31 lines
583 B
Ruby
Executable file
31 lines
583 B
Ruby
Executable file
#!/usr/bin/env ruby
|
|
$stdout.sync = true
|
|
|
|
def noecho
|
|
system("stty -echo")
|
|
yield
|
|
ensure
|
|
system("stty echo")
|
|
end
|
|
|
|
def read
|
|
noecho { $stdin.gets }
|
|
.gsub(/[^A-Za-z0-9_\s\/\-,;:*"'.]/, '')
|
|
end
|
|
|
|
open = false
|
|
loop do
|
|
tab, buf = "\t", read
|
|
if buf.include?(tab)
|
|
print "\n}\n" if open
|
|
class_name, class_body = buf.split(tab, 2)
|
|
class_name.gsub!(%r|([/.])|) { "\\#{_1}" }
|
|
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"
|
|
end
|
|
end
|