snapshot 1.9.0 → 1.10.0

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: 240336d6be66f93dcf5fb8f86d0b22c02b8cf430
4
- data.tar.gz: c3474a9d370b0d30621dadb856aed9aea93db090
3
+ metadata.gz: 1f423c7b8038df57343f37a6d205c3d7df858612
4
+ data.tar.gz: 10ff5a81421f1a3bad034c590297c812e69e7277
5
5
  SHA512:
6
- metadata.gz: c08cc643de417f35674cc2ebf621afb8df57454556b0f0346e8895b8743347a16b31df40a0448f3682eb9f7fc82d705213346f0f352b6bd7605f11ff92851446
7
- data.tar.gz: a4c00fc15adb4707dad1bcca1e1f6cab5a5f63f8be2ff82286e1ad37cb7388fd0a0f5974c3756be77bc37c945ee160a7da2dc684a77c83d02dbf31e396e0d74c
6
+ metadata.gz: 7cc9ad37a6ff4e4fdf627866821784474fc471f2bfb8769805aee42d8540fe892aa71b0d690052a535631dd87b1d7e8554a5aebb95a9a931ed49d109da8f681a
7
+ data.tar.gz: 1c436151af68dfe77df868b95460ad6ad35c27821100a440aea6c72ffceb520e2502676b61a54f509dfa25f91accf5c4625989f97a424e398e2fef6aae1c180a
data/README.md CHANGED
@@ -286,7 +286,7 @@ to update your `SnapshotHelper.swift` files. In case you modified your `Snapshot
286
286
 
287
287
  ## Launch Arguments
288
288
 
289
- You can provide additional arguments to your app on launch. These strings will be available in your code through `NSProcessInfo.processInfo().arguments`. Alternatively use user-default syntax (`-key value`) and they will be available as key-value pairs in `NSUserDefaults.standardUserDefaults()`.
289
+ You can provide additional arguments to your app on launch. These strings will be available in your app (eg. not in the testing target) through `NSProcessInfo.processInfo().arguments`. Alternatively use user-default syntax (`-key value`) and they will be available as key-value pairs in `NSUserDefaults.standardUserDefaults()`.
290
290
 
291
291
  `snapshot` includes `-FASTLANE_SNAPSHOT YES`, which will set a temporary user default for the key `FASTLANE_SNAPSHOT`, you may use this to detect when the app is run by `snapshot`.
292
292
 
data/bin/snapshot CHANGED
@@ -65,8 +65,8 @@ class SnapshotApplication
65
65
  c.option '-i', '--ios String', String, 'The comma separated list of iOS Versions you want to use'
66
66
 
67
67
  c.action do |args, options|
68
- versions = [Snapshot::LatestIosVersion.version]
69
- versions = options.ios.split(',') if options.ios
68
+ options.default ios_version: Snapshot::LatestIosVersion.version
69
+ versions = options.ios_version.split(',') if options.ios_version
70
70
  require 'snapshot/reset_simulators'
71
71
 
72
72
  Snapshot::ResetSimulators.clear_everything!(versions)
@@ -34,10 +34,15 @@ class Snapshot: NSObject {
34
34
  }
35
35
 
36
36
  class func setLanguage(app: XCUIApplication) {
37
- let path = "/tmp/language.txt"
37
+ guard let prefix = pathPrefix() else {
38
+ return
39
+ }
40
+
41
+ let path = prefix.stringByAppendingPathComponent("language.txt")
38
42
 
39
43
  do {
40
- deviceLanguage = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String
44
+ let trimCharacterSet = NSCharacterSet.whitespaceAndNewlineCharacterSet()
45
+ deviceLanguage = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding).stringByTrimmingCharactersInSet(trimCharacterSet) as String
41
46
  app.launchArguments += ["-AppleLanguages", "(\(deviceLanguage))"]
42
47
  } catch {
43
48
  print("Couldn't detect/set language...")
@@ -45,10 +50,15 @@ class Snapshot: NSObject {
45
50
  }
46
51
 
47
52
  class func setLocale(app: XCUIApplication) {
48
- let path = "tmp/locale.txt"
53
+ guard let prefix = pathPrefix() else {
54
+ return
55
+ }
56
+
57
+ let path = prefix.stringByAppendingPathComponent("locale.txt")
49
58
 
50
59
  do {
51
- locale = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String
60
+ let trimCharacterSet = NSCharacterSet.whitespaceAndNewlineCharacterSet()
61
+ locale = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding).stringByTrimmingCharactersInSet(trimCharacterSet) as String
52
62
  } catch {
53
63
  print("Couldn't detect/set locale...")
54
64
  }
@@ -59,8 +69,11 @@ class Snapshot: NSObject {
59
69
  }
60
70
 
61
71
  class func setLaunchArguments(app: XCUIApplication) {
62
- let path = "/tmp/snapshot-launch_arguments.txt"
72
+ guard let prefix = pathPrefix() else {
73
+ return
74
+ }
63
75
 
76
+ let path = prefix.stringByAppendingPathComponent("snapshot-launch_arguments.txt")
64
77
  app.launchArguments += ["-FASTLANE_SNAPSHOT", "YES", "-ui_testing"]
65
78
 
66
79
  do {
@@ -95,6 +108,14 @@ class Snapshot: NSObject {
95
108
  print("Waiting for loading indicator to disappear...")
96
109
  }
97
110
  }
111
+
112
+ class func pathPrefix() -> NSString? {
113
+ if let path = NSProcessInfo().environment["SIMULATOR_HOST_HOME"] as NSString? {
114
+ return path.stringByAppendingPathComponent("Library/Caches/tools.fastlane")
115
+ }
116
+ print("Couldn't find Snapshot configuration files at ~/Library/Caches/tools.fastlane")
117
+ return nil
118
+ }
98
119
  }
99
120
 
100
121
  extension XCUIElement {
@@ -105,4 +126,4 @@ extension XCUIElement {
105
126
 
106
127
  // Please don't remove the lines below
107
128
  // They are used to detect outdated configuration files
108
- // SnapshotHelperVersion [1.1]
129
+ // SnapshotHelperVersion [1.2]
@@ -6,7 +6,7 @@ module Snapshot
6
6
  def self.available_options
7
7
  output_directory = (File.directory?("fastlane") ? "fastlane/screenshots" : "screenshots")
8
8
 
9
- @@options ||= [
9
+ @options ||= [
10
10
  FastlaneCore::ConfigItem.new(key: :workspace,
11
11
  short_option: "-w",
12
12
  env_name: "SNAPSHOT_WORKSPACE",
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>KrauseFx/snapshot</title>
4
+ <title>fastlane/snapshot</title>
5
5
  <meta charset="UTF-8">
6
6
  <style type="text/css">
7
7
  * {
@@ -115,9 +115,11 @@ module Snapshot
115
115
  FileUtils.rm_rf(screenshots_path) if Snapshot.config[:clean]
116
116
  FileUtils.mkdir_p(screenshots_path)
117
117
 
118
- File.write("/tmp/language.txt", language)
119
- File.write("/tmp/locale.txt", locale || "")
120
- File.write("/tmp/snapshot-launch_arguments.txt", launch_arguments.last)
118
+ prefix = File.join(Dir.home, "Library/Caches/tools.fastlane")
119
+ FileUtils.mkdir_p(prefix)
120
+ File.write(File.join(prefix, "language.txt"), language)
121
+ File.write(File.join(prefix, "locale.txt"), locale || "")
122
+ File.write(File.join(prefix, "snapshot-launch_arguments.txt"), launch_arguments.last)
121
123
 
122
124
  Fixes::SimulatorZoomFix.patch
123
125
  Fixes::HardwareKeyboardFix.patch
@@ -220,13 +222,25 @@ module Snapshot
220
222
  end
221
223
  end
222
224
 
225
+ def version_of_bundled_helper
226
+ runner_dir = File.dirname(__FILE__)
227
+ bundled_helper = File.read File.expand_path('../assets/SnapshotHelper.swift', runner_dir)
228
+ current_version = bundled_helper.match(/\n.*SnapshotHelperVersion \[.+\]/)[0]
229
+
230
+ ## Something like "// SnapshotHelperVersion [1.2]", but be relaxed about whitespace
231
+ current_version.gsub(%r{^//\w*}, '').strip
232
+ end
233
+
223
234
  # rubocop:disable Style/Next
224
235
  def verify_helper_is_current
236
+ current_version = version_of_bundled_helper
237
+ UI.verbose "Checking that helper files contain #{current_version}"
238
+
225
239
  helper_files = Update.find_helper
226
240
  helper_files.each do |path|
227
241
  content = File.read(path)
228
242
 
229
- unless content.include?("SnapshotHelperVersion [1.1]")
243
+ unless content.include?(current_version)
230
244
  UI.error "Your '#{path}' is outdated, please run `snapshot update`"
231
245
  UI.error "to update your Helper file"
232
246
  UI.user_error!("Please update your Snapshot Helper file")
@@ -88,7 +88,7 @@ module Snapshot
88
88
  end
89
89
 
90
90
  def derived_data_path
91
- "/tmp/snapshot_derived/"
91
+ Snapshot.cache[:derived_data_path] ||= Dir.mktmpdir("snapshot_derived")
92
92
  end
93
93
  end
94
94
  end
@@ -1,4 +1,4 @@
1
1
  module Snapshot
2
- VERSION = "1.9.0"
2
+ VERSION = "1.10.0"
3
3
  DESCRIPTION = "Automate taking localized screenshots of your iOS app on every device"
4
4
  end
data/lib/snapshot.rb CHANGED
@@ -25,9 +25,12 @@ module Snapshot
25
25
 
26
26
  attr_accessor :project
27
27
 
28
+ attr_accessor :cache
29
+
28
30
  def config=(value)
29
31
  @config = value
30
32
  DetectValues.set_additional_default_values
33
+ @cache = {}
31
34
  end
32
35
 
33
36
  def snapfile_name
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: 1.9.0
4
+ version: 1.10.0
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-22 00:00:00.000000000 Z
11
+ date: 2016-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastimage