Class: Boring::RailsErd::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
BoringGenerators::GeneratorHelper
Defined in:
lib/generators/boring/rails_erd/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_rails_erd_gemObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/generators/boring/rails_erd/install/install_generator.rb', line 12

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

#configure_rails_erd_gemObject



26
27
28
29
30
31
32
# File 'lib/generators/boring/rails_erd/install/install_generator.rb', line 26

def configure_rails_erd_gem
  say 'Configuring rails-erd gem', :green

  Bundler.with_unbundled_env do
    run 'bundle exec rails g erd:install'
  end
end