Class: Khaleesi::CLI::Produce
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
class_from_arg, #create_file_p, normalize_syntax
Constructor Details
#initialize(opts = {}) ⇒ Produce
Returns a new instance of Produce.
119
120
121
|
# File 'lib/khaleesi/cli.rb', line 119
def initialize(opts={})
@input_file = opts[:input_file]
end
|
Instance Attribute Details
Returns the value of attribute input_file.
117
118
119
|
# File 'lib/khaleesi/cli.rb', line 117
def input_file
@input_file
end
|
Class Method Details
.desc ⇒ Object
85
86
87
|
# File 'lib/khaleesi/cli.rb', line 85
def self.desc
'produce html code for specify markdown file'
end
|
.doc {|'usage: khaleesi produce <filename>'| ... } ⇒ Object
89
90
91
92
93
94
95
|
# 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
|
.parse(argv) ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
|
# 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
|
Instance Method Details
113
114
115
|
# File 'lib/khaleesi/cli.rb', line 113
def input
@input ||= input_stream.read
end
|
109
110
111
|
# File 'lib/khaleesi/cli.rb', line 109
def input_stream
@input_stream ||= FileReader.new(@input_file)
end
|
#run ⇒ Object
123
124
125
126
|
# File 'lib/khaleesi/cli.rb', line 123
def run
return unless @input_file
print Generator.new.handle_markdown(input)
end
|