Class: Opengraphplus::Generators::EnvGenerator

Inherits:
BaseGenerator
  • Object
show all
Defined in:
lib/generators/opengraphplus/env/env_generator.rb

Constant Summary collapse

ENV_FILES =
%w[.env .env.local .env.development .env.development.local .envrc].freeze
ENV_VAR_NAME =
"OPENGRAPHPLUS__API_KEY"

Constants inherited from BaseGenerator

BaseGenerator::API_KEY_PREFIX

Instance Method Summary collapse

Methods inherited from BaseGenerator

#validate_api_key

Instance Method Details

#append_to_env_fileObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/generators/opengraphplus/env/env_generator.rb', line 18

def append_to_env_file
  if options[:envfile]
    write_to_env_file(options[:envfile], create: true)
  else
    env_file = detect_env_file
    if env_file
      write_to_env_file(env_file)
    else
      say_status :skip, "No env file found (create one or use -e)", :yellow
    end
  end
end

#create_initializerObject



31
32
33
# File 'lib/generators/opengraphplus/env/env_generator.rb', line 31

def create_initializer
  template "initializer.rb.tt", "config/initializers/opengraphplus.rb"
end