Class: Html2fortitude::Run

Inherits:
Object
  • Object
show all
Defined in:
lib/html2fortitude/run.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Run

Returns a new instance of Run.



7
8
9
# File 'lib/html2fortitude/run.rb', line 7

def initialize(argv)
  @argv = argv
end

Instance Method Details

#run!Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/html2fortitude/run.rb', line 11

def run!
  parse_arguments!

  for_each_input_file do |name_and_block|
    name = name_and_block[:name]
    block = name_and_block[:block]

    contents = nil
    block.call { |io| contents = io.read }

    effective_options = trollop_options.select do |key, value|
      %w{output class_name class_base superclass method assigns do_end new_style_hashes}.include?(key.to_s)
    end

    source_template = Html2fortitude::SourceTemplate.new(name, contents, effective_options)
    source_template.write_transformed_content!

    unless @argv.include?("-")
      puts "#{source_template.filename} -> #{source_template.output_filename} (#{source_template.line_count} lines)"
    end
  end
end