2024-01-28 04:43:09 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
$stdout.sync = true
|
|
|
|
|
|
|
|
def noecho
|
2024-01-28 06:16:40 +01:00
|
|
|
system("stty -echo")
|
|
|
|
yield
|
|
|
|
ensure
|
|
|
|
system("stty echo")
|
2024-01-28 04:43:09 +01:00
|
|
|
end
|
|
|
|
|
2024-01-28 06:16:40 +01:00
|
|
|
def read
|
|
|
|
noecho { $stdin.gets }
|
2024-01-28 06:23:09 +01:00
|
|
|
.gsub(/[^A-Za-z0-9_\s\/\-,;:*"'.]/, '')
|
2024-01-28 06:16:40 +01:00
|
|
|
end
|
|
|
|
|
2024-01-28 07:26:10 +01:00
|
|
|
open = false
|
2024-01-28 04:43:09 +01:00
|
|
|
loop do
|
2024-01-28 06:16:40 +01:00
|
|
|
tab, buf = "\t", read
|
2024-01-28 07:26:10 +01:00
|
|
|
if buf.include?(tab)
|
|
|
|
print "\n}\n" if open
|
2024-01-28 06:16:40 +01:00
|
|
|
class_name, class_body = buf.split(tab, 2)
|
2024-01-28 04:43:09 +01:00
|
|
|
class_name.gsub!(%r|([/.])|) { "\\#{_1}" }
|
2024-01-28 07:26:10 +01:00
|
|
|
print ".#{class_name} {", "\n", " " * 2, class_body.chomp
|
|
|
|
open = true
|
|
|
|
elsif buf.include?(":")
|
|
|
|
print "\n", " " * 2, buf.chomp
|
|
|
|
elsif open
|
|
|
|
open = false
|
|
|
|
print "\n}\n"
|
2024-01-28 04:43:09 +01:00
|
|
|
end
|
|
|
|
end
|