Class: Pu::Gem::DotenvGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
PlutoniumGenerators::Generator
Defined in:
lib/generators/pu/gem/dotenv/dotenv_generator.rb

Instance Method Summary collapse

Methods included from PlutoniumGenerators::Generator

derive_association_name, find_shared_namespace, included

Methods included from PlutoniumGenerators::Concerns::Logger

#debug, #error, #exception, #info, #success, #warn

Methods included from PlutoniumGenerators::Concerns::Config

#read_config, #write_config

Instance Method Details

#startObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/generators/pu/gem/dotenv/dotenv_generator.rb', line 14

def start
  in_root do
    [".env", ".env.local", ".env.template", ".env.local.template", ".env.test.local"].each do |file|
      copy_file file
    end

    copy_file "config/initializers/001_ensure_required_env.rb"

    gitignore "!/.env", "!/.env.template", "!/.env.local.template", "!/.env.test.local"

    insert_into_file "Gemfile", "\ngem \"dotenv\", groups: %i[development test]\n", after: /^gem ["']rails["'].*\n/
    bundle!
  end
rescue => e
  exception "#{self.class} failed:", e
end