Module: Speculate::Generator

Extended by:
Generator
Included in:
Generator
Defined in:
lib/speculate/generator.rb

Constant Summary collapse

Error =
Class.new RuntimeError

Instance Method Summary collapse

Instance Method Details

#generate(pair) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/speculate/generator.rb', line 5

def generate pair
  unless pair.outdated?
    raise Error,
      "Must not call generate for #{pair.speculation.path} -> #{pair.spec.path}, because it is not outdated"
  end
  puts "Generating: #{pair.speculation.path} -> #{pair.spec.path}"
  text = Speculate::Parser.new(pair.speculation).parse
  File.open(pair.spec.path, "w"){ |f|
    f.puts _header(pair.speculation.path)
    f.puts text
    f.puts _footer
  }
end