snapshot 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -16
- data/bin/snapshot +3 -2
- data/lib/assets/SnapfileTemplate +2 -6
- data/lib/snapshot/builder.rb +13 -6
- data/lib/snapshot/dependency_checker.rb +8 -0
- data/lib/snapshot/page.html.erb +3 -2
- data/lib/snapshot/reports_generator.rb +2 -3
- data/lib/snapshot/runner.rb +36 -6
- data/lib/snapshot/snapshot_config.rb +5 -8
- data/lib/snapshot/snapshot_file.rb +6 -9
- data/lib/snapshot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63d4849c32160441375a38343e1788f096de13b1
|
4
|
+
data.tar.gz: 3aeddc0b99d47752887b6164fb5b6bc13d4bae9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72791e5862dc34a5c23f357c4636519a3b7c180a1ed7ed038f20159bc6f29c2a683a490782a940b9bceece5bbd3ebfaa88f66f555d6e91921ccdf22feae2a88f
|
7
|
+
data.tar.gz: 962e41980b306165d10e226ba8a4228dde0f9dce9e79f3c513aafbadfe7088281673b7b39ede657e3e7d519558a2af12c1d2e7a63f631bc56b848d99e49bdc83
|
data/README.md
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
<a href="https://github.com/KrauseFx/deliver">Deliver</a> •
|
3
3
|
<b>Snapshot</b> •
|
4
4
|
<a href="https://github.com/KrauseFx/frameit">FrameIt</a> •
|
5
|
-
<a href="https://github.com/KrauseFx/PEM">PEM</a>
|
5
|
+
<a href="https://github.com/KrauseFx/PEM">PEM</a> •
|
6
|
+
<a href="https://github.com/KrauseFx/sigh">Sigh</a>
|
6
7
|
</p>
|
7
8
|
-------
|
8
9
|
|
@@ -10,7 +11,7 @@
|
|
10
11
|
<img src="assets/snapshot.png">
|
11
12
|
</p>
|
12
13
|
|
13
|
-
Snapshot - Create
|
14
|
+
Snapshot - Create iOS App Screenshots
|
14
15
|
============
|
15
16
|
|
16
17
|
[![Twitter: @KauseFx](https://img.shields.io/badge/contact-@KrauseFx-blue.svg?style=flat)](https://twitter.com/KrauseFx)
|
@@ -41,13 +42,15 @@ Follow the developer on Twitter: [@KrauseFx](https://twitter.com/KrauseFx)
|
|
41
42
|
|
42
43
|
|
43
44
|
-------
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
<p align="center">
|
46
|
+
<a href="#features">Features</a> •
|
47
|
+
<a href="#installation">Installation</a> •
|
48
|
+
<a href="#ui-automation">UI Automation</a> •
|
49
|
+
<a href="#quick-start">Quick Start</a> •
|
50
|
+
<a href="#usage">Usage</a> •
|
51
|
+
<a href="#tips">Tips</a> •
|
52
|
+
<a href="#need-help">Need help?</a>
|
53
|
+
</p>
|
51
54
|
|
52
55
|
-------
|
53
56
|
|
@@ -56,7 +59,8 @@ Follow the developer on Twitter: [@KrauseFx](https://twitter.com/KrauseFx)
|
|
56
59
|
- Create hundreds of screenshots in multiple languages on all simulators
|
57
60
|
- Configure it once, store the configuration in git
|
58
61
|
- Do something else, while the computer takes the screenshots for you
|
59
|
-
- Very easy to integrate with ```deliver```
|
62
|
+
- Very easy to integrate with [```deliver```](https://github.com/KrauseFx/deliver)
|
63
|
+
- Generates a beautiful web page, which shows all screenshots on all devices. This is perfect to send to Q&A or the marketing team
|
60
64
|
- ```Snapshot``` automatically waits for network requests to be finished before taking a screenshot (we don't want loading images in the App Store screenshots)
|
61
65
|
|
62
66
|
After ```Snapshot``` successfully created new screenshots, it will generate a beautiful html file to get a quick overview of all screens:
|
@@ -184,12 +188,6 @@ By default, ```snapshot``` will look for your project in the current directory.
|
|
184
188
|
project_path "./my_project/Project.xcworkspace"
|
185
189
|
```
|
186
190
|
|
187
|
-
### HTML Report Path
|
188
|
-
After all screenshots were created, a HTML file will be generated, to quickly get an overview of all screens on all devices. You can set a custom export path, to easily integrate the HTML report as ```Jenkins``` test result page.
|
189
|
-
```ruby
|
190
|
-
html_path "~/Desktop/screens.html"
|
191
|
-
```
|
192
|
-
|
193
191
|
### iOS Version
|
194
192
|
I'll try to keep the script up to date. If you need to change the iOS version, you can do it like this:
|
195
193
|
|
@@ -238,6 +236,14 @@ end
|
|
238
236
|
In case you want to skip this process, just add ```skip_alpha_removal``` to your ```Snapfile```.
|
239
237
|
|
240
238
|
# Tips
|
239
|
+
|
240
|
+
## Other helpful tools
|
241
|
+
Check out other tools in this collection to speed up your deployment process:
|
242
|
+
- [```deliver```](https://github.com/KrauseFx/deliver): Deploy screenshots, app metadata and app updates to the App Store using just one command.
|
243
|
+
- [```FrameIt```](https://github.com/KrauseFx/frameit): Want a device frame around your screenshot? Do it in an instant!
|
244
|
+
- [```PEM```](https://github.com/KrauseFx/pem): Tired of manually creating and maintaining your push certification profiles?
|
245
|
+
- [```sigh```](https://github.com/KrauseFx/sigh): Because you would rather spend your time building stuff than fighting provisioning.
|
246
|
+
|
241
247
|
## Specify a custom ```Snapfile```
|
242
248
|
|
243
249
|
snapshot --snapfile ./SpecialSnapfile
|
data/bin/snapshot
CHANGED
@@ -31,10 +31,11 @@ command :run do |c|
|
|
31
31
|
c.syntax = 'snapshot'
|
32
32
|
c.description = 'Run the script, to take all the screenshots'
|
33
33
|
c.option '--snapfile STRING', String, 'Custom path for your Snapfile'
|
34
|
+
c.option '--noclean', 'Skips the clean process when running snapshot.'
|
34
35
|
|
35
36
|
c.action do |args, options|
|
36
37
|
Snapshot::SnapshotConfig.shared_instance(options.snapfile) if options.snapfile # to set the custom Snapfile path if given
|
37
|
-
Snapshot::Runner.new.work
|
38
|
+
Snapshot::Runner.new.work(clean: !options.noclean)
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
@@ -45,4 +46,4 @@ command :init do |c|
|
|
45
46
|
c.action do |args, options|
|
46
47
|
Snapshot::SnapfileCreator.create('.')
|
47
48
|
end
|
48
|
-
end
|
49
|
+
end
|
data/lib/assets/SnapfileTemplate
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Uncomment the lines below you want to change by removing the # in the beginning
|
2
2
|
|
3
3
|
# A list of devices you want to take the screenshots from
|
4
4
|
devices([
|
@@ -30,10 +30,6 @@ screenshots_path "./screenshots"
|
|
30
30
|
# By default, the latest version should be used automatically. If you want to change it, do it here
|
31
31
|
# ios_version '8.1'
|
32
32
|
|
33
|
-
# The path, on which the HTML file should be exported to
|
34
|
-
# html_path './screenshots.html'
|
35
|
-
|
36
|
-
|
37
33
|
# Custom Callbacks
|
38
34
|
|
39
35
|
# setup_for_device_change do |device|
|
@@ -52,4 +48,4 @@ screenshots_path "./screenshots"
|
|
52
48
|
# teardown_device do |device|
|
53
49
|
# puts "Cleaning device #{device}"
|
54
50
|
# system("./cleanup.sh")
|
55
|
-
# end
|
51
|
+
# end
|
data/lib/snapshot/builder.rb
CHANGED
@@ -6,16 +6,18 @@ module Snapshot
|
|
6
6
|
|
7
7
|
|
8
8
|
def initialize
|
9
|
-
|
9
|
+
|
10
10
|
end
|
11
11
|
|
12
|
-
def build_app
|
12
|
+
def build_app(clean: true)
|
13
|
+
FileUtils.rm_rf(BUILD_DIR) if clean
|
14
|
+
|
13
15
|
command = SnapshotConfig.shared_instance.build_command
|
14
16
|
|
15
17
|
if not command
|
16
18
|
# That's the default case, user did not provide a custom build_command
|
17
19
|
raise "Could not find project. Please pass the path to your project using 'project_path'.".red unless SnapshotConfig.shared_instance.project_name
|
18
|
-
command = generate_build_command
|
20
|
+
command = generate_build_command(clean: clean)
|
19
21
|
end
|
20
22
|
|
21
23
|
Helper.log.info "Building project '#{SnapshotConfig.shared_instance.project_name}' - this might take some time...".green
|
@@ -51,7 +53,7 @@ module Snapshot
|
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
|
-
def generate_build_command
|
56
|
+
def generate_build_command(clean: true)
|
55
57
|
scheme = SnapshotConfig.shared_instance.scheme
|
56
58
|
|
57
59
|
proj_path = SnapshotConfig.shared_instance.project_path
|
@@ -59,16 +61,21 @@ module Snapshot
|
|
59
61
|
proj_key = 'workspace' if proj_path.end_with?'.xcworkspace'
|
60
62
|
|
61
63
|
build_command = (DependencyChecker.xctool_installed? ? 'xctool' : 'xcodebuild')
|
64
|
+
|
65
|
+
actions = []
|
66
|
+
actions << 'clean' if clean
|
67
|
+
actions << "build"
|
68
|
+
|
62
69
|
[
|
63
70
|
build_command,
|
64
|
-
"-sdk iphonesimulator
|
71
|
+
"-sdk iphonesimulator",
|
65
72
|
"CONFIGURATION_BUILD_DIR='#{BUILD_DIR}/build'",
|
66
73
|
"-#{proj_key} '#{proj_path}'",
|
67
74
|
"-scheme '#{scheme}'",
|
68
75
|
"DSTROOT='#{BUILD_DIR}'",
|
69
76
|
"OBJROOT='#{BUILD_DIR}'",
|
70
77
|
"SYMROOT='#{BUILD_DIR}'",
|
71
|
-
|
78
|
+
actions.join(' ')
|
72
79
|
].join(' ')
|
73
80
|
end
|
74
81
|
end
|
@@ -5,6 +5,7 @@ module Snapshot
|
|
5
5
|
self.check_simulators
|
6
6
|
self.check_xctool
|
7
7
|
self.check_for_automation_subfolder
|
8
|
+
self.check_simctl
|
8
9
|
end
|
9
10
|
|
10
11
|
def self.check_xcode_select
|
@@ -24,6 +25,7 @@ module Snapshot
|
|
24
25
|
Helper.log.fatal '#############################################################'
|
25
26
|
Helper.log.fatal "# You have to add new simulators using Xcode"
|
26
27
|
Helper.log.fatal "# Xcode => Window => Devices"
|
28
|
+
Helper.log.fatal "# Please run `instruments -s` to verify your xcode path"
|
27
29
|
Helper.log.fatal '#############################################################'
|
28
30
|
raise "Create the new simulators and run this script again"
|
29
31
|
end
|
@@ -48,5 +50,11 @@ module Snapshot
|
|
48
50
|
raise "Seems like you have an 'Automation' folder in the current directory. You need to delete/rename it!".red
|
49
51
|
end
|
50
52
|
end
|
53
|
+
|
54
|
+
def self.check_simctl
|
55
|
+
unless `xcrun simctl`.include?"openurl"
|
56
|
+
raise "Could not find `xcrun simctl`. Make sure you have the latest version of Xcode and Mac OS installed.".red
|
57
|
+
end
|
58
|
+
end
|
51
59
|
end
|
52
60
|
end
|
data/lib/snapshot/page.html.erb
CHANGED
@@ -40,10 +40,11 @@
|
|
40
40
|
<% screens.each do |screen_path| %>
|
41
41
|
<% next if screen_path.include?"_framed.png" %>
|
42
42
|
<td>
|
43
|
+
<% path = screen_path.gsub("./screenshots/", "./") %>
|
43
44
|
<% screen_size = FastImage.size(screen_path) %>
|
44
|
-
<a href="<%=
|
45
|
+
<a href="<%= path %>" target="_blank">
|
45
46
|
<img class="screenshot"
|
46
|
-
src="<%=
|
47
|
+
src="<%= path %>",
|
47
48
|
style="width: <%= [(screen_size[0] / divide_size_by).round, max_width].min %>px;" />
|
48
49
|
</a>
|
49
50
|
</td>
|
@@ -28,11 +28,10 @@ module Snapshot
|
|
28
28
|
html_path = [lib_path, "snapshot/page.html.erb"].join('/')
|
29
29
|
html = ERB.new(File.read(html_path)).result(binding) # http://www.rrn.dk/rubys-erb-templating-system
|
30
30
|
|
31
|
-
|
32
|
-
export_path = SnapshotConfig.shared_instance.html_path
|
31
|
+
export_path = "#{screens_path}/screenshots.html"
|
33
32
|
File.write(export_path, html)
|
34
33
|
|
35
|
-
Helper.log.info "Successfully created HTML file with all the screenshots: #{export_path}".green
|
34
|
+
Helper.log.info "Successfully created HTML file with an overview of all the screenshots: '#{File.expand_path(export_path)}'".green
|
36
35
|
end
|
37
36
|
|
38
37
|
private
|
data/lib/snapshot/runner.rb
CHANGED
@@ -8,18 +8,23 @@ module Snapshot
|
|
8
8
|
Snapshot::DependencyChecker.check_dependencies
|
9
9
|
end
|
10
10
|
|
11
|
-
def work
|
11
|
+
def work(clean: true)
|
12
12
|
SnapshotConfig.shared_instance.js_file # to verify the file can be found
|
13
13
|
|
14
|
-
Builder.new.build_app
|
14
|
+
Builder.new.build_app(clean: clean)
|
15
|
+
@app_path = Dir.glob("/tmp/snapshot/build/*.app").first
|
15
16
|
|
16
17
|
counter = 0
|
17
18
|
errors = []
|
19
|
+
|
18
20
|
SnapshotConfig.shared_instance.devices.each do |device|
|
19
21
|
|
20
22
|
SnapshotConfig.shared_instance.blocks[:setup_for_device_change].call(device) # Callback
|
21
23
|
|
22
24
|
SnapshotConfig.shared_instance.languages.each do |language|
|
25
|
+
|
26
|
+
# uninstall_app(device)
|
27
|
+
|
23
28
|
SnapshotConfig.shared_instance.blocks[:setup_for_language_change].call(language, device) # Callback
|
24
29
|
|
25
30
|
begin
|
@@ -57,12 +62,11 @@ module Snapshot
|
|
57
62
|
|
58
63
|
def run_tests(device, language)
|
59
64
|
Helper.log.info "Running tests on #{device} in language #{language}".green
|
60
|
-
app_path = Dir.glob("/tmp/snapshot/build/*.app").first
|
61
65
|
|
62
66
|
clean_old_traces
|
63
67
|
|
64
68
|
ENV['SNAPSHOT_LANGUAGE'] = language
|
65
|
-
command = generate_test_command(device, language
|
69
|
+
command = generate_test_command(device, language)
|
66
70
|
Helper.log.debug command.yellow
|
67
71
|
|
68
72
|
retry_run = false
|
@@ -98,6 +102,32 @@ module Snapshot
|
|
98
102
|
return errors
|
99
103
|
end
|
100
104
|
|
105
|
+
# def uninstall_app(device)
|
106
|
+
# def com(str)
|
107
|
+
# puts str.yellow
|
108
|
+
# puts `#{str}`
|
109
|
+
# sleep 1.0
|
110
|
+
# end
|
111
|
+
|
112
|
+
# def find_simulator(name)
|
113
|
+
# all = `instruments -s`.split("\n")
|
114
|
+
# all.each do |current|
|
115
|
+
# return current.match(/\[(.*)\]/)[1] if current.include?name
|
116
|
+
# end
|
117
|
+
# raise "Could not find simulator '#{name}' to install the app on."
|
118
|
+
# end
|
119
|
+
|
120
|
+
# udid = find_simulator(device)
|
121
|
+
# com("killall 'iOS Simulator'")
|
122
|
+
# com("xcrun simctl boot '#{udid}'")
|
123
|
+
# com("xcrun simctl uninstall '#{udid}' 'net.sunapps.123'") # TODO: Dynamic
|
124
|
+
# sleep 3
|
125
|
+
# com("xcrun simctl install '#{udid}' '#{@app_path}'")
|
126
|
+
# com("xcrun simctl shutdown '#{udid}'")
|
127
|
+
# sleep 1
|
128
|
+
# com("killall 'iOS Simulator'")
|
129
|
+
# end
|
130
|
+
|
101
131
|
def parse_test_line(line)
|
102
132
|
if line =~ /.*Target failed to run.*/
|
103
133
|
return :retry
|
@@ -127,7 +157,7 @@ module Snapshot
|
|
127
157
|
return Dir.glob("#{TRACE_DIR}/**/*.png").count
|
128
158
|
end
|
129
159
|
|
130
|
-
def generate_test_command(device, language
|
160
|
+
def generate_test_command(device, language)
|
131
161
|
script_path = SnapshotConfig.shared_instance.js_file
|
132
162
|
|
133
163
|
[
|
@@ -135,7 +165,7 @@ module Snapshot
|
|
135
165
|
"-w '#{device}'",
|
136
166
|
"-D '#{TRACE_DIR}/trace'",
|
137
167
|
"-t 'Automation'",
|
138
|
-
"'#{app_path}'",
|
168
|
+
"'#{@app_path}'",
|
139
169
|
"-e UIARESULTSPATH '#{TRACE_DIR}'",
|
140
170
|
"-e UIASCRIPT '#{script_path}'",
|
141
171
|
"-AppleLanguages '(#{language})'",
|
@@ -25,9 +25,6 @@ module Snapshot
|
|
25
25
|
# @return (String) The path, in which the screenshots should be stored
|
26
26
|
attr_accessor :screenshots_path
|
27
27
|
|
28
|
-
# @return (String) The path, in which the HTML file should be exported to
|
29
|
-
attr_accessor :html_path
|
30
|
-
|
31
28
|
# @return (String) The build command, wich should build the app to '/tmp/snapshot'
|
32
29
|
attr_accessor :build_command
|
33
30
|
|
@@ -48,12 +45,14 @@ module Snapshot
|
|
48
45
|
path ||= './Snapfile'
|
49
46
|
set_defaults
|
50
47
|
|
51
|
-
if
|
48
|
+
if File.exists?path
|
49
|
+
Helper.log.info "Using '#{path}'".green
|
52
50
|
self.snapshot_file = SnapshotFile.new(path, self)
|
53
51
|
else
|
54
52
|
if path != './Snapfile'
|
55
53
|
raise "Could not find Snapfile at path '#{path}'. Make sure you pass the full path, including 'Snapfile'".red
|
56
54
|
else
|
55
|
+
# Using default settings, since user didn't provide a path
|
57
56
|
Helper.log.error "Could not find './Snapfile'. It is recommended to create a file using 'snapshot init' into the current directory. Using the defaults now.".red
|
58
57
|
end
|
59
58
|
end
|
@@ -81,8 +80,6 @@ module Snapshot
|
|
81
80
|
self.project_path = (Dir.glob("./*.xcworkspace").first rescue nil) # prefer workspaces ofc
|
82
81
|
self.project_path ||= (Dir.glob("./*.xcodeproj").first rescue nil)
|
83
82
|
|
84
|
-
self.html_path = './screenshots.html'
|
85
|
-
|
86
83
|
empty = Proc.new {}
|
87
84
|
self.blocks = {
|
88
85
|
setup_for_device_change: empty,
|
@@ -102,7 +99,7 @@ module Snapshot
|
|
102
99
|
|
103
100
|
# Returns the file name of the project
|
104
101
|
def project_name
|
105
|
-
(self.project_path
|
102
|
+
File.basename(self.project_path, ".*" )
|
106
103
|
end
|
107
104
|
|
108
105
|
# The JavaScript UIAutomation file
|
@@ -120,7 +117,7 @@ module Snapshot
|
|
120
117
|
# The scheme to use (either it's set, or there is only one, or user has to enter it)
|
121
118
|
def scheme
|
122
119
|
begin
|
123
|
-
command = "cd '#{
|
120
|
+
command = "cd '#{File.expand_path('..', project_path)}'; xcodebuild -list"
|
124
121
|
schemes = `#{command}`.split("Schemes:").last.split("\n").each { |a| a.strip! }.delete_if { |a| a == '' }
|
125
122
|
Helper.log.debug "Found available schemes: #{schemes}"
|
126
123
|
|
@@ -36,14 +36,10 @@ module Snapshot
|
|
36
36
|
when :js_file
|
37
37
|
raise "js_file has to be an String".red unless value.kind_of?String
|
38
38
|
raise "js_file at path '#{value}' not found".red unless File.exists?value
|
39
|
-
@config.manual_js_file =
|
39
|
+
@config.manual_js_file = File.expand_path(value)
|
40
40
|
when :screenshots_path
|
41
41
|
raise "screenshots_path has to be an String".red unless value.kind_of?String
|
42
|
-
@config.screenshots_path =
|
43
|
-
when :html_path
|
44
|
-
raise "html_path has to be an String".red unless value.kind_of?String
|
45
|
-
@config.html_path = value.gsub("~", ENV['HOME'])
|
46
|
-
@config.html_path = @config.html_path + "/screenshots.html" unless @config.html_path.include?".html"
|
42
|
+
@config.screenshots_path = File.expand_path(value)
|
47
43
|
when :build_command
|
48
44
|
raise "build_command has to be an String".red unless value.kind_of?String
|
49
45
|
@config.build_command = value
|
@@ -52,10 +48,11 @@ module Snapshot
|
|
52
48
|
when :project_path
|
53
49
|
raise "project_path has to be an String".red unless value.kind_of?String
|
54
50
|
|
55
|
-
|
56
|
-
|
51
|
+
path = File.expand_path(value)
|
52
|
+
if File.exists?path and (path.end_with?".xcworkspace" or path.end_with?".xcodeproj")
|
53
|
+
@config.project_path = path
|
57
54
|
else
|
58
|
-
raise "The given project_path '#{
|
55
|
+
raise "The given project_path '#{path}' could not be found. Make sure to include the extension as well.".red
|
59
56
|
end
|
60
57
|
|
61
58
|
# Blocks
|
data/lib/snapshot/version.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Krause
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|