snapshot 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/lib/assets/SnapfileTemplate +1 -1
- data/lib/snapshot/builder.rb +2 -1
- data/lib/snapshot/dependency_checker.rb +5 -5
- data/lib/snapshot/page.html.erb +3 -4
- data/lib/snapshot/reports_generator.rb +1 -1
- data/lib/snapshot/runner.rb +3 -1
- data/lib/snapshot/screenshot_flatten.rb +3 -12
- data/lib/snapshot/snapshot_config.rb +34 -8
- data/lib/snapshot/snapshot_file.rb +5 -15
- data/lib/snapshot/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb22e301c8b01a884a5a8c28d667c7232aec7aac
|
4
|
+
data.tar.gz: ade29b593ed655a723842b8a5a29adab0ec9edd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77e1b8abec203b2821de66c104e0327abd5d4bc07f716dc07494ded8910b364f66c08038a32f839e0164270ea1bacc0b920b392d4eb7cfb8b352d20fa25397ce
|
7
|
+
data.tar.gz: b46801b442b87817743e93575b2f24453ca3fa2851641632cd00aca4ed82b23c34f787c5574f209a136455a69b8c04a6ade27d45af2a53c62c70fbbbe5e3dc8e
|
data/README.md
CHANGED
@@ -226,6 +226,12 @@ I'll try to keep the script up to date. If you need to change the iOS version, y
|
|
226
226
|
ios_version "9.0"
|
227
227
|
```
|
228
228
|
|
229
|
+
### Custom Args for the build command
|
230
|
+
|
231
|
+
```ruby
|
232
|
+
custom_args "GCC_PREPROCESSOR_DEFINITIONS='SCREENSHOTS'"
|
233
|
+
```
|
234
|
+
|
229
235
|
### Custom Build Command
|
230
236
|
If for some reason, the default build command does not work for your project, you can pass your own build script. The script will be executed **once** before the tests are being run.
|
231
237
|
|
@@ -253,7 +259,7 @@ end
|
|
253
259
|
|
254
260
|
setup_for_language_change do |lang, device|
|
255
261
|
puts "Running #{lang} on #{device}"
|
256
|
-
system("./
|
262
|
+
system("./populateDatabase.sh")
|
257
263
|
end
|
258
264
|
|
259
265
|
teardown_language do |lang, device|
|
@@ -266,6 +272,8 @@ teardown_device do |device|
|
|
266
272
|
end
|
267
273
|
```
|
268
274
|
|
275
|
+
If you want to run a script before each run of the app, it's enough to only implement the `setup_for_language_change` callback.
|
276
|
+
|
269
277
|
### Skip alpha removal from screenshots
|
270
278
|
In case you want to skip this process, just add ```skip_alpha_removal``` to your ```Snapfile```.
|
271
279
|
|
data/lib/assets/SnapfileTemplate
CHANGED
data/lib/snapshot/builder.rb
CHANGED
@@ -58,7 +58,8 @@ module Snapshot
|
|
58
58
|
proj_key = 'project'
|
59
59
|
proj_key = 'workspace' if proj_path.end_with?'.xcworkspace'
|
60
60
|
|
61
|
-
|
61
|
+
pre_command = SnapshotConfig.shared_instance.custom_args || ENV["SNAPSHOT_CUSTOM_ARGS"] || ''
|
62
|
+
build_command = pre_command + ' ' + (DependencyChecker.xctool_installed? ? 'xctool' : 'xcodebuild')
|
62
63
|
|
63
64
|
actions = []
|
64
65
|
actions << 'clean' if clean
|
@@ -37,11 +37,11 @@ module Snapshot
|
|
37
37
|
|
38
38
|
def self.check_xctool
|
39
39
|
if not self.xctool_installed?
|
40
|
-
Helper.log.
|
41
|
-
Helper.log.
|
42
|
-
Helper.log.
|
43
|
-
Helper.log.
|
44
|
-
Helper.log.
|
40
|
+
Helper.log.info '#############################################################'
|
41
|
+
Helper.log.info "# xctool is recommended to build the apps"
|
42
|
+
Helper.log.info "# Install it using 'brew install xctool'"
|
43
|
+
Helper.log.info "# Falling back to xcode build instead "
|
44
|
+
Helper.log.info '#############################################################'
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
data/lib/snapshot/page.html.erb
CHANGED
@@ -40,11 +40,10 @@
|
|
40
40
|
<% screens.each do |screen_path| %>
|
41
41
|
<% next if screen_path.include?"_framed.png" %>
|
42
42
|
<td>
|
43
|
-
<%
|
44
|
-
|
45
|
-
<a href="<%= path %>" target="_blank">
|
43
|
+
<% screen_size = FastImage.size(screen_path) %>
|
44
|
+
<a href="<%= screen_path %>" target="_blank">
|
46
45
|
<img class="screenshot"
|
47
|
-
src="<%=
|
46
|
+
src="<%= screen_path %>",
|
48
47
|
style="width: <%= [(screen_size[0] / divide_size_by).round, max_width].min %>px;" />
|
49
48
|
</a>
|
50
49
|
</td>
|
@@ -27,7 +27,7 @@ module Snapshot
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
html_path =
|
30
|
+
html_path = File.join(lib_path, "snapshot/page.html.erb")
|
31
31
|
html = ERB.new(File.read(html_path)).result(binding) # http://www.rrn.dk/rubys-erb-templating-system
|
32
32
|
|
33
33
|
export_path = "#{screens_path}/screenshots.html"
|
data/lib/snapshot/runner.rb
CHANGED
@@ -34,6 +34,8 @@ module Snapshot
|
|
34
34
|
SnapshotConfig.shared_instance.blocks[:teardown_device].call(device) # Callback
|
35
35
|
end
|
36
36
|
|
37
|
+
`killall "iOS Simulator"` # close the simulator after the script is finished
|
38
|
+
|
37
39
|
ReportsGenerator.new.generate
|
38
40
|
|
39
41
|
if errors.count > 0
|
@@ -161,7 +163,7 @@ module Snapshot
|
|
161
163
|
end
|
162
164
|
|
163
165
|
def copy_screenshots(language)
|
164
|
-
resulting_path =
|
166
|
+
resulting_path = File.join(SnapshotConfig.shared_instance.screenshots_path, language)
|
165
167
|
|
166
168
|
FileUtils.mkdir_p resulting_path
|
167
169
|
|
@@ -4,25 +4,16 @@ module Snapshot
|
|
4
4
|
# @param (String) The path in which the screenshots are located in
|
5
5
|
def run(path)
|
6
6
|
Helper.log.info "Going to remove the alpha channel from generated png files"
|
7
|
-
|
8
|
-
flatten(path)
|
9
|
-
else
|
10
|
-
Helper.log.info "Could not remove transparency of generated screenhots.".yellow
|
11
|
-
Helper.log.info "This will cause problems when trying to manually upload them to iTC.".yellow
|
12
|
-
Helper.log.info "You can install 'imagemagick' using 'brew install imagemagick' to enable this feature.".yellow
|
13
|
-
end
|
7
|
+
flatten(path)
|
14
8
|
end
|
15
9
|
|
16
10
|
def flatten(path)
|
17
11
|
Dir.glob([path, '/**/*.png'].join('/')).each do |file|
|
18
12
|
Helper.log.info "Removing alpha channel from '#{file}'"
|
19
|
-
`
|
13
|
+
`sips -s format bmp '#{file}' &> /dev/null ` # &> /dev/null because there is warning because of the extension
|
14
|
+
`sips -s format png '#{file}'`
|
20
15
|
end
|
21
16
|
Helper.log.info "Finished removing the alpha channel."
|
22
17
|
end
|
23
|
-
|
24
|
-
def image_magick_installed?
|
25
|
-
`which convert`.length > 1
|
26
|
-
end
|
27
18
|
end
|
28
19
|
end
|
@@ -34,6 +34,9 @@ module Snapshot
|
|
34
34
|
# @return (BOOL) Clear previously generated screenshots before creating new ones
|
35
35
|
attr_accessor :clear_previous_screenshots
|
36
36
|
|
37
|
+
# @return (String) This will be prepended before the actual build command
|
38
|
+
attr_accessor :custom_args
|
39
|
+
|
37
40
|
# @return (Hash) All the blocks, which are called on specific actions
|
38
41
|
attr_accessor :blocks
|
39
42
|
|
@@ -51,12 +54,15 @@ module Snapshot
|
|
51
54
|
if File.exists?path
|
52
55
|
Helper.log.info "Using '#{path}'".green
|
53
56
|
self.snapshot_file = SnapshotFile.new(path, self)
|
57
|
+
|
58
|
+
self.verify_devices
|
54
59
|
else
|
55
60
|
if path != './Snapfile'
|
56
61
|
raise "Could not find Snapfile at path '#{path}'. Make sure you pass the full path, including 'Snapfile'".red
|
57
62
|
else
|
58
63
|
# Using default settings, since user didn't provide a path
|
59
64
|
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
|
65
|
+
self.verify_devices
|
60
66
|
end
|
61
67
|
end
|
62
68
|
|
@@ -66,13 +72,6 @@ module Snapshot
|
|
66
72
|
def set_defaults
|
67
73
|
self.ios_version = '8.1'
|
68
74
|
|
69
|
-
self.devices = [
|
70
|
-
"iPhone 6 (#{self.ios_version} Simulator)",
|
71
|
-
"iPhone 6 Plus (#{self.ios_version} Simulator)",
|
72
|
-
"iPhone 5 (#{self.ios_version} Simulator)",
|
73
|
-
"iPhone 4s (#{self.ios_version} Simulator)"
|
74
|
-
]
|
75
|
-
|
76
75
|
self.languages = [
|
77
76
|
'de-DE',
|
78
77
|
'en-US'
|
@@ -98,6 +97,33 @@ module Snapshot
|
|
98
97
|
}
|
99
98
|
end
|
100
99
|
|
100
|
+
# This has to be done after parsing the Snapfile (iOS version)
|
101
|
+
def set_default_simulators
|
102
|
+
self.devices ||= [
|
103
|
+
"iPhone 6 (#{self.ios_version} Simulator)",
|
104
|
+
"iPhone 6 Plus (#{self.ios_version} Simulator)",
|
105
|
+
"iPhone 5 (#{self.ios_version} Simulator)",
|
106
|
+
"iPhone 4s (#{self.ios_version} Simulator)"
|
107
|
+
]
|
108
|
+
end
|
109
|
+
|
110
|
+
# This method takes care of appending the iOS version to the simulator name
|
111
|
+
def verify_devices
|
112
|
+
self.set_default_simulators
|
113
|
+
|
114
|
+
actual_devices = []
|
115
|
+
self.devices.each do |current|
|
116
|
+
current += " (#{self.ios_version} Simulator)" unless current.include?"Simulator"
|
117
|
+
|
118
|
+
unless Simulators.available_devices.include?current
|
119
|
+
raise "Device '#{current}' not found. Available device types: #{Simulators.available_devices}".red
|
120
|
+
else
|
121
|
+
actual_devices << current
|
122
|
+
end
|
123
|
+
end
|
124
|
+
self.devices = actual_devices
|
125
|
+
end
|
126
|
+
|
101
127
|
def load_env
|
102
128
|
# Load environment variables
|
103
129
|
self.manual_scheme = ENV["SNAPSHOT_SCHEME"] if ENV["SNAPSHOT_SCHEME"]
|
@@ -129,7 +155,7 @@ module Snapshot
|
|
129
155
|
end
|
130
156
|
end
|
131
157
|
|
132
|
-
unless File.exists?result
|
158
|
+
unless File.exists?(result || '')
|
133
159
|
raise "Could not determine which UIAutomation file to use. Please pass a path to your Javascript file using 'js_file'.".red
|
134
160
|
end
|
135
161
|
|
@@ -24,7 +24,8 @@ module Snapshot
|
|
24
24
|
|
25
25
|
case method_sym
|
26
26
|
when :devices
|
27
|
-
|
27
|
+
raise "Devices has to be an array".red unless value.kind_of?Array
|
28
|
+
@config.devices = value
|
28
29
|
when :languages
|
29
30
|
@config.languages = value
|
30
31
|
when :ios_version
|
@@ -43,6 +44,9 @@ module Snapshot
|
|
43
44
|
when :build_command
|
44
45
|
raise "build_command has to be an String".red unless value.kind_of?String
|
45
46
|
@config.build_command = value
|
47
|
+
when :custom_args
|
48
|
+
raise "custom_args has to be an String".red unless value.kind_of?String
|
49
|
+
@config.custom_args = value
|
46
50
|
when :skip_alpha_removal
|
47
51
|
@config.skip_alpha_removal = true
|
48
52
|
when :clear_previous_screenshots
|
@@ -66,19 +70,5 @@ module Snapshot
|
|
66
70
|
Helper.log.error "Unknown method #{method_sym}"
|
67
71
|
end
|
68
72
|
end
|
69
|
-
|
70
|
-
def verify_devices(value)
|
71
|
-
raise "Devices has to be an array".red unless value.kind_of?Array
|
72
|
-
@config.devices = []
|
73
|
-
value.each do |current|
|
74
|
-
current += " (#{@config.ios_version} Simulator)" unless current.include?"Simulator"
|
75
|
-
|
76
|
-
unless Simulators.available_devices.include?current
|
77
|
-
raise "Device '#{current}' not found. Available device types: #{Simulators.available_devices}".red
|
78
|
-
else
|
79
|
-
@config.devices << current
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
73
|
end
|
84
74
|
end
|
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.4.
|
4
|
+
version: 0.4.8
|
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-
|
11
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 4
|
61
|
+
version: '4'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 4
|
68
|
+
version: '4'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: fastimage
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|