Module: DaemonKit::Generators

Defined in:
lib/daemon_kit/generators.rb,
lib/daemon_kit/generators/base.rb,
lib/generators/daemon_kit/app/app_generator.rb,
lib/generators/daemon_kit/amqp/amqp_generator.rb,
lib/generators/daemon_kit/cron/cron_generator.rb,
lib/generators/daemon_kit/xmpp/xmpp_generator.rb,
lib/generators/daemon_kit/rspec/rspec_generator.rb,
lib/generators/daemon_kit/ruote/ruote_generator.rb,
lib/generators/daemon_kit/cucumber/cucumber_generator.rb,
lib/generators/daemon_kit/test_unit/test_unit_generator.rb,
lib/generators/daemon_kit/capistrano/capistrano_generator.rb,
lib/generators/daemon_kit/nanite_agent/nanite_agent_generator.rb

Defined Under Namespace

Classes: AmqpGenerator, AppGenerator, Base, CapistranoGenerator, CronGenerator, CucumberGenerator, Error, NaniteAgentGenerator, RuoteGenerator, SpecGenerator, TestUnitGenerator, XmppGenerator

Class Method Summary collapse

Class Method Details

.configure!Object



21
22
# File 'lib/daemon_kit/generators.rb', line 21

def configure!
end

.helpObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/daemon_kit/generators.rb', line 40

def help
  namespaces = constants.inject([]) do |list, sym|
    unless sym == :Base || sym == :AppGenerator
      klass = const_get( sym )
      list << klass.namespace if klass.respond_to?( :namespace )
    end

    list
  end

  puts "Usage:"
  puts "  script/generate GENERATOR [args] [options]"
  puts
  puts "General options:"
  puts "  -h, [--help]     # Print generators options and usage"
  puts "  -p, [--pretend]  # Run but do not make any changes"
  puts "  -f, [--force]    # Overwrite files that already exist"
  puts "  -s, [--skip]     # Skip files that already exist"
  puts "  -q, [--quiet]    # Supress status output"
  puts
  puts "Available generators:"

  namespaces.each { |ns| puts "  " + ns }
  puts
end

.invoke(namespace, args = ARGV, config = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/daemon_kit/generators.rb', line 24

def invoke( namespace, args = ARGV, config = {} )
  klass_name = constants.detect do |sym|
    klass = const_get( sym )
    klass.respond_to?( :namespace ) && klass.namespace == namespace
  end

  if klass_name.nil?
    raise Error, "Could not find generator #{namespace}."
  end

  klass = const_get( klass_name )

  args << '--help' if args.empty? && klass.arguments.any? { |a| a.required? }
  klass.start( args, config )
end