Module: GenMachine::Generators::Generator

Included in:
RubyGenerator
Defined in:
lib/genmachine/generators/generator.rb

Instance Method Summary collapse

Instance Method Details

#generate_classObject



19
20
21
# File 'lib/genmachine/generators/generator.rb', line 19

def generate_class
  puts "TODO: Generate class (#{@classname}): #{@class_fname}" if @debug
end

#generate_executableObject



23
24
25
26
# File 'lib/genmachine/generators/generator.rb', line 23

def generate_executable
  return unless @gen_executable
  puts "TODO: Generate executable: #{@exe_fname}" if @debug
end

#initialize(opts = {}) ⇒ Object

Raises:

  • (ArgumentError)


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

def initialize(opts={})
  opts ||= {}
  @spec_ast       = opts.delete(:spec_ast)
  @gen_executable = opts.delete(:executable)
  @classname      = opts.delete(:classname)  || 'MiscParser'
  @test_file      = opts.delete(:test_file)
  @output_dir     = opts.delete(:output_dir) || './'
  @class_fname    = opts.delete(:class_fname)|| @classname.to_underscored
  @exe_fname      = opts.delete(:exe_fname)  || @classname.sub(/parser$/i,'').to_underscored
  @debug          = opts.delete(:debug)
  @gen_executable = false if @gen_executable.nil?
  @debug          = false if @debug.nil?
  raise ArgumentError, "Must include the table specification data (:spec_ast)" if @spec_ast.nil?
end

#run_testObject



28
29
30
31
# File 'lib/genmachine/generators/generator.rb', line 28

def run_test
  return if @test_file.nil?
  puts "TODO: Run test" if @debug
end