Class: Precedent::CLI
- Inherits:
-
Thor
- Object
- Thor
- Precedent::CLI
- Defined in:
- lib/precedent/cli.rb
Constant Summary collapse
- OUTPUT_FORMATS =
{ :json => lambda { |hashes, pretty| require 'json' = pretty ? :pretty_generate : :generate JSON.send(, hashes) }, :yaml => lambda { |hashes, pretty| require 'yaml' hashes.to_yaml } }
Instance Method Summary collapse
Instance Method Details
#translate(file = STDIN) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/precedent/cli.rb', line 34 def translate(file=STDIN) input = file.is_a?(String) ? File.read(file) : file.read parsed = Precedent.new(input).to_hashes output = OUTPUT_FORMATS[[:format].to_sym].call(parsed, [:pretty]) STDOUT.write(output) end |