snapshot 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e9a3bdd92f26c6fb438e58ac38b9e3dacd4b55d
4
- data.tar.gz: 0f72ce53c3c5fbe8634ff5fc9d61d88c0929e8f8
3
+ metadata.gz: ca1d44f5d3981444263228bcb8c0528b97cede47
4
+ data.tar.gz: 2a84ee85f3a7c0dd2c1d7da5557857abe5ee869a
5
5
  SHA512:
6
- metadata.gz: 9bf6c703c5d25c7cb403c1b644ecf1e94949fac393d62d29b6478bb77e5c2fd5fe596c321f84fe93535dc49bcd37adf27677fd479f6d83fcb5e6247441687886
7
- data.tar.gz: c4d53cd5b1fe7ceb648f064a01e238866d38264bec7537a980cc00917cfaf7dadf4804c82cc5deaae8e98012756fc2caf5e0f0df58d2bac317a15a553db5e473
6
+ metadata.gz: f80391c3b5d104f8271c4cd90f03110cb4ee900d6edbe582ba9b061c83d744d13942ba9cda5c4853e4365275e16136f325f07db2665925eefcee8329cc297f92
7
+ data.tar.gz: 4a194d765aa44cfa75b3cca707dd65753e60e65874052cbc1e881acd558b8ad8b44edbdec69a5510dbb43675bc2fd683f3e69aabd23a3d5748a3365724e2d422
data/README.md CHANGED
@@ -197,6 +197,8 @@ to your test file.
197
197
  js_file './path/file.js'
198
198
  ```
199
199
 
200
+ You can add a custom script for iPads: `./path/file-iPad.js` and it will automatically be used if found. Just append the `-iPad` to your existing file.
201
+
200
202
  ### Scheme
201
203
  To not be asked which scheme to use, just set it like this:
202
204
  ```ruby
@@ -242,8 +244,11 @@ This can be used to
242
244
 
243
245
  To run a shell script, just use ```system('./script.sh')```.
244
246
  ```ruby
245
- setup_for_device_change do |device|
246
- puts "Preparing device: #{device}"
247
+ setup_for_device_change do |device, udid|
248
+ puts "Preparing device: #{device} with udid #{udid}"
249
+
250
+ # Completely reset the device before we start taking screenshots
251
+ system("xcrun simctl erase #{udid}")
247
252
  end
248
253
 
249
254
  setup_for_language_change do |lang, device|
@@ -41,7 +41,7 @@
41
41
  <% next if screen_path.include?"_framed.png" %>
42
42
  <td>
43
43
  <% path = screen_path.gsub("./screenshots/", "./") %>
44
- <% screen_size = FastImage.size(screen_path) %>
44
+ <% screen_size = FastImage.size(File.join('screenshots', screen_path)) %>
45
45
  <a href="<%= path %>" target="_blank">
46
46
  <img class="screenshot"
47
47
  src="<%= path %>",
@@ -9,17 +9,19 @@ module Snapshot
9
9
  @data = {}
10
10
 
11
11
  Dir["#{screens_path}/*"].sort.each do |language_path|
12
- language = language_path.split('/').last
13
- Dir[[language_path, '*'].join('/')].sort.each do |screenshot|
12
+ language = File.basename(language_path)
13
+ Dir[File.join(language_path, '*')].sort.each do |screenshot|
14
14
 
15
15
  available_devices.each do |key_name, output_name|
16
16
 
17
- if screenshot.split('/').last.include?key_name
17
+ if File.basename(screenshot).include?key_name
18
18
  # This screenshot it from this device
19
19
  @data[language] ||= {}
20
20
  @data[language][output_name] ||= []
21
- @data[language][output_name] << screenshot
22
- break # to not include iPhone 6 and 6 Plus
21
+
22
+ resulting_path = File.join('.', language, File.basename(screenshot))
23
+ @data[language][output_name] << resulting_path
24
+ break # to not include iPhone 6 and 6 Plus (name is contained in the other name)
23
25
  end
24
26
  end
25
27
  end
@@ -5,7 +5,7 @@ module Snapshot
5
5
  TRACE_DIR = '/tmp/snapshot_traces'
6
6
 
7
7
  def work(clean: true)
8
- SnapshotConfig.shared_instance.js_file # to verify the file can be found
8
+ SnapshotConfig.shared_instance.js_file # to verify the file can be found earlier
9
9
 
10
10
  Builder.new.build_app(clean: clean)
11
11
  @app_path = Dir.glob("/tmp/snapshot/build/*.app").first
@@ -15,7 +15,7 @@ module Snapshot
15
15
 
16
16
  SnapshotConfig.shared_instance.devices.each do |device|
17
17
 
18
- SnapshotConfig.shared_instance.blocks[:setup_for_device_change].call(device) # Callback
18
+ SnapshotConfig.shared_instance.blocks[:setup_for_device_change].call(device, udid_for_simulator(device)) # Callback
19
19
 
20
20
  SnapshotConfig.shared_instance.languages.each do |language|
21
21
  SnapshotConfig.shared_instance.blocks[:setup_for_language_change].call(language, device) # Callback
@@ -51,17 +51,21 @@ module Snapshot
51
51
  FileUtils.mkdir_p(TRACE_DIR)
52
52
  end
53
53
 
54
- def reinstall_app(device, language)
55
- def find_simulator(name) # fetches the UDID of the simulator type
56
- all = `instruments -s`.split("\n")
57
- all.each do |current|
58
- return current.match(/\[(.*)\]/)[1] if current.include?name
59
- end
60
- raise "Could not find simulator '#{name}' to install the app on."
54
+ def udid_for_simulator(name) # fetches the UDID of the simulator type
55
+ all = `instruments -s`.split("\n")
56
+ all.each do |current|
57
+ return current.match(/\[(.*)\]/)[1] if current.include?name
61
58
  end
59
+ raise "Could not find simulator '#{name}' to install the app on."
60
+ end
61
+
62
+ def reinstall_app(device, language)
62
63
 
63
64
  def app_identifier
64
- @app_identifier ||= (ENV["SNAPSHOT_APP_IDENTIFIER"] || `/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' /tmp/snapshot/build/*.app/*.plist`)
65
+ @app_identifier ||= ENV["SNAPSHOT_APP_IDENTIFIER"]
66
+ @app_identifier ||= `/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' /tmp/snapshot/build/*.app/Info.plist`
67
+ @app_identifier ||= `/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' /tmp/snapshot/build/*.app/*.plist`
68
+ @app_identifier.strip
65
69
  end
66
70
 
67
71
  def com(cmd)
@@ -70,13 +74,16 @@ module Snapshot
70
74
  puts result if result.to_s.length > 0
71
75
  end
72
76
 
73
- udid = find_simulator(device)
77
+ udid = udid_for_simulator(device)
78
+
79
+
74
80
  com("killall 'iOS Simulator'")
81
+ sleep 3
75
82
  com("xcrun simctl boot '#{udid}'")
76
- com("xcrun simctl uninstall '#{udid}' '#{app_identifier}'")
83
+ com("xcrun simctl uninstall booted '#{app_identifier}'")
77
84
  sleep 3
78
- com("xcrun simctl install '#{udid}' '#{@app_path}'")
79
- com("xcrun simctl shutdown '#{udid}'")
85
+ com("xcrun simctl install booted '#{@app_path}'")
86
+ com("xcrun simctl shutdown booted")
80
87
  end
81
88
 
82
89
  def run_tests(device, language)
@@ -169,7 +176,8 @@ module Snapshot
169
176
  end
170
177
 
171
178
  def generate_test_command(device, language)
172
- script_path = SnapshotConfig.shared_instance.js_file
179
+ is_ipad = (device.downcase.include?'ipad')
180
+ script_path = SnapshotConfig.shared_instance.js_file(is_ipad)
173
181
 
174
182
  [
175
183
  "instruments",
@@ -184,4 +192,4 @@ module Snapshot
184
192
  ].join(' ')
185
193
  end
186
194
  end
187
- end
195
+ end
@@ -10,10 +10,12 @@ module Snapshot
10
10
 
11
11
  File.write(snapfile_path, File.read("#{gem_path}/lib/assets/SnapfileTemplate"))
12
12
  File.write([path, 'snapshot.js'].join('/'), File.read("#{gem_path}/lib/assets/snapshot.js"))
13
+ File.write([path, 'snapshot-iPad.js'].join('/'), File.read("#{gem_path}/lib/assets/snapshot.js"))
13
14
  File.write([path, 'SnapshotHelper.js'].join('/'), File.read("#{gem_path}/lib/assets/SnapshotHelper.js"))
14
15
 
15
16
  puts "Successfully created SnapshotHelper.js '#{[path, 'SnapshotHelper.js'].join('/')}'".green
16
17
  puts "Successfully created new UI Automation JS file at '#{[path, 'snapshot.js'].join('/')}'".green
18
+ puts "Successfully created new UI Automation JS file for iPad at '#{[path, 'snapshot-iPad.js'].join('/')}'".green
17
19
  puts "Successfully created new Snapfile at '#{snapfile_path}'".green
18
20
  end
19
21
 
@@ -109,15 +109,28 @@ module Snapshot
109
109
  end
110
110
 
111
111
  # The JavaScript UIAutomation file
112
- def js_file
113
- return manual_js_file if manual_js_file
112
+ def js_file(ipad = false)
113
+ result = manual_js_file
114
114
 
115
- files = Dir.glob("./*.js").delete_if { |path| path.include?"SnapshotHelper.js" }
116
- if files.count == 1
117
- return files.first
118
- else
115
+ unless result
116
+ files = Dir.glob("./*.js").delete_if { |path| (path.include?"SnapshotHelper.js" or path.include?"iPad.js") }
117
+ if files.count == 1
118
+ result = files.first
119
+ end
120
+ end
121
+
122
+ if ipad
123
+ ipad_file = result.split('.js').join('/') + '-iPad.js'
124
+ if File.exists?(ipad_file)
125
+ result = ipad_file
126
+ end
127
+ end
128
+
129
+ unless File.exists?result
119
130
  raise "Could not determine which UIAutomation file to use. Please pass a path to your Javascript file using 'js_file'.".red
120
131
  end
132
+
133
+ return result
121
134
  end
122
135
 
123
136
  # The scheme to use (either it's set, or there is only one, or user has to enter it)
@@ -1,3 +1,3 @@
1
1
  module Snapshot
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snapshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-30 00:00:00.000000000 Z
11
+ date: 2015-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json