class Rodolfo::CLI

Rodolfo CLI

Public Class Methods

exit_on_failure?() click to toggle source
# File lib/rodolfo/cli.rb, line 46
def self.exit_on_failure?
  true
end

Public Instance Methods

__print_version() click to toggle source
# File lib/rodolfo/cli.rb, line 53
def __print_version
  puts VERSION
end
help(*args, &block) click to toggle source
Calls superclass method
# File lib/rodolfo/cli.rb, line 85
def help(*args, &block)
  puts "Rodolfo v#{Rodolfo::VERSION}"
  super(*args, &block)
end
read(pdf) click to toggle source
# File lib/rodolfo/cli.rb, line 63
def read(pdf)
  puts Rodolfo::Reader.new(pdf).to_json
end
render(recipe_path) click to toggle source
# File lib/rodolfo/cli.rb, line 71
def render(recipe_path)
  file_name = options['save-to']
  strict = options['strict']

  data = $stdin.tty? ? {} : JSON.parse($stdin.read, symbolize_names: true)
  content = Rodolfo::Renderer.new(recipe_path, data, strict).render

  file_name ? File.write(file_name, content) : STDOUT.write(content)
  exit 0
rescue RenderError, SchemaValidationError => error
  STDOUT.write error.errors.to_json
  exit 2
end
schema(recipe_path) click to toggle source
# File lib/rodolfo/cli.rb, line 58
def schema(recipe_path)
  puts Rodolfo::Renderer.new(recipe_path, {}).json_schema
end