Class: Ive::Configuration
- Inherits:
-
Object
- Object
- Ive::Configuration
- Defined in:
- lib/ive/configuration.rb
Instance Attribute Summary collapse
-
#configurations ⇒ Object
readonly
Returns the value of attribute configurations.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
- #config_path ⇒ Object
- #create_file(xcode_params) ⇒ Object
- #exists? ⇒ Boolean
- #initial_content(xcode_params) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #read_config ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 |
# File 'lib/ive/configuration.rb', line 9 def initialize self.read_config if self.exists? end |
Instance Attribute Details
#configurations ⇒ Object (readonly)
Returns the value of attribute configurations.
7 8 9 |
# File 'lib/ive/configuration.rb', line 7 def configurations @configurations end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
6 7 8 |
# File 'lib/ive/configuration.rb', line 6 def targets @targets end |
Instance Method Details
#config_path ⇒ Object
38 39 40 |
# File 'lib/ive/configuration.rb', line 38 def config_path @config_path ||= File.join(Ive.path,'.ive') end |
#create_file(xcode_params) ⇒ Object
13 14 15 |
# File 'lib/ive/configuration.rb', line 13 def create_file xcode_params File.open(config_path, "w") { |f| f.write(initial_content(xcode_params)) } unless exists? end |
#exists? ⇒ Boolean
34 35 36 |
# File 'lib/ive/configuration.rb', line 34 def exists? File.exists?(self.config_path) end |
#initial_content(xcode_params) ⇒ Object
42 43 44 |
# File 'lib/ive/configuration.rb', line 42 def initial_content xcode_params xcode_params.to_yaml end |
#read_config ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/ive/configuration.rb', line 17 def read_config params = YAML::load File.open(self.config_path) if params @targets = params.keys @configurations = params end end |
#valid? ⇒ Boolean
25 26 27 28 29 30 31 32 |
# File 'lib/ive/configuration.rb', line 25 def valid? return false unless @targets return false unless @targets.count > 0 return false unless @configurations values = @configurations.values.select { |v| v.count > 0 } return false if values.empty? true end |