Class: Inkling::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/inkling/commands/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#forceObject

Returns the value of attribute force.



23
24
25
# File 'lib/inkling/commands/generator.rb', line 23

def force
  @force
end

#pretendObject

Returns the value of attribute pretend.



23
24
25
# File 'lib/inkling/commands/generator.rb', line 23

def pretend
  @pretend
end

#quietObject

Returns the value of attribute quiet.



23
24
25
# File 'lib/inkling/commands/generator.rb', line 23

def quiet
  @quiet
end

#skipObject

Returns the value of attribute skip.



23
24
25
# File 'lib/inkling/commands/generator.rb', line 23

def skip
  @skip
end

#template_pathObject

Returns the value of attribute template_path.



23
24
25
# File 'lib/inkling/commands/generator.rb', line 23

def template_path
  @template_path
end

Instance Method Details

#generateObject



62
63
64
# File 'lib/inkling/commands/generator.rb', line 62

def generate
  puts "Generating using: #{ARGV*' '} is incomplete"
end

#option(arg) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/inkling/commands/generator.rb', line 40

def option arg
  case arg
  when '--help', '-h', '-?'
    puts USAGE
    exit(0)
  when '-m', /^--template=(.*)/
    template_path = $1 || ARGV.shift
  when '-p', '--pretend'
    pretend = true
  when '--force'
    force = true
  when '-s', '--skip'
    skip = true
  when '-q', '--quiet'
    quiet = true
  else
    puts "Inkling: option #{arg} unknown"
    puts USAGE
    exit(1)
  end
end

#startObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/inkling/commands/generator.rb', line 25

def start
  # Extract and save options:
  options = ARGV.select{|o| o =~ /^-/ }
  options.each{|o| option o }
  ARGV.delete_if{|o| options.include?(o)}

  # Process the command:
  case cmd = ARGV.shift
  when 'generate'
    generate
  else
    puts "Inkling: command #{cmd} unknown"
  end
end