Sha256: f5c158a6a7231e0b073cdf4ef2be28ac5a3eda7f5d3ad602d2855af5c67b05ab

Contents?: true

Size: 979 Bytes

Versions: 17

Compression:

Stored size: 979 Bytes

Contents

require 'factory_girl_rails/generators/rspec_generator'
require 'factory_girl_rails/generators/non_rspec_generator'
require 'factory_girl_rails/generators/null_generator'

module FactoryGirlRails
  class Generator
    def initialize(config)
      @generators = if config.respond_to?(:app_generators)
                      config.app_generators
                    else
                      config.generators
                    end
    end

    def run
      generator.new(@generators).run
    end

    def generator
      if factory_girl_disabled?
        Generators::NullGenerator
      else
        if test_framework == :rspec
          Generators::RSpecGenerator
        else
          Generators::NonRSpecGenerator
        end
      end
    end

    def test_framework
      rails_options[:test_framework]
    end

    def factory_girl_disabled?
      rails_options[:factory_girl] == false
    end

    def rails_options
      @generators.options[:rails]
    end
  end
end

Version data entries

17 entries across 17 versions & 6 rubygems

Version Path
ffactory_girl_rails-4.8.3 lib/factory_girl_rails/generator.rb
ffactory_girl_rails-4.8.2 lib/factory_girl_rails/generator.rb
factory_girl_rails-4.9.0 lib/factory_girl_rails/generator.rb
ffactory_girl_rails-4.8.0 lib/factory_girl_rails/generator.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/factory_girl_rails-4.8.0/lib/factory_girl_rails/generator.rb
factory_girl_rails-4.8.0 lib/factory_girl_rails/generator.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/factory_girl_rails-4.7.0/lib/factory_girl_rails/generator.rb
factory_girl_rails-4.7.0 lib/factory_girl_rails/generator.rb
factory_girl_rails-4.6.0 lib/factory_girl_rails/generator.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/factory_girl_rails-4.5.0/lib/factory_girl_rails/generator.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/factory_girl_rails-4.5.0/lib/factory_girl_rails/generator.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/factory_girl_rails-4.5.0/lib/factory_girl_rails/generator.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/factory_girl_rails-4.5.0/lib/factory_girl_rails/generator.rb
factory_girl_rails-4.5.0 lib/factory_girl_rails/generator.rb
factory_girl_rails-4.4.1 lib/factory_girl_rails/generator.rb
factory_girl_rails-4.4.0 lib/factory_girl_rails/generator.rb
factory_girl_rails-4.3.0 lib/factory_girl_rails/generator.rb