Class: Boring::SimpleForm::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/boring/simple_form/install/install_generator.rb

Constant Summary collapse

ALLOWED_CSS_FRAMEWORK =
%w(bootstrap foundation)

Instance Method Summary collapse

Instance Method Details

#add_bullet_gemObject



16
17
18
19
20
21
# File 'lib/generators/boring/simple_form/install/install_generator.rb', line 16

def add_bullet_gem
  say "Adding SimpleForm gem", :green
  Bundler.with_unbundled_env do
    run "bundle add simple_form"
  end
end

#run_simple_form_generatorObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/generators/boring/simple_form/install/install_generator.rb', line 23

def run_simple_form_generator
  return if options[:skip_generator]

  say "Running SimpleForm Generator", :green
  if options[:css_framework].present? && ALLOWED_CSS_FRAMEWORK.include?(options[:css_framework])
    run "DISABLE_SPRING=1 bundle exec rails generate simple_form:install --#{options[:css_framework]}"
  elsif options[:css_framework].present?
    say "      ERROR: Invalid option css_framework: \#{options[:css_framework]}. Generator allows css_framework: \#{ALLOWED_CSS_FRAMEWORK.join(\", \")}\n    WARNING\n  else\n    run \"rails generate simple_form:install\"\n  end\nend\n", :red