Sha256: 701afd2c3cb659b6de30cf133ac879667d9340ad8c1b7f7226a12eb91c88eef2

Contents?: true

Size: 1.06 KB

Versions: 49

Compression:

Stored size: 1.06 KB

Contents

require "rails/configuration"

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

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

  def invoke
    Rails::Generators.configure!(config)
    Rails::Generators.invoke(@generator, @args, behavior: :invoke, 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'
    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

49 entries across 49 versions & 1 rubygems

Version Path
jets-1.4.11 lib/jets/generator.rb
jets-1.4.10 lib/jets/generator.rb
jets-1.4.9 lib/jets/generator.rb
jets-1.4.8 lib/jets/generator.rb
jets-1.4.7 lib/jets/generator.rb
jets-1.4.6 lib/jets/generator.rb
jets-1.4.5 lib/jets/generator.rb
jets-1.4.4 lib/jets/generator.rb
jets-1.4.3 lib/jets/generator.rb
jets-1.4.2 lib/jets/generator.rb
jets-1.4.1 lib/jets/generator.rb
jets-1.4.0 lib/jets/generator.rb
jets-1.3.9 lib/jets/generator.rb
jets-1.3.8 lib/jets/generator.rb
jets-1.3.7 lib/jets/generator.rb
jets-1.3.6 lib/jets/generator.rb
jets-1.3.5 lib/jets/generator.rb
jets-1.3.4 lib/jets/generator.rb
jets-1.3.3 lib/jets/generator.rb
jets-1.3.2 lib/jets/generator.rb