fastlane_core 0.36.8 → 0.36.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3df20c29b3701692f89ad3418ab3f9933735b81a
4
- data.tar.gz: bdbe065e873eaade6db30af2d0654c0b5278a204
3
+ metadata.gz: eb03c52b6d68f1d13b5470c5921b9dbe50b88053
4
+ data.tar.gz: 85e09706d35029e07617b279fb6bc8b724fd98c9
5
5
  SHA512:
6
- metadata.gz: f689d3b9a0dc4fcf942cfc12da2ba686f4625da8a4126f8b51908ffd6532cb649db0860def61aea1ccb5e2892a3e2ca4df30f91bf1b79e5d5ad12f079f3a3490
7
- data.tar.gz: d1119e07d5bc52350311171a015c02e2df4ca36ff261f32dca289e951336029800a6f1452bec3893c0ceb4d68aa6f3925a78f827b5e647964a7c6984e6b7253e
6
+ metadata.gz: 93150dbe3b09b674fc298418aed928a461e1ed5b3328d3e1c5a1d9b41396970399419961c4adebfebc13ff579c813f651a3de616e43d0fb8140ce2daea096bb7
7
+ data.tar.gz: 78dfc200e172ba6ade3ce3eed598e503aac40ec6eaeafebbb23b158224e1bf30fa3f10595e00e8b6147a1d77782b0fd1185dd8fcf997d551d8140a873a45dea4
@@ -91,7 +91,7 @@ module FastlaneCore
91
91
  return value.to_f
92
92
  else
93
93
  # Special treatment if the user specififed true, false or YES, NO
94
- # There is no boolean typoe, so we just do it here
94
+ # There is no boolean type, so we just do it here
95
95
  if %w(YES yes true TRUE).include?(value)
96
96
  return true
97
97
  elsif %w(NO no false FALSE).include?(value)
@@ -182,6 +182,9 @@ module FastlaneCore
182
182
  return value unless value.nil? # we already have a value
183
183
  return value if option.optional # as this value is not required, just return what we have
184
184
 
185
+ return value unless ask
186
+
187
+ # fallback to asking
185
188
  if Helper.is_test? or Helper.is_ci?
186
189
  # Since we don't want to be asked on tests, we'll just call the verify block with no value
187
190
  # to raise the exception that is shown when the user passes an invalid value
@@ -190,7 +193,7 @@ module FastlaneCore
190
193
  UI.user_error!("No value found for '#{key}'")
191
194
  end
192
195
 
193
- while ask && value.nil?
196
+ while value.nil?
194
197
  Helper.log.info "To not be asked about this value, you can specify it using '#{option.key}'".yellow
195
198
  value = ask("#{option.description}: ")
196
199
  # Also store this value to use it from now on
@@ -221,10 +224,11 @@ module FastlaneCore
221
224
  true
222
225
  end
223
226
 
224
- def values
227
+ # see fetch
228
+ def values(ask: true)
225
229
  # As the user accesses all values, we need to iterate through them to receive all the values
226
230
  @available_options.each do |option|
227
- @values[option.key] = fetch(option.key) unless @values[option.key]
231
+ @values[option.key] = fetch(option.key, ask: ask) unless @values[option.key]
228
232
  end
229
233
  @values
230
234
  end
@@ -32,10 +32,13 @@ module FastlaneCore
32
32
  def method_missing(method_sym, *arguments, &block)
33
33
  # First, check if the key is actually available
34
34
  if self.config.all_keys.include? method_sym
35
- value = arguments.first || (block.call if block_given?) # this is either a block or a value
36
- if value
37
- self.config[method_sym] = value if self.config._values[method_sym].to_s.length == 0
38
- end
35
+ # This silently prevents a value from having its value set more than once.
36
+ return unless self.config._values[method_sym].to_s.empty?
37
+
38
+ value = arguments.first
39
+ value = block.call if value.nil? && block_given?
40
+
41
+ self.config[method_sym] = value unless value.nil?
39
42
  else
40
43
  # We can't set this value, maybe the tool using this configuration system has its own
41
44
  # way of handling this block, as this might be a special block (e.g. ipa block) that's only
@@ -2,22 +2,16 @@ module FastlaneCore
2
2
  class PrintTable
3
3
  class << self
4
4
  # This method prints out all the user inputs in a nice table. Useful to summarize the run
5
- # You can pass an array to `hide_key` if you don't want certain elements to show up (symbols)
6
- def print_values(config: nil, title: nil, hide_keys: [])
5
+ # You can pass an array to `hide_keys` if you don't want certain elements to show up (symbols or strings)
6
+ # You can pass an array to `mask_keys` if you want to mask certain elements (symbols or strings)
7
+ def print_values(config: nil, title: nil, hide_keys: [], mask_keys: [])
7
8
  require 'terminal-table'
8
- rows = []
9
9
 
10
- config.available_options.each do |config_item|
11
- value = config.fetch(config_item.key, ask: false) # Don't ask the user for missing values at this point
12
- next if value.nil?
13
- next if value.to_s == ""
14
- next if hide_keys.include?(config_item.key)
15
-
16
- rows << [config_item.key, value]
17
- end
10
+ options = config.nil? ? {} : config.values(ask: false)
11
+ rows = self.collect_rows(options: options, hide_keys: hide_keys.map(&:to_s), mask_keys: mask_keys.map(&:to_s), prefix: '')
18
12
 
19
13
  params = {}
20
- params[:rows] = rows
14
+ params[:rows] = limit_row_size(rows)
21
15
  params[:title] = title.green if title
22
16
 
23
17
  puts ""
@@ -26,6 +20,37 @@ module FastlaneCore
26
20
 
27
21
  return params
28
22
  end
23
+
24
+ def limit_row_size(rows, max_length = 100)
25
+ require 'fastlane_core/string_filters'
26
+
27
+ max_key_length = rows.map { |e| e[0].length }.max || 0
28
+ max_allowed_value_length = max_length - max_key_length - 7
29
+ rows.map do |e|
30
+ value = e[1]
31
+ value = value.truncate(max_allowed_value_length) if value.kind_of? String
32
+ [e[0], value]
33
+ end
34
+ end
35
+
36
+ def collect_rows(options: nil, hide_keys: [], mask_keys: [], prefix: '', mask: '********')
37
+ rows = []
38
+
39
+ options.each do |key, value|
40
+ prefixed_key = "#{prefix}#{key}"
41
+ next if value.nil?
42
+ next if value.to_s == ""
43
+ next if hide_keys.include?(prefixed_key)
44
+ value = mask if mask_keys.include?(prefixed_key)
45
+
46
+ if value.respond_to? :key
47
+ rows.concat self.collect_rows(options: value, hide_keys: hide_keys, mask_keys: mask_keys, prefix: "#{prefix}#{key}.", mask: mask)
48
+ else
49
+ rows << [prefixed_key, value]
50
+ end
51
+ end
52
+ rows
53
+ end
29
54
  end
30
55
  end
31
56
  end
@@ -80,6 +80,14 @@ module FastlaneCore
80
80
  self.is_workspace
81
81
  end
82
82
 
83
+ def project_name
84
+ if is_workspace
85
+ return File.basename(options[:workspace], ".xcworkspace")
86
+ else
87
+ return File.basename(options[:project], ".xcodeproj")
88
+ end
89
+ end
90
+
83
91
  # Get all available schemes in an array
84
92
  def schemes
85
93
  parsed_info.schemes
@@ -109,15 +117,16 @@ module FastlaneCore
109
117
 
110
118
  if preferred_to_include and preferred.count == 1
111
119
  options[:scheme] = preferred.last
120
+ elsif automated_scheme_selection? && schemes.include?(project_name)
121
+ Helper.log.info "Using scheme matching project name (#{project_name}).".yellow
122
+ options[:scheme] = project_name
123
+ elsif Helper.is_ci?
124
+ Helper.log.error "Multiple schemes found but you haven't specified one.".red
125
+ Helper.log.error "Since this is a CI, please pass one using the `scheme` option".red
126
+ raise "Multiple schemes found".red
112
127
  else
113
- if Helper.is_ci?
114
- Helper.log.error "Multiple schemes found but you haven't specified one.".red
115
- Helper.log.error "Since this is a CI, please pass one using the `scheme` option".red
116
- raise "Multiple schemes found".red
117
- else
118
- puts "Select Scheme: "
119
- options[:scheme] = choose(*(schemes))
120
- end
128
+ puts "Select Scheme: "
129
+ options[:scheme] = choose(*(schemes))
121
130
  end
122
131
  else
123
132
  Helper.log.error "Couldn't find any schemes in this project, make sure that the scheme is shared if you are using a workspace".red
@@ -290,5 +299,11 @@ module FastlaneCore
290
299
  end
291
300
  @parsed_info
292
301
  end
302
+
303
+ # If scheme not specified, do we want the scheme
304
+ # matching project name?
305
+ def automated_scheme_selection?
306
+ !!ENV["AUTOMATED_SCHEME_SELECTION"]
307
+ end
293
308
  end
294
309
  end
@@ -30,9 +30,9 @@ module FastlaneCore
30
30
  else
31
31
  # iPad 2 (0EDE6AFC-3767-425A-9658-AAA30A60F212) (Shutdown)
32
32
  # iPad Air 2 (4F3B8059-03FD-4D72-99C0-6E9BBEE2A9CE) (Shutdown) (unavailable, device type profile not found)
33
- match = line.match(/\s+([^\(]+) \(([-0-9A-F]+)\) \((?:[^\(]+)\)(.*unavailable.*)?/)
34
- if match && !match[3] && os_type == requested_os_type
35
- @devices << Device.new(name: match[1], ios_version: os_version, udid: match[2])
33
+ match = line.match(/\s+([^\(]+) \(([-0-9A-F]+)\) \(([^\(]+)\)(.*unavailable.*)?/)
34
+ if match && !match[4] && os_type == requested_os_type
35
+ @devices << Device.new(name: match[1], os_version: os_version, udid: match[2], state: match[3])
36
36
  end
37
37
  end
38
38
  end
@@ -44,6 +44,18 @@ module FastlaneCore
44
44
  @devices = nil
45
45
  end
46
46
 
47
+ # Reset all simulators of this type
48
+ def reset_all
49
+ all.each(&:reset)
50
+ end
51
+
52
+ # Reset simulator by UDID or name and OS version
53
+ # Latter is useful when combined with -destination option of xcodebuild
54
+ def reset(udid: nil, name: nil, os_version: nil)
55
+ match = all.detect { |device| device.udid == udid || device.name == name && device.os_version == os_version }
56
+ match.reset if match
57
+ end
58
+
47
59
  # The code below works from Xcode 7 on
48
60
  # def all
49
61
  # Helper.log.info "Fetching available devices" if $verbose
@@ -68,7 +80,7 @@ module FastlaneCore
68
80
  # next unless os_version.include?(requested_os_type)
69
81
 
70
82
  # os = os_version.gsub(requested_os_type + " ", "").strip
71
- # @devices << Device.new(name: device['name'], ios_version: os, udid: device['udid'])
83
+ # @devices << Device.new(name: device['name'], os_version: os, udid: device['udid'])
72
84
  # end
73
85
  # end
74
86
 
@@ -88,20 +100,29 @@ module FastlaneCore
88
100
 
89
101
  class Device
90
102
  attr_accessor :name
91
-
92
103
  attr_accessor :udid
104
+ attr_accessor :os_version
105
+ attr_accessor :ios_version # Preserved for backwards compatibility
106
+ attr_accessor :state
93
107
 
94
- attr_accessor :ios_version
95
-
96
- def initialize(name: nil, udid: nil, ios_version: nil)
108
+ def initialize(name: nil, udid: nil, os_version: nil, state: nil)
97
109
  self.name = name
98
110
  self.udid = udid
99
- self.ios_version = ios_version
111
+ self.os_version = os_version
112
+ self.ios_version = os_version
113
+ self.state = state
100
114
  end
101
115
 
102
116
  def to_s
103
117
  self.name
104
118
  end
119
+
120
+ def reset
121
+ Helper.log.info "Resetting #{self}"
122
+ `xcrun simctl shutdown #{self.udid}` if self.state == "Booted"
123
+ `xcrun simctl erase #{self.udid}`
124
+ return
125
+ end
105
126
  end
106
127
  end
107
128
 
@@ -112,4 +133,12 @@ module FastlaneCore
112
133
  end
113
134
  end
114
135
  end
136
+
137
+ class SimulatorWatch < Simulator
138
+ class << self
139
+ def requested_os_type
140
+ 'watchOS'
141
+ end
142
+ end
143
+ end
115
144
  end
@@ -0,0 +1,34 @@
1
+ class String
2
+ # Truncates a given +text+ after a given <tt>length</tt> if +text+ is longer than <tt>length</tt>:
3
+ #
4
+ # 'Once upon a time in a world far far away'.truncate(27)
5
+ # # => "Once upon a time in a wo..."
6
+ #
7
+ # Pass a string or regexp <tt>:separator</tt> to truncate +text+ at a natural break:
8
+ #
9
+ # 'Once upon a time in a world far far away'.truncate(27, separator: ' ')
10
+ # # => "Once upon a time in a..."
11
+ #
12
+ # 'Once upon a time in a world far far away'.truncate(27, separator: /\s/)
13
+ # # => "Once upon a time in a..."
14
+ #
15
+ # The last characters will be replaced with the <tt>:omission</tt> string (defaults to "...")
16
+ # for a total length not exceeding <tt>length</tt>:
17
+ #
18
+ # 'And they found that many people were sleeping better.'.truncate(25, omission: '... (continued)')
19
+ # # => "And they f... (continued)"
20
+ def truncate(truncate_at, options = {})
21
+ return dup unless length > truncate_at
22
+
23
+ omission = options[:omission] || '...'
24
+ length_with_room_for_omission = truncate_at - omission.length
25
+ stop = \
26
+ if options[:separator]
27
+ rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission
28
+ else
29
+ length_with_room_for_omission
30
+ end
31
+
32
+ "#{self[0, stop]}#{omission}"
33
+ end
34
+ end
@@ -1,3 +1,3 @@
1
1
  module FastlaneCore
2
- VERSION = "0.36.8".freeze
2
+ VERSION = "0.36.9".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.36.8
4
+ version: 0.36.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-25 00:00:00.000000000 Z
11
+ date: 2016-02-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -355,6 +355,7 @@ files:
355
355
  - lib/fastlane_core/project.rb
356
356
  - lib/fastlane_core/provisioning_profile.rb
357
357
  - lib/fastlane_core/simulator.rb
358
+ - lib/fastlane_core/string_filters.rb
358
359
  - lib/fastlane_core/ui/disable_colors.rb
359
360
  - lib/fastlane_core/ui/fastlane_runner.rb
360
361
  - lib/fastlane_core/ui/implementations/shell.rb
@@ -384,7 +385,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
384
385
  version: '0'
385
386
  requirements: []
386
387
  rubyforge_project:
387
- rubygems_version: 2.4.6
388
+ rubygems_version: 2.4.5.1
388
389
  signing_key:
389
390
  specification_version: 4
390
391
  summary: Contains all shared code/dependencies of the fastlane.tools