Class: OneSky::Generators::InitGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/one_sky/init/init_generator.rb

Constant Summary collapse

@@config_file =
[Rails.root.to_s, 'config', 'one_sky.yml'].join('/')

Instance Method Summary collapse

Instance Method Details

#create_config_fileObject



23
24
25
26
27
# File 'lib/generators/one_sky/init/init_generator.rb', line 23

def create_config_file
  config_hash = {"api_key" => api_key, "api_secret" => api_secret, "project" => project}
  create_file(@@config_file, config_hash.to_yaml)
  say_status("info", "config file #{@@config_file} created.", :green)
end

#remove_config_fileObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/generators/one_sky/init/init_generator.rb', line 11

def remove_config_file
  if File.exists? @@config_file
    if options.force?
      say_status("warning", "config file already exists and is being overwritten.", :yellow)
      remove_file @@config_file
    else
      say_status("error", "config file already exists. Use --force to overwrite.", :red)
      raise "Error: OneSky config file exists."
    end
  end
end