Class: Boring::Annotate::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
BoringGenerators::GeneratorHelper
Defined in:
lib/generators/boring/annotate/install/install_generator.rb

Instance Method Summary collapse

Methods included from BoringGenerators::GeneratorHelper

#app_ruby_version, #bundle_install, #check_and_install_gem, #gem_installed?, #inject_into_file_if_new

Instance Method Details

#add_annotate_gemObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/boring/annotate/install/install_generator.rb', line 18

def add_annotate_gem
  if gem_installed?("annotate")
    say "annotate is already in the Gemfile, skipping it ...", :yellow
  else
    say "Adding annotate gem", :green
    gem_content = <<~RUBY
      \n
      \tgem "annotate"
    RUBY
    insert_into_file "Gemfile", gem_content, after: /group :development do/
    bundle_install
  end
end

#configure_annotateObject



32
33
34
35
36
37
38
# File 'lib/generators/boring/annotate/install/install_generator.rb', line 32

def configure_annotate
  say "Configuring annotate", :green

  Bundler.with_unbundled_env do
    run "bundle exec rails g annotate:install"
  end
end

#update_auto_annotate_models_rakeObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/generators/boring/annotate/install/install_generator.rb', line 40

def update_auto_annotate_models_rake
  return unless options[:skip_on_db_migrate]

  say "Setting skip_on_db_migrate to false on file 'lib/tasks/auto_annotate_models.rake'",
      :green

  gsub_file "lib/tasks/auto_annotate_models.rake",
            "'skip_on_db_migrate'          => 'false'",
            "'skip_on_db_migrate'          => 'true'"
end