snapshot 0.5.0 → 0.6.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 +4 -4
- data/README.md +33 -5
- data/bin/snapshot +2 -1
- data/lib/snapshot/builder.rb +11 -10
- data/lib/snapshot/page.html.erb +3 -0
- data/lib/snapshot/reports_generator.rb +11 -9
- data/lib/snapshot/runner.rb +4 -3
- data/lib/snapshot/snapshot_config.rb +5 -2
- data/lib/snapshot/snapshot_file.rb +3 -0
- 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: 920d554867f6ee77a1100ff2c43f43065a9356ea
|
4
|
+
data.tar.gz: 19834058363057e3e1f3ceb68412079c065878ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eecfdc2cbf3fb17854217c78b740616cce1f30314c1624f5eb480e792472f93ac8c6df92e5804972caa359bd82f888a7ebc19188cd6b6bceb40da532f8d52696
|
7
|
+
data.tar.gz: 246ff86c93511de42fcda6a8c5f6b6fc162dbbc625f2cbfa6becf3128ec509ae4b4bdb6234831107d2fe9e40e615373b4d04de82ff01c91d14973cec7093461b
|
data/README.md
CHANGED
@@ -233,18 +233,19 @@ ios_version "9.0"
|
|
233
233
|
|
234
234
|
### Custom Args for the build command
|
235
235
|
Use the ```custom_args``` directive to prepend custom statements to the build command.
|
236
|
-
|
237
|
-
custom_args "GCC_PREPROCESSOR_DEFINITIONS='SCREENSHOTS'"
|
238
|
-
```
|
236
|
+
|
239
237
|
Add a ```custom_build_args``` line to your ```Snapfile``` to add custom arguments to the build command.
|
238
|
+
|
239
|
+
Here is an example for adding a preprocessor macro `SNAPSHOT` and a custom build setting `SNAPSHOT_ENABLE`.
|
240
|
+
|
240
241
|
```ruby
|
241
|
-
custom_build_args "
|
242
|
+
custom_build_args "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) SNAPSHOT=1' SNAPSHOT_ENABLE = YES"
|
242
243
|
```
|
243
244
|
|
244
245
|
### Custom Build Command
|
245
246
|
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.
|
246
247
|
|
247
|
-
**Make sure** you are setting the output path to ```/tmp/snapshot```.
|
248
|
+
**Make sure** you are setting the output path to ```/tmp/snapshot``` or specify a custom ```build_dir``` on your ```Snapfile```.
|
248
249
|
|
249
250
|
```ruby
|
250
251
|
build_command "xcodebuild DSTROOT='/tmp/snapshot' OBJROOT='/tmp/snapshot' SYMROOT='/tmp/snapshot' ... "
|
@@ -349,6 +350,33 @@ Unfortunately ```Instruments``` sometimes decides, to not respond to anything. W
|
|
349
350
|
|
350
351
|
The only way to fix this, is a restart of the Mac.
|
351
352
|
|
353
|
+
## Use a custom build system
|
354
|
+
Using a build systems not based on Xcode –such as RubyMotion or Xamarin– is also possible.
|
355
|
+
|
356
|
+
### RubyMotion
|
357
|
+
|
358
|
+
Add to your ```Snapfile```:
|
359
|
+
|
360
|
+
```ruby
|
361
|
+
build_dir 'build/iPhoneSimulator-7.0-Development'
|
362
|
+
build_command 'rake build:simulator'
|
363
|
+
```
|
364
|
+
|
365
|
+
### Xamarin
|
366
|
+
|
367
|
+
Add to your ```Snapfile```:
|
368
|
+
|
369
|
+
```ruby
|
370
|
+
build_dir 'YourProject/bin/iPhoneSimulator'
|
371
|
+
build_command '/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool -v build "--configuration:Debug|iPhoneSimulator" YourProject.sln'
|
372
|
+
```
|
373
|
+
|
374
|
+
Unfortunately, Xamarin command line tool is only available for Business Edition licenses. For Indie licenses you can build the app using Xamarin Studio and use the ```--nobuild``` option.
|
375
|
+
|
376
|
+
### Skip building
|
377
|
+
|
378
|
+
If building via command-line doesn't work for your project or you don't want to build every time, you can run the tool with ```snapshot --nobuild``` to skip the build process and use a pre-built ```.app``` under your ```build_dir```.
|
379
|
+
|
352
380
|
# Need help?
|
353
381
|
- If there is a technical problem with ```snapshot```, submit an issue.
|
354
382
|
- I'm available for contract work - drop me an email: snapshot@krausefx.com
|
data/bin/snapshot
CHANGED
@@ -22,6 +22,7 @@ class SnapshotApplication
|
|
22
22
|
program :help_formatter, :compact
|
23
23
|
|
24
24
|
global_option '--snapfile PATH', String, 'Custom path for your Snapfile.'
|
25
|
+
global_option '--nobuild', 'Skips the build process when running snapshot.'
|
25
26
|
global_option '--noclean', 'Skips the clean process of the build command when running snapshot.'
|
26
27
|
global_option('--verbose', 'Shows all output printed by Instruments.') { $verbose = true }
|
27
28
|
|
@@ -36,7 +37,7 @@ class SnapshotApplication
|
|
36
37
|
Dir.chdir(path) do # switch the context
|
37
38
|
Snapshot::DependencyChecker.check_simulators
|
38
39
|
Snapshot::SnapshotConfig.shared_instance(options.snapfile)
|
39
|
-
Snapshot::Runner.new.work(clean: !options.noclean)
|
40
|
+
Snapshot::Runner.new.work(clean: !options.noclean, build: !options.nobuild)
|
40
41
|
end
|
41
42
|
end
|
42
43
|
end
|
data/lib/snapshot/builder.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
module Snapshot
|
2
2
|
class Builder
|
3
|
-
BUILD_DIR = '/tmp/snapshot'
|
4
|
-
|
5
3
|
|
6
4
|
def initialize
|
7
|
-
|
5
|
+
@build_dir = SnapshotConfig.shared_instance.build_dir || '/tmp/snapshot'
|
8
6
|
end
|
9
7
|
|
10
8
|
def build_app(clean: true)
|
11
|
-
FileUtils.rm_rf(
|
9
|
+
FileUtils.rm_rf(@build_dir) if clean
|
12
10
|
|
13
11
|
command = SnapshotConfig.shared_instance.build_command
|
14
12
|
|
@@ -33,14 +31,17 @@ module Snapshot
|
|
33
31
|
raise ex
|
34
32
|
end
|
35
33
|
end
|
34
|
+
Process.wait(pid)
|
36
35
|
end
|
36
|
+
# Exit status for build command, should be 0 if build succeeded
|
37
|
+
cmdstatus = $?.exitstatus
|
37
38
|
|
38
|
-
if all_lines.join('\n').include?'** BUILD SUCCEEDED **'
|
39
|
+
if cmdstatus == 0 || all_lines.join('\n').include?('** BUILD SUCCEEDED **')
|
39
40
|
Helper.log.info "BUILD SUCCEEDED".green
|
40
41
|
return true
|
41
42
|
else
|
42
43
|
Helper.log.info(all_lines.join(' '))
|
43
|
-
raise "Looks like the build was not
|
44
|
+
raise "Looks like the build was not successful."
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
@@ -70,12 +71,12 @@ module Snapshot
|
|
70
71
|
[
|
71
72
|
build_command,
|
72
73
|
"-sdk iphonesimulator",
|
73
|
-
"CONFIGURATION_BUILD_DIR='#{
|
74
|
+
"CONFIGURATION_BUILD_DIR='#{@build_dir}/build'",
|
74
75
|
"-#{proj_key} '#{proj_path}'",
|
75
76
|
"-scheme '#{scheme}'",
|
76
|
-
"DSTROOT='#{
|
77
|
-
"OBJROOT='#{
|
78
|
-
"SYMROOT='#{
|
77
|
+
"DSTROOT='#{@build_dir}'",
|
78
|
+
"OBJROOT='#{@build_dir}'",
|
79
|
+
"SYMROOT='#{@build_dir}'",
|
79
80
|
custom_build_args,
|
80
81
|
actions.join(' ')
|
81
82
|
].join(' ')
|
data/lib/snapshot/page.html.erb
CHANGED
@@ -12,16 +12,18 @@ module Snapshot
|
|
12
12
|
language = File.basename(language_path)
|
13
13
|
Dir[File.join(language_path, '*')].sort.each do |screenshot|
|
14
14
|
|
15
|
-
|
15
|
+
["portrait", "landscape"].each do |orientation|
|
16
|
+
available_devices.each do |key_name, output_name|
|
17
|
+
if File.basename(screenshot).include?key_name and File.basename(screenshot).include?orientation
|
18
|
+
output_name += " (#{orientation.capitalize})"
|
19
|
+
# This screenshot it from this device
|
20
|
+
@data[language] ||= {}
|
21
|
+
@data[language][output_name] ||= []
|
16
22
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
+
resulting_path = File.join('.', language, File.basename(screenshot))
|
24
|
+
@data[language][output_name] << resulting_path
|
25
|
+
break # to not include iPhone 6 and 6 Plus (name is contained in the other name)
|
26
|
+
end
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
data/lib/snapshot/runner.rb
CHANGED
@@ -5,10 +5,10 @@ module Snapshot
|
|
5
5
|
class Runner
|
6
6
|
TRACE_DIR = '/tmp/snapshot_traces'
|
7
7
|
|
8
|
-
def work(clean: true)
|
8
|
+
def work(clean: true, build: true)
|
9
9
|
SnapshotConfig.shared_instance.js_file # to verify the file can be found earlier
|
10
10
|
|
11
|
-
Builder.new.build_app(clean: clean)
|
11
|
+
Builder.new.build_app(clean: clean) if build
|
12
12
|
@app_path = determine_app_path
|
13
13
|
|
14
14
|
counter = 0
|
@@ -153,7 +153,8 @@ module Snapshot
|
|
153
153
|
|
154
154
|
def determine_app_path
|
155
155
|
# Determine the path to the actual app and not the WatchKit app
|
156
|
-
|
156
|
+
build_dir = SnapshotConfig.shared_instance.build_dir || '/tmp/snapshot'
|
157
|
+
Dir.glob("#{build_dir}/**/*.app/*.plist").each do |path|
|
157
158
|
watchkit_enabled = `/usr/libexec/PlistBuddy -c 'Print WKWatchKitApp' '#{path}'`.strip
|
158
159
|
next if watchkit_enabled == 'true' # we don't care about WatchKit Apps
|
159
160
|
|
@@ -25,9 +25,12 @@ 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 build command, wich should build the app to
|
28
|
+
# @return (String) The build command, wich should build the app to build_dir (/tmp/snapshot by default)
|
29
29
|
attr_accessor :build_command
|
30
30
|
|
31
|
+
# @return (String) The build directory, defaults to '/tmp/snapshot'
|
32
|
+
attr_accessor :build_dir
|
33
|
+
|
31
34
|
# @return (BOOL) Skip the removal of the alpha channel from the screenshots
|
32
35
|
attr_accessor :skip_alpha_removal
|
33
36
|
|
@@ -138,7 +141,7 @@ module Snapshot
|
|
138
141
|
|
139
142
|
# Returns the file name of the project
|
140
143
|
def project_name
|
141
|
-
File.basename(self.project_path, ".*" )
|
144
|
+
File.basename(self.project_path, ".*" ) if self.project_path
|
142
145
|
end
|
143
146
|
|
144
147
|
# The JavaScript UIAutomation file
|
@@ -44,6 +44,9 @@ module Snapshot
|
|
44
44
|
when :build_command
|
45
45
|
raise "build_command has to be an String".red unless value.kind_of?String
|
46
46
|
@config.build_command = value
|
47
|
+
when :build_dir
|
48
|
+
raise "build_dir has to be an String".red unless value.kind_of?String
|
49
|
+
@config.build_dir = File.expand_path(value)
|
47
50
|
when :custom_args
|
48
51
|
raise "custom_args has to be an String".red unless value.kind_of?String
|
49
52
|
@config.custom_args = value
|
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
|
+
version: 0.6.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: 2015-
|
11
|
+
date: 2015-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastimage
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.4.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.4.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|