Class: OneSky::Generators::InitGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- OneSky::Generators::InitGenerator
- Defined in:
- lib/generators/one_sky/init/init_generator.rb
Constant Summary collapse
- CONFIG_PATH =
File.join(Rails.root.to_s, 'config', 'one_sky.yml')
- YAML_COMMENT =
<<-YAML # # To load your OneSky details from the environment # just add some erb tags like this. # # api_key: <%= ENV["ONESKY_API_KEY"] %> # api_secret: <%= ENV["ONESKY_API_SECRET"] %> # project: <%= ENV["ONESKY_PROJECT"] %> # platform_id: <%= ENV["ONESKY_PLATFORM_ID"] %> # YAML
Instance Method Summary collapse
Instance Method Details
#config_hash ⇒ Object
38 39 40 |
# File 'lib/generators/one_sky/init/init_generator.rb', line 38 def config_hash {"api_key" => api_key, "api_secret" => api_secret, "project" => project, "platform_id" => platform_id.to_i} end |
#create_config_file ⇒ Object
42 43 44 |
# File 'lib/generators/one_sky/init/init_generator.rb', line 42 def create_config_file create_file(CONFIG_PATH, YAML_COMMENT+config_hash.to_yaml) end |
#remove_config_file ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/generators/one_sky/init/init_generator.rb', line 15 def remove_config_file if File.exists? CONFIG_PATH if .force? say_status("warning", "config file already exists and is being overwritten.", :yellow) remove_file CONFIG_PATH else say_status("error", "config file already exists. Use --force to overwrite.", :red) end end end |