Class: Xfabricator::FabricationConfig
- Inherits:
-
Object
- Object
- Xfabricator::FabricationConfig
- Defined in:
- lib/xfabricator/fabrication_config.rb
Instance Attribute Summary collapse
-
#default_target ⇒ Object
readonly
Returns the value of attribute default_target.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#template_location ⇒ Object
readonly
Returns the value of attribute template_location.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(project_file, template_location, variables, default_target_name) ⇒ FabricationConfig
constructor
A new instance of FabricationConfig.
Constructor Details
#initialize(project_file, template_location, variables, default_target_name) ⇒ FabricationConfig
Returns a new instance of FabricationConfig.
35 36 37 38 39 40 41 |
# File 'lib/xfabricator/fabrication_config.rb', line 35 def initialize(project_file, template_location, variables, default_target_name) project = Xcodeproj::Project.open(project_file) @project = project @variables = variables @template_location = template_location @default_target = project.targets.find { |target| target.name == default_target_name } end |
Instance Attribute Details
#default_target ⇒ Object (readonly)
Returns the value of attribute default_target.
10 11 12 |
# File 'lib/xfabricator/fabrication_config.rb', line 10 def default_target @default_target end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
8 9 10 |
# File 'lib/xfabricator/fabrication_config.rb', line 8 def project @project end |
#template_location ⇒ Object (readonly)
Returns the value of attribute template_location.
7 8 9 |
# File 'lib/xfabricator/fabrication_config.rb', line 7 def template_location @template_location end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
9 10 11 |
# File 'lib/xfabricator/fabrication_config.rb', line 9 def variables @variables end |
Class Method Details
.create_config(config) ⇒ Object
43 44 45 46 47 |
# File 'lib/xfabricator/fabrication_config.rb', line 43 def FabricationConfig.create_config(config) = {} config.call() FabricationConfig.new [:project_file], [:template_location], [:variables], [:default_target] end |
.load_config(config_file) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/xfabricator/fabrication_config.rb', line 12 def FabricationConfig.load_config(config_file) unless config_file raise ArgumentError, 'config file not specified' end unless config_file.exist? raise ArgumentError, "config file doesn't exist" end relative_path = config_file.parent.to_s config = eval(File.read(config_file.to_s), binding) unless config raise RuntimeError, "config was not loaded" end unless config.is_a? FabricationConfig raise RuntimeError, "Valid config not loaded" end return config end |