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
- #validate_options ⇒ Object
-
#validate_scheme(options) ⇒ Object
rubocop: enable Metrics/PerceivedComplexity.
-
#validate_xcodeproj_and_workspace(options) ⇒ Object
rubocop: disable Metrics/PerceivedComplexity.
Methods inherited from Configuration
#bridging_header_path, #bridging_header_required?, #helper, #initialize, #modules_enabled?, #open_podfile, #print_identification, #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
155 156 157 158 159 160 161 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 155 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 <<EOF <%= color('Xcode workspace:', BOLD) %> #{workspace_path || '(none)'} <%= color('Xcode project:', BOLD) %> #{xcodeproj_path || '(none)'} <%= color('Scheme:', BOLD) %> #{scheme || '(none)'} <%= color('Target:', BOLD) %> #{target || '(none)'} <%= color('Configuration:', BOLD) %> #{configuration} <%= color('SDK:', BOLD) %> #{sdk} <%= color('Podfile:', BOLD) %> #{podfile_path || '(none)'} <%= color('Cartfile:', BOLD) %> #{cartfile_path || '(none)'} <%= color('Pod repo update:', BOLD) %> #{pod_repo_update.inspect} <%= color('Clean:', BOLD) %> #{clean.inspect} <%= color('Report path:', BOLD) %> #{report_path} EOF 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 @configuration = .configuration @report_path = .out @sdk = .sdk @pod_repo_update = .pod_repo_update validate_xcodeproj_and_workspace validate_target validate_scheme # 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 |
# File 'lib/branch_io_cli/configuration/report_configuration.rb', line 133 def validate_scheme() schemes = all_schemes # TODO: Prompt if --scheme specified but not found. if .scheme && schemes.include?(.scheme) @scheme = .scheme elsif schemes.count == 1 @scheme = schemes.first elsif !schemes.empty? # By default, take a scheme with the same name as the target name. return if (@scheme = schemes.find { |s| s == target.name }) say "Please specify one of the following for the --scheme argument:" schemes.each do |scheme| say " #{scheme}" end exit 1 else say "No scheme defined in project." exit(-1) end 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 = .workspace end if .xcodeproj path = .xcodeproj @xcodeproj = Xcodeproj::Project.open .xcodeproj @xcodeproj_path = .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 = 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 = path return else say "Path must end with .xcworkspace or .xcodeproj" end rescue StandardError => e say e. end end end |