Sha256: d6525ad919383a58a1c54b771a96820992dda3145d2a33f6ce812c41d80d81fa

Contents?: true

Size: 1.32 KB

Versions: 39

Compression:

Stored size: 1.32 KB

Contents

# Piggy back off of Rails Generators.
class Jets::Generator
  def self.invoke(generator, *args)
    new(generator, *args).run(:invoke)
  end

  def self.revoke(generator, *args)
    new(generator, *args).run(:revoke)
  end

  def initialize(generator, *args)
    @generator, @args = generator, args
  end

  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: 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.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
    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

  def template_paths
    templates_path = File.expand_path("../generator/templates", __FILE__)
    [templates_path]
  end
end

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
jets_bb_fork-0.0.4 lib/jets/generator.rb
jets-1.9.32 lib/jets/generator.rb
jets-1.9.31 lib/jets/generator.rb
jets-1.9.30 lib/jets/generator.rb
jets-1.9.29 lib/jets/generator.rb
jets-1.9.28 lib/jets/generator.rb
jets-1.9.27 lib/jets/generator.rb
jets-1.9.26 lib/jets/generator.rb
jets-1.9.25 lib/jets/generator.rb
jets-1.9.24 lib/jets/generator.rb
jets-1.9.23 lib/jets/generator.rb
jets-1.9.22 lib/jets/generator.rb
jets-1.9.21 lib/jets/generator.rb
jets-1.9.20 lib/jets/generator.rb
jets-1.9.19 lib/jets/generator.rb
jets-1.9.18 lib/jets/generator.rb
jets-1.9.17 lib/jets/generator.rb
jets-1.9.16 lib/jets/generator.rb
jets-1.9.15 lib/jets/generator.rb
jets-1.9.14 lib/jets/generator.rb