Sha256: 2b35d08329d5f51df9e2b73414f5f153e64bd497dba827caf02ce0f15369bbe2

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

require "generators/flipflop/features/features_generator"
require "generators/flipflop/migration/migration_generator"
require "generators/flipflop/routes/routes_generator"

class Flipflop::InstallGenerator < Rails::Generators::Base
  def invoke_generators
    Flipflop::FeaturesGenerator.new([], options).invoke_all
    Flipflop::MigrationGenerator.new([], options).invoke_all
    Flipflop::RoutesGenerator.new([], options).invoke_all
  end

  def configure_dashboard
    comment = <<-RUBY
# Replace with a lambda or method name defined in ApplicationController
# to implement access control for the Flipflop dashboard.
RUBY

    forbidden = <<-RUBY
config.flipflop.dashboard_access_filter = -> { head :forbidden }
RUBY

    allowed = <<-RUBY
config.flipflop.dashboard_access_filter = nil
RUBY

    environment(indent(comment + forbidden + "\n", 4).lstrip)
    environment(indent(comment + allowed + "\n", 2).lstrip, env: [:development, :test])
  end

  private

  def indent(content, multiplier = 2)
    spaces = " " * multiplier
    content.each_line.map {|line| line.blank? ? line : "#{spaces}#{line}" }.join
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flipflop-2.3.1 lib/generators/flipflop/install/install_generator.rb
flipflop-2.3.0 lib/generators/flipflop/install/install_generator.rb
flipflop-2.2.1 lib/generators/flipflop/install/install_generator.rb