Sha256: c535d88e3e6ba87c4d1c10b684982726d17220a20c650634913b9972a09f20d5

Contents?: true

Size: 972 Bytes

Versions: 5

Compression:

Stored size: 972 Bytes

Contents

require 'factory_bot_rails/generators/rspec_generator'
require 'factory_bot_rails/generators/non_rspec_generator'
require 'factory_bot_rails/generators/null_generator'

module FactoryBotRails
  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_bot_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_bot_disabled?
      rails_options[:factory_bot] == false
    end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
factory_bot_rails-4.11.1 lib/factory_bot_rails/generator.rb
factory_bot_rails-4.11.0 lib/factory_bot_rails/generator.rb
factory_bot_rails-4.10.0 lib/factory_bot_rails/generator.rb
factory_bot_rails-4.8.2 lib/factory_bot_rails/generator.rb
factory_bot_rails-1.0.0.alpha lib/factory_bot_rails/generator.rb