Class: Kodiak::Generator
- Inherits:
-
Object
- Object
- Kodiak::Generator
- Defined in:
- lib/kodiak/generator.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#config_exists? ⇒ Boolean
check to see if Kodiak.yaml already exists in directory.
-
#copy_config ⇒ Object
copy sample Kodiak.yaml to directory.
- #generate ⇒ Object
-
#initialize(options) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(options) ⇒ Generator
Returns a new instance of Generator.
6 7 8 |
# File 'lib/kodiak/generator.rb', line 6 def initialize() @options = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/kodiak/generator.rb', line 4 def @options end |
Instance Method Details
#config_exists? ⇒ Boolean
check to see if Kodiak.yaml already exists in directory
19 20 21 |
# File 'lib/kodiak/generator.rb', line 19 def config_exists? File.exists? Kodiak::CONFIG_FILENAME end |
#copy_config ⇒ Object
copy sample Kodiak.yaml to directory
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kodiak/generator.rb', line 24 def copy_config FileUtils.cp_r "#{Kodiak::CONFIG_PATH}/#{Kodiak::CONFIG_FILENAME}", "#{Kodiak::CONFIG_FILENAME}", :remove_destination => true # if logs exist already, don't overwrite them. Not even in force mode. Never ever. if not File.exists? Kodiak::LOG_FILENAME FileUtils.cp_r "#{Kodiak::CONFIG_PATH}/#{Kodiak::LOG_FILENAME}", "#{Kodiak::LOG_FILENAME}", :remove_destination => true end Kodiak::Notification.new "Kodiak configuration created at #{Kodiak::CONFIG_FILENAME}\n", "success" system("open #{Kodiak::CONFIG_FILENAME}") exit end |
#generate ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/kodiak/generator.rb', line 10 def generate if config_exists? && ! [:force] Kodiak::Notification.new "Kodiak config already exists in this directory. Use --force to overwrite.\n", "failure" elsif (!config_exists?) || (config_exists? && [:force]) copy_config end end |