Module: Ambient

Extended by:
Ambient
Included in:
Ambient
Defined in:
lib/ambient.rb

Constant Summary collapse

ROOT =
File.expand_path('.', File.dirname(__FILE__))

Instance Method Summary collapse

Instance Method Details

#configure(&block) ⇒ Object



27
28
29
# File 'lib/ambient.rb', line 27

def configure(&block)
  instance_eval &block
end

#load_in_parent_scheme_valuesObject



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/ambient.rb', line 135

def load_in_parent_scheme_values
  @parents.each do |target, parents|
    parents.each do |child, parent|
      if parent
        if target == :all
          puts "Identified #{child} as a child of #{parent}"
          child_options = @scheme_options[child]
          parent_options = @scheme_options[parent]
        else
          target_options = @target_options[target]
          child_options = target_options[child]
          parent_options = target_options[parent]
        end
        child_options.merge!(parent_options) { |_, child, _| child }
      end
    end
  end
end

#process_capabilitiesObject



125
126
127
128
# File 'lib/ambient.rb', line 125

def process_capabilities
  puts "applying ambient capabilities"
  project_helper.process_capabilities(@capabilities)
end

#process_development_teamsObject



130
131
132
133
# File 'lib/ambient.rb', line 130

def process_development_teams
  puts "applying ambient development teams"
  project_helper.process_development_teams(@development_teams)
end

#process_project_optionsObject



105
106
107
108
# File 'lib/ambient.rb', line 105

def process_project_options
  puts "applying ambient project settings"
  project_helper.process_project_options(@project_options)
end

#process_scheme_optionsObject



110
111
112
113
# File 'lib/ambient.rb', line 110

def process_scheme_options
  puts "applying ambient scheme settings"
  project_helper.process_scheme_options(@scheme_options)
end

#process_shared_target_optionsObject



115
116
117
118
# File 'lib/ambient.rb', line 115

def process_shared_target_options
  puts "applying ambient shared target settings"
  project_helper.process_shared_target_options(@shared_target_options)
end

#process_target_optionsObject



120
121
122
123
# File 'lib/ambient.rb', line 120

def process_target_options
  puts "applying ambient target settings"
  project_helper.process_target_options(@target_options)
end

#project_helperObject



31
32
33
# File 'lib/ambient.rb', line 31

def project_helper
  @project_helper ||= ProjectHelper.new
end

#reset_capabilites_to_defaultsObject



100
101
102
103
# File 'lib/ambient.rb', line 100

def reset_capabilites_to_defaults
  puts "resetting capabilities to xcode default settings"
  project_helper.reset_capabilities_to_defaults
end

#reset_project_to_defaultsObject



90
91
92
93
# File 'lib/ambient.rb', line 90

def reset_project_to_defaults
  puts "resetting project settings to xcode default settings"
  project_helper.reset_project_to_defaults
end

#reset_targets_to_defaultsObject



95
96
97
98
# File 'lib/ambient.rb', line 95

def reset_targets_to_defaults
  puts "resetting target settings to xcode default settings"
  project_helper.reset_targets_to_defaults
end

#run_ambientfile(filename) ⇒ Object



154
155
156
157
158
159
# File 'lib/ambient.rb', line 154

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

#set_capability(target_name, capability_name) ⇒ Object



65
66
67
68
# File 'lib/ambient.rb', line 65

def set_capability(target_name, capability_name)
  capabilities = @capabilities[target_name] ||= []
  capabilities << capability_name
end

#set_development_team(target_name, team_name) ⇒ Object



70
71
72
# File 'lib/ambient.rb', line 70

def set_development_team(target_name, team_name)
  @development_teams[target_name] = team_name
end

#set_option(option, value, target: nil, scheme: nil, parent: nil) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ambient.rb', line 41

def set_option(option, value, target: nil, scheme: nil, parent: nil)
  value = "YES" if value == true
  value = "NO" if value == false
  value = nil if value == :default

  if target
    if scheme
      @target_options[target] ||= {}
      @target_options[target][scheme] ||= {}
      @target_options[target][scheme][option] = value
    else
      @shared_target_options[target] ||= {}
      @shared_target_options[target][option] = value
    end
  else
    if scheme
      @scheme_options[scheme] ||= {}
      @scheme_options[scheme][option] = value
    else
      @project_options[option] = value
    end
  end
end

#set_parent_scheme(target: nil, child: nil, parent: nil) ⇒ Object



35
36
37
38
39
# File 'lib/ambient.rb', line 35

def set_parent_scheme(target: nil, child: nil, parent: nil)
  target = target || :all
  @parents[target] ||= {}
  @parents[target][child] = parent
end

#setup_project(ambientfile) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/ambient.rb', line 74

def setup_project(ambientfile)
  run_ambientfile(ambientfile)
  project_helper.print_info
  reset_project_to_defaults if @use_defaults
  reset_targets_to_defaults if @use_defaults
  reset_capabilites_to_defaults if @use_defaults
  load_in_parent_scheme_values
  process_project_options
  process_scheme_options
  process_shared_target_options
  process_target_options
  process_capabilities
  process_development_teams
  project_helper.save_changes
end