lib/jets/generator.rb in jets-1.8.9 vs lib/jets/generator.rb in jets-1.8.10
- old
+ new
@@ -1,35 +1,42 @@
# Piggy back off of Rails Generators.
class Jets::Generator
def self.invoke(generator, *args)
- new(generator, *args).invoke
+ new(generator, *args).run(:invoke)
end
+ def self.revoke(generator, *args)
+ new(generator, *args).run(:revoke)
+ end
+
def initialize(generator, *args)
- @generator = generator
- @args = args
+ @generator, @args = generator, args
end
- def invoke
+ def run(behavior=:invoke)
# lazy require so Rails const is only defined when using generators
require "rails/generators"
require "rails/configuration"
Rails::Generators.configure!(config)
- Rails::Generators.invoke(@generator, @args, behavior: :invoke, destination_root: Jets.root)
+ Rails::Generators.invoke(@generator, @args, behavior: behavior, destination_root: Jets.root)
end
def config
g = Rails::Configuration::Generators.new
g.orm :active_record, migration: true, timestamps: true
# TODO: support g.orm :dynamodb
- g.template_engine :erb
g.test_framework false #:test_unit, fixture: false
# g.test_framework :rspec # need to
# TODO: load rspec configuration to use rspec
g.stylesheets false
g.javascripts false
g.assets false
- g.api Jets.config.mode == 'api'
+ if Jets.config.mode == 'api'
+ g.api_only = true
+ g.template_engine nil
+ else
+ g.template_engine :erb
+ end
g.resource_route true
g.templates.unshift(template_paths)
g
end