Class: Prettyrb::CLI
- Inherits:
-
Thor
- Object
- Thor
- Prettyrb::CLI
- Defined in:
- lib/prettyrb/cli.rb
Instance Method Summary collapse
Instance Method Details
#format(file) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/prettyrb/cli.rb', line 6 def format(file) content = File.read(file) formatted_content = Prettyrb::Formatter.new(content).format puts formatted_content end |
#write(*files) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/prettyrb/cli.rb', line 14 def write(*files) files.each do |file| content = File.read(file) begin formatted_content = Prettyrb::Formatter.new(content).format rescue Exception => e puts "Failed to write #{file}" throw e end File.open(file, 'w') do |f| f.write(formatted_content) end end end |