class Khaleesi::CLI::Produce

Attributes

input_file[R]

Public Class Methods

desc() click to toggle source
# File lib/khaleesi/cli.rb, line 85
def self.desc
  'produce html code for specify markdown file'
end
doc() { |'usage: khaleesi produce <filename>'| ... } click to toggle source
# File lib/khaleesi/cli.rb, line 89
def self.doc
  return enum_for(:doc) unless block_given?

  yield 'usage: khaleesi produce <filename>'
  yield ''
  yield '<filename>  specify a file to read'
end
new(opts={}) click to toggle source
# File lib/khaleesi/cli.rb, line 119
def initialize(opts={})
  @input_file = opts[:input_file]
end
parse(argv) click to toggle source
# File lib/khaleesi/cli.rb, line 97
def self.parse(argv)
  opts = {:input_file => nil}

  until argv.empty?
    opts[:input_file] = argv.shift
  end

  puts 'unspecific markdown file' unless opts[:input_file]

  new(opts)
end

Public Instance Methods

input() click to toggle source
# File lib/khaleesi/cli.rb, line 113
def input
  @input ||= input_stream.read
end
input_stream() click to toggle source
# File lib/khaleesi/cli.rb, line 109
def input_stream
  @input_stream ||= FileReader.new(@input_file)
end
run() click to toggle source
# File lib/khaleesi/cli.rb, line 123
def run
  return unless @input_file
  print Generator.new.handle_markdown(input)
end