Class: HMap::Resolver
- Inherits:
-
Object
- Object
- HMap::Resolver
- Defined in:
- lib/hmap/xc/resolver.rb
Constant Summary collapse
- PODFILE_NAMES =
Returns The filenames that the Podfile can have ordered by priority.
[ 'CocoaPods.podfile.yaml', 'CocoaPods.podfile', 'Podfile', 'Podfile.rb' ].freeze
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#installation_root ⇒ Pathname
(also: #project_root)
The root of the workspace or project where is located.
-
#use_origin ⇒ Object
Returns the value of attribute use_origin.
Instance Method Summary collapse
- #project_build_settings(project_path) ⇒ Object
- #verbose? ⇒ Boolean
- #workspace_build_settings(workspace) ⇒ Object
-
#xcodebuild_list(workspace) ⇒ String
Executes xcodebuild list in the current working directory and returns its output (both STDOUT and STDERR).
-
#xcodebuild_project(project) ⇒ hash
Executes xcodebuild -project in the current working directory and returns its output (both STDOUT and STDERR).
-
#xcodebuild_workspace(workspace, scheme) ⇒ hash
Executes xcodebuild -workspace -scheme in the current working directory and returns its output (both STDOUT and STDERR).
Class Attribute Details
.instance ⇒ Object
19 20 21 |
# File 'lib/hmap/xc/resolver.rb', line 19 def self.instance @instance ||= new end |
Instance Attribute Details
#installation_root ⇒ Pathname Also known as: project_root
Returns the root of the workspace or project where is located.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/hmap/xc/resolver.rb', line 48 def installation_root @installation_root ||= begin current_dir = Pathname.new(Dir.pwd.unicode_normalize) current_path = current_dir until current_path.root? if podfile_path_in_dir(current_path) installation_root = current_path puts("[in #{current_path}]") unless current_path == current_dir break else current_path = current_path.parent end end installation_root || current_dir end end |
#use_origin ⇒ Object
Returns the value of attribute use_origin.
17 18 19 |
# File 'lib/hmap/xc/resolver.rb', line 17 def use_origin @use_origin end |
Instance Method Details
#project_build_settings(project_path) ⇒ Object
41 42 43 44 |
# File 'lib/hmap/xc/resolver.rb', line 41 def project_build_settings(project_path) targets = xcodebuild_project(project_path) || [] targets.first['buildSettings'] end |
#verbose? ⇒ Boolean
68 69 70 |
# File 'lib/hmap/xc/resolver.rb', line 68 def verbose? false end |
#workspace_build_settings(workspace) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/hmap/xc/resolver.rb', line 34 def workspace_build_settings(workspace) workspace_dic = xcodebuild_list(workspace)['workspace'] schemes = workspace_dic['schemes'] || [] targets = xcodebuild_workspace(workspace, schemes[0]) || [] targets.first['buildSettings'] end |
#xcodebuild_list(workspace) ⇒ String
Executes xcodebuild list in the current working directory and returns its output (both STDOUT and STDERR).
75 76 77 78 79 80 |
# File 'lib/hmap/xc/resolver.rb', line 75 def xcodebuild_list(workspace) command = %W[-workspace #{workspace}] command += %w[-json -list] results = Executable.execute_command('xcodebuild', command, false) JSON.parse(results) unless results.nil? end |
#xcodebuild_project(project) ⇒ hash
Executes xcodebuild -project in the current working directory and returns its output (both STDOUT and STDERR).
94 95 96 97 |
# File 'lib/hmap/xc/resolver.rb', line 94 def xcodebuild_project(project) command = %W[-project #{project}] xcodebuild(command) end |
#xcodebuild_workspace(workspace, scheme) ⇒ hash
Executes xcodebuild -workspace -scheme in the current working directory and returns its output (both STDOUT and STDERR).
85 86 87 88 89 |
# File 'lib/hmap/xc/resolver.rb', line 85 def xcodebuild_workspace(workspace, scheme) command = %W[-workspace #{workspace}] command += %W[-scheme #{scheme}] xcodebuild(command) end |