lib/ambient.rb in ambient-xcode-0.2.0 vs lib/ambient.rb in ambient-xcode-0.3.0

- old
+ new

@@ -5,10 +5,11 @@ end end end require_relative 'project_helper' +require_relative 'capabilities_helper' require_relative 'dsl' module Ambient extend self Ambient::ROOT = File.expand_path('.', File.dirname(__FILE__)) @@ -17,10 +18,11 @@ @project_options = {} @shared_target_options = {} @target_options = {} @scheme_options = {} @parents = {} + @capabilities = {} def configure(&block) instance_eval &block end @@ -55,34 +57,44 @@ @project_options[option] = value end end end - def setup_project + def set_capability(target_name, capability_name) + capabilities = @capabilities[target_name] ||= [] + capabilities << capability_name + end + + def setup_project(ambientfile) + run_ambientfile(ambientfile) project_helper.print_info - reset_project_to_defaults - reset_targets_to_defaults + reset_project_to_defaults if @use_defaults + reset_targets_to_defaults if @use_defaults + reset_capabilites_to_defaults if @use_defaults process_project_options process_scheme_options process_shared_target_options process_target_options + process_capabilities + project_helper.save_changes end def reset_project_to_defaults - if @use_defaults - puts "resetting project settings to xcode default settings" - project_helper.reset_project_to_defaults - end + puts "resetting project settings to xcode default settings" + project_helper.reset_project_to_defaults end def reset_targets_to_defaults - if @use_defaults - puts "resetting target settings to xcode default settings" - project_helper.reset_targets_to_defaults - end + puts "resetting target settings to xcode default settings" + project_helper.reset_targets_to_defaults end + def reset_capabilites_to_defaults + puts "resetting capabilities to xcode default settings" + project_helper.reset_capabilities_to_defaults + end + def process_project_options puts "applying ambient project settings" project_helper.process_project_options(@project_options) end @@ -100,10 +112,15 @@ puts "applying ambient target settings" load_in_parent_target_values project_helper.process_target_options(@target_options) end + def process_capabilities + puts "applying ambient capabilities" + project_helper.process_capabilities(@capabilities) + end + def load_in_parent_target_values @parents.each do |target, parents| parents.each do |child, parent| if parent options = @target_options[target] @@ -113,10 +130,12 @@ end end end end - ambient = File.join(Dir.pwd, 'Ambientfile') - raise "ambient not found" unless File.exists?(ambient) - - load ambient + def run_ambientfile(filename) + puts "Reading settings from #{filename}" + ambient = File.join(Dir.pwd, filename) + raise "#{filename} not found in current directory." unless File.exists?(ambient) + load ambient + end end