snapshot 0.10.2 → 1.0.1

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.
@@ -10,9 +10,9 @@ module Snapshot
10
10
  def flatten(path)
11
11
  Dir.glob([path, '/**/*.png'].join('/')).each do |file|
12
12
  Helper.log.info "Removing alpha channel from '#{file}'" if $verbose
13
- `sips -s format bmp '#{file}' &> /dev/null ` # &> /dev/null because there is warning because of the extension
13
+ `sips -s format bmp '#{file}' &> /dev/null` # &> /dev/null because there is warning because of the extension
14
14
  `sips -s format png '#{file}'`
15
15
  end
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -22,19 +22,17 @@ module Snapshot
22
22
  command = "sips -r 180 '#{file}'"
23
23
  end
24
24
 
25
+ next unless command
26
+
25
27
  # Only rotate if we need to
26
- if command
27
- PTY.spawn( command ) do |r, w, pid|
28
- r.sync
29
- r.each do |line|
30
- # We need to read this otherwise things hang
31
- end
32
- ::Process.wait pid
28
+ PTY.spawn(command) do |r, w, pid|
29
+ r.sync
30
+ r.each do |line|
31
+ # We need to read this otherwise things hang
33
32
  end
33
+ ::Process.wait pid
34
34
  end
35
-
36
35
  end
37
36
  end
38
-
39
37
  end
40
38
  end
@@ -0,0 +1,33 @@
1
+ module Snapshot
2
+ class Setup
3
+ # This method will take care of creating a Snapfile and other necessary files
4
+ def self.create(path)
5
+ snapfile_path = File.join(path, 'Snapfile')
6
+
7
+ if File.exist?(snapfile_path)
8
+ raise "Snapfile already exists at path '#{snapfile_path}'. Run 'snapshot' to use snapshot.".red
9
+ end
10
+
11
+ gem_path = Helper.gem_path("snapshot")
12
+ File.write(snapfile_path, File.read("#{gem_path}/lib/assets/SnapfileTemplate"))
13
+ File.write(File.join(path, 'SnapshotHelper.swift'), File.read("#{gem_path}/lib/assets/SnapshotHelper.swift"))
14
+
15
+ puts "Successfully created SnapshotHelper.js '#{File.join(path, 'SnapshotHelper.swift')}'".green
16
+ puts "Successfully created new Snapfile at '#{snapfile_path}'".green
17
+
18
+ puts "-------------------------------------------------------".yellow
19
+ puts "Open your Xcode project and make sure to do the following:".yellow
20
+ puts "1) Add the ./SnapshotHelper.swift to your UI Test target".yellow
21
+ puts " You can move the file anywhere you want".yellow
22
+ puts "2) Call `setLanguage(app)` when launching your app".yellow
23
+ puts ""
24
+ puts " let app = XCUIApplication()"
25
+ puts " setLanguage(app)"
26
+ puts " app.launch()"
27
+ puts ""
28
+ puts "3) Add `snapshot(\"0Launch\")` to wherever you want to create the screenhsots".yellow
29
+ puts ""
30
+ puts "More information on GitHub: https://github.com/krausefx/snapshot".green
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,93 @@
1
+ module Snapshot
2
+ # Responsible for building the fully working xcodebuild command
3
+ class TestCommandGenerator
4
+ class << self
5
+ def generate(device_type: nil)
6
+ parts = prefix
7
+ parts << "xcodebuild"
8
+ parts += options
9
+ parts += destination(device_type)
10
+ parts += actions
11
+ parts += suffix
12
+ parts += pipe
13
+
14
+ parts
15
+ end
16
+
17
+ def prefix
18
+ ["set -o pipefail &&"]
19
+ end
20
+
21
+ # Path to the project or workspace as parameter
22
+ # This will also include the scheme (if given)
23
+ # @return [Array] The array with all the components to join
24
+ def project_path_array
25
+ proj = Snapshot.project.xcodebuild_parameters
26
+ return proj if proj.count > 0
27
+ raise "No project/workspace found"
28
+ end
29
+
30
+ def options
31
+ config = Snapshot.config
32
+
33
+ options = []
34
+ options += project_path_array
35
+ options << "-configuration '#{config[:configuration]}'" if config[:configuration]
36
+ options << "-sdk '#{config[:sdk]}'" if config[:sdk]
37
+ options << "-derivedDataPath '#{derived_data_path}'"
38
+ # options << "-xcconfig '#{config[:xcconfig]}'" if config[:xcconfig]
39
+ # options << "-archivePath '#{archive_path}'"
40
+ # options << config[:xcargs] if config[:xcargs]
41
+
42
+ options
43
+ end
44
+
45
+ def actions
46
+ actions = []
47
+ # actions << :clean if config[:clean]
48
+ actions << :test
49
+
50
+ actions
51
+ end
52
+
53
+ def suffix
54
+ []
55
+ end
56
+
57
+ def pipe
58
+ ["| tee '#{xcodebuild_log_path}' | xcpretty"]
59
+ end
60
+
61
+ def destination(device)
62
+ # we now fetch the device's udid. Why? Because we might get this error message
63
+ # > The requested device could not be found because multiple devices matched the request.
64
+ #
65
+ # This happens when you have multiple simulators for a given device type / iOS combination
66
+ # { platform:iOS Simulator, id:1685B071-AFB2-4DC1-BE29-8370BA4A6EBD, OS:9.0, name:iPhone 5 }
67
+ # { platform:iOS Simulator, id:A141F23B-96B3-491A-8949-813B376C28A7, OS:9.0, name:iPhone 5 }
68
+ #
69
+
70
+ device_udid = nil
71
+ FastlaneCore::Simulator.all.each do |sim|
72
+ device_udid = sim.udid if sim.name.strip == device.strip
73
+ end
74
+
75
+ value = "platform=iOS Simulator,id=#{device_udid},OS=#{Snapshot.config[:ios_version]}"
76
+
77
+ return ["-destination '#{value}'"]
78
+ end
79
+
80
+ def xcodebuild_log_path
81
+ file_name = "#{Snapshot.project.app_name}-#{Snapshot.config[:scheme]}.log"
82
+ containing = File.expand_path(Snapshot.config[:buildlog_path])
83
+ FileUtils.mkdir_p(containing)
84
+
85
+ return File.join(containing, file_name)
86
+ end
87
+
88
+ def derived_data_path
89
+ "/tmp/snapshot_derived/"
90
+ end
91
+ end
92
+ end
93
+ end
@@ -1,3 +1,4 @@
1
1
  module Snapshot
2
- VERSION = "0.10.2"
2
+ VERSION = "1.0.1"
3
+ DESCRIPTION = "Automate taking localized screenshots of your iOS app on every device"
3
4
  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.10.2
4
+ version: 1.0.1
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-10-17 00:00:00.000000000 Z
11
+ date: 2015-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastimage
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.16.1
33
+ version: 0.21.0
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
36
  version: 1.0.0
@@ -40,10 +40,38 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 0.16.1
43
+ version: 0.21.0
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: 1.0.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: xcpretty
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: plist
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 3.1.0
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 3.1.0
47
75
  - !ruby/object:Gem::Dependency
48
76
  name: bundler
49
77
  requirement: !ruby/object:Gem::Requirement
@@ -115,7 +143,7 @@ dependencies:
115
143
  - !ruby/object:Gem::Version
116
144
  version: 0.8.7.4
117
145
  - !ruby/object:Gem::Dependency
118
- name: codeclimate-test-reporter
146
+ name: coveralls
119
147
  requirement: !ruby/object:Gem::Requirement
120
148
  requirements:
121
149
  - - ">="
@@ -128,6 +156,48 @@ dependencies:
128
156
  - - ">="
129
157
  - !ruby/object:Gem::Version
130
158
  version: '0'
159
+ - !ruby/object:Gem::Dependency
160
+ name: fastlane
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ - !ruby/object:Gem::Dependency
174
+ name: rubocop
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '0.34'
180
+ type: :development
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - "~>"
185
+ - !ruby/object:Gem::Version
186
+ version: '0.34'
187
+ - !ruby/object:Gem::Dependency
188
+ name: webmock
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - "~>"
192
+ - !ruby/object:Gem::Version
193
+ version: 1.19.0
194
+ type: :development
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - "~>"
199
+ - !ruby/object:Gem::Version
200
+ version: 1.19.0
131
201
  description: Automate taking localized screenshots of your iOS app on every device
132
202
  email:
133
203
  - snapshot@krausefx.com
@@ -140,22 +210,22 @@ files:
140
210
  - README.md
141
211
  - bin/snapshot
142
212
  - lib/assets/SnapfileTemplate
143
- - lib/assets/SnapshotHelper.js
144
- - lib/assets/snapshot.js
213
+ - lib/assets/SnapshotHelper.swift
145
214
  - lib/snapshot.rb
146
- - lib/snapshot/builder.rb
215
+ - lib/snapshot/collector.rb
147
216
  - lib/snapshot/dependency_checker.rb
217
+ - lib/snapshot/detect_values.rb
218
+ - lib/snapshot/error_handler.rb
148
219
  - lib/snapshot/latest_ios_version.rb
220
+ - lib/snapshot/options.rb
149
221
  - lib/snapshot/page.html.erb
150
222
  - lib/snapshot/reports_generator.rb
151
223
  - lib/snapshot/reset_simulators.rb
152
224
  - lib/snapshot/runner.rb
153
225
  - lib/snapshot/screenshot_flatten.rb
154
226
  - lib/snapshot/screenshot_rotate.rb
155
- - lib/snapshot/simulators.rb
156
- - lib/snapshot/snapfile_creator.rb
157
- - lib/snapshot/snapshot_config.rb
158
- - lib/snapshot/snapshot_file.rb
227
+ - lib/snapshot/setup.rb
228
+ - lib/snapshot/test_command_generator.rb
159
229
  - lib/snapshot/version.rb
160
230
  homepage: https://fastlane.tools
161
231
  licenses:
@@ -177,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
247
  version: '0'
178
248
  requirements: []
179
249
  rubyforge_project:
180
- rubygems_version: 2.4.8
250
+ rubygems_version: 2.4.6
181
251
  signing_key:
182
252
  specification_version: 4
183
253
  summary: Automate taking localized screenshots of your iOS app on every device
@@ -1,63 +0,0 @@
1
- function wait_for_loading_indicator_to_be_finished()
2
- {
3
- try {
4
- re = UIATarget.localTarget().frontMostApp().statusBar().elements()[2].rect()
5
- re2 = UIATarget.localTarget().frontMostApp().statusBar().elements()[3].rect()
6
- while ((re['size']['width'] == 10 && re['size']['height'] == 20) ||
7
- (re2['size']['width'] == 10 && re2['size']['height'] == 20))
8
- {
9
- UIALogger.logMessage("Loading indicator is visible... waiting")
10
- UIATarget.localTarget().delay(1)
11
- re = UIATarget.localTarget().frontMostApp().statusBar().elements()[2].rect()
12
- re2 = UIATarget.localTarget().frontMostApp().statusBar().elements()[3].rect()
13
- }
14
- } catch (e) {}
15
- }
16
-
17
- function isTablet()
18
- {
19
- return !(UIATarget.localTarget().model().match(/iPhone/))
20
- }
21
-
22
- function captureLocalizedScreenshot(name) {
23
- wait_for_loading_indicator_to_be_finished();
24
-
25
- var target = UIATarget.localTarget();
26
- var model = target.model();
27
- var rect = target.rect();
28
- var deviceOrientation = target.deviceOrientation();
29
-
30
- var theSize = (rect.size.width > rect.size.height) ? rect.size.width.toFixed() : rect.size.height.toFixed();
31
-
32
- if (model.match(/iPhone/))
33
- {
34
- if (theSize > 667) {
35
- model = "iPhone6Plus";
36
- } else if (theSize == 667) {
37
- model = "iPhone6";
38
- } else if (theSize == 568){
39
- model = "iPhone5";
40
- } else {
41
- model = "iPhone4";
42
- }
43
- }
44
- else
45
- {
46
- model = "iPad";
47
- }
48
-
49
- var orientation = "portrait";
50
- if (deviceOrientation == UIA_DEVICE_ORIENTATION_LANDSCAPELEFT) {
51
- orientation = "landscapeleft";
52
- } else if (deviceOrientation == UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT) {
53
- orientation = "landscaperight";
54
- } else if (deviceOrientation == UIA_DEVICE_ORIENTATION_PORTRAIT_UPSIDEDOWN) {
55
- orientation = "portrait_upsidedown";
56
- }
57
-
58
- var result = target.host().performTaskWithPathArgumentsTimeout("/usr/bin/printenv" , ["SNAPSHOT_LANGUAGE"], 5);
59
- var language = result.stdout.substring(0, result.stdout.length - 1);
60
-
61
- var parts = [language, model, name, orientation];
62
- target.captureScreenWithName(parts.join("-"));
63
- }
@@ -1,9 +0,0 @@
1
- #import "SnapshotHelper.js"
2
-
3
- var target = UIATarget.localTarget();
4
- var app = target.frontMostApp();
5
- var window = app.mainWindow();
6
-
7
-
8
- target.delay(3)
9
- captureLocalizedScreenshot("0-LandingScreen")
@@ -1,85 +0,0 @@
1
- module Snapshot
2
- class Builder
3
-
4
- def initialize
5
- @build_dir = SnapshotConfig.shared_instance.build_dir || '/tmp/snapshot'
6
- end
7
-
8
- def build_app(clean: true)
9
- FileUtils.rm_rf(@build_dir) if clean
10
-
11
- command = SnapshotConfig.shared_instance.build_command
12
-
13
- if not command
14
- # That's the default case, user did not provide a custom build_command
15
- raise "Could not find project. Please pass the path to your project using 'project_path'.".red unless SnapshotConfig.shared_instance.project_path
16
- command = generate_build_command(clean: clean)
17
- end
18
-
19
- Helper.log.info "Building project '#{SnapshotConfig.shared_instance.project_name}' - this might take some time...".green
20
- Helper.log.debug command.yellow
21
-
22
- all_lines = []
23
-
24
- PTY.spawn(command) do |stdin, stdout, pid|
25
- stdin.each do |line|
26
- all_lines << line
27
- begin
28
- parse_build_line(line) if line.length > 2
29
- rescue => ex
30
- Helper.log.fatal all_lines.join("\n")
31
- raise ex
32
- end
33
- end
34
- Process.wait(pid)
35
- end
36
- # Exit status for build command, should be 0 if build succeeded
37
- cmdstatus = $?.exitstatus
38
-
39
- if cmdstatus == 0 || all_lines.join('\n').include?('** BUILD SUCCEEDED **')
40
- Helper.log.info "BUILD SUCCEEDED".green
41
- return true
42
- else
43
- Helper.log.info(all_lines.join(' '))
44
- raise "Looks like the build was not successful."
45
- end
46
- end
47
-
48
- private
49
- def parse_build_line(line)
50
- if line.include?"** BUILD FAILED **"
51
- raise line
52
- end
53
- end
54
-
55
- def generate_build_command(clean: true)
56
- scheme = SnapshotConfig.shared_instance.scheme
57
-
58
- proj_path = SnapshotConfig.shared_instance.project_path
59
- proj_key = 'project'
60
- proj_key = 'workspace' if proj_path.end_with?'.xcworkspace'
61
-
62
- pre_command = SnapshotConfig.shared_instance.custom_args || ENV["SNAPSHOT_CUSTOM_ARGS"] || ''
63
- custom_build_args = SnapshotConfig.shared_instance.custom_build_args || ENV["SNAPSHOT_CUSTOM_BUILD_ARGS"] || ''
64
-
65
- build_command = pre_command + ' ' + (DependencyChecker.xctool_installed? ? 'xctool' : 'xcodebuild')
66
-
67
- actions = []
68
- actions << 'clean' if clean
69
- actions << "build"
70
-
71
- [
72
- build_command,
73
- "-sdk iphonesimulator",
74
- "CONFIGURATION_BUILD_DIR='#{@build_dir}/build'",
75
- "-#{proj_key} '#{proj_path}'",
76
- "-scheme '#{scheme}'",
77
- "DSTROOT='#{@build_dir}'",
78
- "OBJROOT='#{@build_dir}'",
79
- "SYMROOT='#{@build_dir}'",
80
- custom_build_args,
81
- actions.join(' ')
82
- ].join(' ')
83
- end
84
- end
85
- end