Class: BranchIOCLI::Configuration::ReportConfiguration
- Inherits:
-
Configuration
- Object
- Configuration
- BranchIOCLI::Configuration::ReportConfiguration
- Defined in:
- lib/branch_io_cli/configuration/report_configuration.rb
Instance Attribute Summary collapse
-
#clean ⇒ Object
readonly
Returns the value of attribute clean.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#header_only ⇒ Object
readonly
Returns the value of attribute header_only.
-
#report_path ⇒ Object
readonly
Returns the value of attribute report_path.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
-
#sdk ⇒ Object
readonly
Returns the value of attribute sdk.
Attributes inherited from Configuration
#cartfile_path, #options, #pod_repo_update, #podfile, #podfile_path, #sdk_integration_mode, #target, #workspace, #workspace_path, #xcodeproj, #xcodeproj_path
Instance Method Summary collapse
- #all_schemes ⇒ Object
- #log ⇒ Object
- #scheme_with_name(scheme_name) ⇒ Object
- #validate_configuration(options) ⇒ Object
- #validate_options ⇒ Object
-
#validate_scheme(options) ⇒ Object
rubocop: enable Metrics/PerceivedComplexity.
-
#validate_xcodeproj_and_workspace(options) ⇒ Object
rubocop: disable Metrics/PerceivedComplexity.
- #xcscheme ⇒ Object
Methods inherited from Configuration
#app_delegate_objc_path, #app_delegate_swift_path, #branch_imports, #branch_imports_from_file, #bridging_header_path, #bridging_header_required?, #helper, #initialize, #modules_enabled?, #open_podfile, #print_identification, #relative_path, #swift_version, #uses_frameworks?, #validate_buildfile_at_path, #validate_buildfile_path, #validate_target, #validate_xcodeproj_path
Constructor Details
This class inherits a constructor from BranchIOCLI::Configuration::Configuration
Instance Attribute Details
#clean ⇒ Object (readonly)
Returns the value of attribute clean.
4 5 6 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 4 def clean @clean end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
7 8 9 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 7 def configuration @configuration end |
#header_only ⇒ Object (readonly)
Returns the value of attribute header_only.
5 6 7 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 5 def header_only @header_only end |
#report_path ⇒ Object (readonly)
Returns the value of attribute report_path.
8 9 10 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 8 def report_path @report_path end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
6 7 8 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 6 def scheme @scheme end |
#sdk ⇒ Object (readonly)
Returns the value of attribute sdk.
9 10 11 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 9 def sdk @sdk end |
Instance Method Details
#all_schemes ⇒ Object
163 164 165 166 167 168 169 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 163 def all_schemes if workspace_path workspace.schemes.keys.reject { |scheme| scheme == "Pods" } else Xcodeproj::Project.schemes xcodeproj_path end end |
#log ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 36 def log super say "<%= color('Xcode workspace:', BOLD) %> \#{workspace_path || '(none)'}\n<%= color('Xcode project:', BOLD) %> \#{xcodeproj_path || '(none)'}\n<%= color('Scheme:', BOLD) %> \#{scheme || '(none)'}\n<%= color('Target:', BOLD) %> \#{target || '(none)'}\n<%= color('Configuration:', BOLD) %> \#{configuration}\n<%= color('SDK:', BOLD) %> \#{sdk}\n<%= color('Podfile:', BOLD) %> \#{relative_path(podfile_path) || '(none)'}\n<%= color('Cartfile:', BOLD) %> \#{relative_path(cartfile_path) || '(none)'}\n<%= color('Pod repo update:', BOLD) %> \#{pod_repo_update.inspect}\n<%= color('Clean:', BOLD) %> \#{clean.inspect}\n<%= color('Report path:', BOLD) %> \#{report_path}\n" end |
#scheme_with_name(scheme_name) ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 179 def scheme_with_name(scheme_name) if workspace_path project_path = workspace.schemes[@scheme] else project_path = xcodeproj_path end # Look for a shared scheme. xcshareddata_path = File.join project_path, "xcshareddata", "xcschemes", "#{@scheme}.xcscheme" scheme_path = xcshareddata_path if File.exist?(xcshareddata_path) unless scheme_path # Look for a local scheme user = @xcode_settings["USER"] if @xcode_settings user ||= ENV["USER"] || ENV["LOGNAME"] xcuserdata_path = File.join project_path, "xcuserdata", "#{user}.xcuserdatad", "xcschemes", "#{@scheme}.xcscheme" scheme_path = xcuserdata_path if File.exist?(xcuserdata_path) end return nil unless scheme_path Xcodeproj::XCScheme.new(scheme_path) end |
#validate_configuration(options) ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 203 def validate_configuration() all_configs = xcodeproj.build_configurations.map(&:name) if .configuration && all_configs.include?(.configuration) @configuration = .configuration elsif .configuration say "Configuration #{options.configuration} not found." @configuration = choose do || .header = "Configurations from project" all_configs.each { |c| .choice c } .prompt = "Please choose one of the above. " end end return if @configuration @configuration = "Debug" # Usual default for the launch action return unless xcscheme @configuration = xcscheme.launch_action.build_configuration end |
#validate_options ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 11 def @clean = .clean @header_only = .header_only @scheme = .scheme @target = .target @report_path = .out @sdk = .sdk @pod_repo_update = .pod_repo_update validate_xcodeproj_and_workspace validate_scheme validate_target validate_configuration # If neither --podfile nor --cartfile is present, arbitrarily look for a Podfile # first. # If --cartfile is present, don't look for a Podfile. Just validate that # Cartfile. validate_buildfile_path(.podfile, "Podfile") if .cartfile.nil? # If --podfile is present or a Podfile was found, don't look for a Cartfile. validate_buildfile_path(.cartfile, "Cartfile") if sdk_integration_mode.nil? end |
#validate_scheme(options) ⇒ Object
rubocop: enable Metrics/PerceivedComplexity
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 133 def validate_scheme() schemes = all_schemes if .scheme && schemes.include?(.scheme) @scheme = .scheme elsif schemes.count == 1 @scheme = schemes.first say "Scheme #{options.scheme} not found. Using #{@scheme}." if .scheme elsif !schemes.empty? # By default, take a scheme with the same name as the project name. return if !.scheme && (@scheme = schemes.find { |s| s == File.basename(xcodeproj_path, '.xcodeproj') }) @scheme = choose do || .header = "Schemes from project" schemes.each { |s| .choice s } .prompt = "Please choose one of the schemes above. " end else say "No scheme defined in project." exit(-1) end return if .target || xcscheme.nil? # Find the target used when running the scheme if the user didn't specify one. # This will be picked up in #validate_target entry = xcscheme.build_action.entries.select(&:build_for_running?).first .target = entry.buildable_references.first.target_name end |
#validate_xcodeproj_and_workspace(options) ⇒ Object
rubocop: disable Metrics/PerceivedComplexity
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 54 def validate_xcodeproj_and_workspace() # 1. What was passed in? begin if .workspace path = .workspace @workspace = Xcodeproj::Workspace.new_from_xcworkspace .workspace @workspace_path = File. .workspace end if .xcodeproj path = .xcodeproj @xcodeproj = Xcodeproj::Project.open .xcodeproj @xcodeproj_path = File. .xcodeproj else # Pass --workspace and --xcodeproj to override this inference. if workspace && workspace.file_references.count > 0 && workspace.file_references.first.path =~ /\.xcodeproj$/ @xcodeproj_path = File. "../#{@workspace.file_references.first.path}", workspace_path @xcodeproj = Xcodeproj::Project.open xcodeproj_path end end return if @workspace || @xcodeproj rescue StandardError => e say e. end # Try to find first a workspace, then a project all_workspace_paths = Dir[File.(File.join(".", "**/*.xcworkspace"))] .reject { |w| w =~ %r{/project.xcworkspace$} } .select do |p| valid = true Pathname.new(p).each_filename do |f| valid = false && break if f == "Carthage" || f == "Pods" end valid end if all_workspace_paths.count == 1 path = all_workspace_paths.first elsif all_workspace_paths.count == 0 all_xcodeproj_paths = Dir[File.(File.join(".", "**/*.xcodeproj"))] xcodeproj_paths = all_xcodeproj_paths.select do |p| valid = true Pathname.new(p).each_filename do |f| valid = false && break if f == "Carthage" || f == "Pods" end valid end path = xcodeproj_paths.first if xcodeproj_paths.count == 1 end # If more than one workspace. Don't try to find a project. Just prompt. loop do path = ask "Please enter a path to your Xcode project or workspace: " if path.nil? begin if path =~ /\.xcworkspace$/ @workspace = Xcodeproj::Workspace.new_from_xcworkspace path @workspace_path = File. path # Pass --workspace and --xcodeproj to override this inference. if workspace.file_references.count > 0 && workspace.file_references.first.path =~ /\.xcodeproj$/ @xcodeproj_path = File. "../#{workspace.file_references.first.path}", workspace_path @xcodeproj = Xcodeproj::Project.open xcodeproj_path end return elsif path =~ /\.xcodeproj$/ @xcodeproj = Xcodeproj::Project.open path @xcodeproj_path = File. path return else say "Path must end with .xcworkspace or .xcodeproj" end rescue StandardError => e say e. end end end |
#xcscheme ⇒ Object
171 172 173 174 175 176 177 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 171 def xcscheme return @xcscheme if @xcscheme_checked # This may not exist. If it comes back nil once, don't keep checking. @xcscheme_checked = true @xcscheme = scheme_with_name @scheme @xcscheme end |