snapshot 0.0.2 → 0.1.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 +41 -2
- data/lib/snapshot.rb +0 -2
- data/lib/snapshot/builder.rb +7 -3
- data/lib/snapshot/runner.rb +7 -3
- data/lib/snapshot/snapshot_config.rb +7 -1
- data/lib/snapshot/snapshot_file.rb +6 -1
- data/lib/snapshot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a66a1a9280b45c2ab1a4791bc85878ea76dc9929
|
|
4
|
+
data.tar.gz: c0fdea38499e026ba90f5d50064308c1da2c488a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 95c00e2071a985cb2430f42fded88f4b208ed94432df393b8637fca9c2e407b55c2c9cb89304f98fe9d4a5a2cf253152bbe0ea9640eabc56439d36ad08503190
|
|
7
|
+
data.tar.gz: 6ea6bf77f028ed25ce463a2ab85c0164c2bf313426528c5463698154a93f0472260ec9265cfb598bd6f146fcf502f5358d297469f292b3e7b6ea57383924212e
|
data/README.md
CHANGED
|
@@ -22,6 +22,7 @@ Follow the developer on Twitter: [@KrauseFx](https://twitter.com/KrauseFx)
|
|
|
22
22
|
-------
|
|
23
23
|
[Features](#features) •
|
|
24
24
|
[Installation](#installation) •
|
|
25
|
+
[UI Automation](#ui-automation) •
|
|
25
26
|
[Quick Start](#quick-start) •
|
|
26
27
|
[Usage](#usage) •
|
|
27
28
|
[Tips](#tips) •
|
|
@@ -35,6 +36,16 @@ Follow the developer on Twitter: [@KrauseFx](https://twitter.com/KrauseFx)
|
|
|
35
36
|
- Configure it once, store the configuration in git
|
|
36
37
|
- Do something else, while the computer takes the screenshots for you
|
|
37
38
|
- Very easy to integrate with ```deliver```
|
|
39
|
+
- ```Snapshot``` automatically waits for network requests to be finished before taking a screenshot (we don't want loading images in the App Store screenshots)
|
|
40
|
+
|
|
41
|
+
## Why?
|
|
42
|
+
This gem automatically switches the language and device type and runs the automation script to take all screenshots.
|
|
43
|
+
|
|
44
|
+
**Why use ```snapshot``` instead of....**
|
|
45
|
+
|
|
46
|
+
- **UI Automation in Instruments**: Instruments can only run your app on one device in one language. You have to manually switch it.
|
|
47
|
+
- **[ui-screen-shooter](https://github.com/jonathanpenn/ui-screen-shooter)**: This ist the best alternative out there right now. It's based on AppleScript, you can not update it properly and there are quite some hacks in there. ```Snapshot``` uses a very similar technique - just in a clean and maintainable Ruby gem.
|
|
48
|
+
- **[Subliminal](https://github.com/inkling/Subliminal)**: A good approach to write the interaction code in Objective C. Unfortunately it has a lot of open issues with the latest release of Xcode.
|
|
38
49
|
|
|
39
50
|
# Installation
|
|
40
51
|
|
|
@@ -45,6 +56,28 @@ Install the gem
|
|
|
45
56
|
Make sure, you have the latest version of the Xcode command line tools installed:
|
|
46
57
|
|
|
47
58
|
xcode-select --install
|
|
59
|
+
|
|
60
|
+
# UI Automation
|
|
61
|
+
|
|
62
|
+
## Get started
|
|
63
|
+
This project uses Apple's ```UI Automation``` under the hood. I will not go into detail on how to write scripts.
|
|
64
|
+
|
|
65
|
+
Here a few links to get started:
|
|
66
|
+
|
|
67
|
+
- [Apple's official documentation](https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/UsingtheAutomationInstrument/UsingtheAutomationInstrument.html)
|
|
68
|
+
- [UI Automation: An Introduction (cocoamanifest.net)](http://cocoamanifest.net/articles/2011/05/uiautomation-an-introduction.html)
|
|
69
|
+
- [Functional Testing UI Automation (mattmccomb.com)](http://www.mattmccomb.com/blog/2013/06/02/ios-functional-testing-with-uiautomation/)
|
|
70
|
+
|
|
71
|
+
## Record your first script
|
|
72
|
+
Profile your app (CMD + I), choose ```Automation``` and click the Record button on the bottom of the window.
|
|
73
|
+
|
|
74
|
+
This will get you started. Save the generated file with the extension ```js``` into your project root.
|
|
75
|
+
|
|
76
|
+
Add ```#import "SnapshotHelper.js"``` on the top of your file.
|
|
77
|
+
|
|
78
|
+
Now you can use ```captureLocalizedScreenshot('0-name')``` to take a snapshot.
|
|
79
|
+
|
|
80
|
+
You can take a look at the example project to play around with it.
|
|
48
81
|
|
|
49
82
|
# Quick Start
|
|
50
83
|
|
|
@@ -92,7 +125,7 @@ languages([
|
|
|
92
125
|
])
|
|
93
126
|
```
|
|
94
127
|
|
|
95
|
-
###
|
|
128
|
+
### JavaScript file
|
|
96
129
|
Usually ```snapshot``` automatically finds your JavaScript file. If that's not the case, you can pass the path
|
|
97
130
|
to your test file.
|
|
98
131
|
```ruby
|
|
@@ -105,6 +138,12 @@ To not be asked which scheme to use, just set it like this:
|
|
|
105
138
|
scheme "Name"
|
|
106
139
|
```
|
|
107
140
|
|
|
141
|
+
### Screenshots output path
|
|
142
|
+
All generated screenshots will be stored in the given path.
|
|
143
|
+
```ruby
|
|
144
|
+
screenshots_path './screenshots'
|
|
145
|
+
```
|
|
146
|
+
|
|
108
147
|
### Project Path
|
|
109
148
|
By default, ```snapshot``` will look for your project in the current directory. If it is located somewhere else, pass your custom path:
|
|
110
149
|
```ruby
|
|
@@ -128,7 +167,7 @@ ios_version "9.0"
|
|
|
128
167
|
## Use a clean status bar
|
|
129
168
|
You can use [SimulatorStatusMagic](https://github.com/shinydevelopment/SimulatorStatusMagic) to clean up the status bar.
|
|
130
169
|
|
|
131
|
-
## Editing the ```
|
|
170
|
+
## Editing the ```Snapfile```
|
|
132
171
|
Change syntax highlighting to *Ruby*.
|
|
133
172
|
|
|
134
173
|
# Need help?
|
data/lib/snapshot.rb
CHANGED
data/lib/snapshot/builder.rb
CHANGED
|
@@ -6,14 +6,14 @@ module Snapshot
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def initialize
|
|
9
|
-
|
|
9
|
+
FileUtils.rm_rf(BUILD_DIR)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def build_app
|
|
13
13
|
raise "Could not find project. Please pass the path to your project using 'project_path'.".red unless SnapshotConfig.shared_instance.project_name
|
|
14
14
|
command = generate_build_command
|
|
15
15
|
|
|
16
|
-
Helper.log.info "Building project '#{SnapshotConfig.shared_instance.project_name}'
|
|
16
|
+
Helper.log.info "Building project '#{SnapshotConfig.shared_instance.project_name}' - this might take some time...".green
|
|
17
17
|
Helper.log.debug command.yellow
|
|
18
18
|
|
|
19
19
|
all_lines = []
|
|
@@ -49,12 +49,16 @@ module Snapshot
|
|
|
49
49
|
def generate_build_command
|
|
50
50
|
scheme = SnapshotConfig.shared_instance.scheme
|
|
51
51
|
|
|
52
|
+
proj_path = SnapshotConfig.shared_instance.project_path
|
|
53
|
+
proj_key = 'project'
|
|
54
|
+
proj_key = 'workspace' if proj_path.end_with?'.xcworkspace'
|
|
55
|
+
|
|
52
56
|
build_command = (DependencyChecker.xctool_installed? ? 'xctool' : 'xcodebuild')
|
|
53
57
|
[
|
|
54
58
|
build_command,
|
|
55
59
|
"-sdk iphonesimulator#{SnapshotConfig.shared_instance.ios_version}",
|
|
56
60
|
"CONFIGURATION_BUILD_DIR='#{BUILD_DIR}/build'",
|
|
57
|
-
"
|
|
61
|
+
"-#{proj_key} '#{proj_path}'",
|
|
58
62
|
"-scheme '#{scheme}'",
|
|
59
63
|
"-configuration Debug",
|
|
60
64
|
"DSTROOT='#{BUILD_DIR}'",
|
data/lib/snapshot/runner.rb
CHANGED
|
@@ -9,8 +9,6 @@ module Snapshot
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def work
|
|
12
|
-
@screenshots_path = './screenshots'
|
|
13
|
-
|
|
14
12
|
SnapshotConfig.shared_instance.js_file # to verify the file can be found
|
|
15
13
|
|
|
16
14
|
Builder.new.build_app
|
|
@@ -27,6 +25,9 @@ module Snapshot
|
|
|
27
25
|
|
|
28
26
|
end
|
|
29
27
|
end
|
|
28
|
+
|
|
29
|
+
Helper.log.info "Successfully finished generating screenshots.".green
|
|
30
|
+
Helper.log.info "Check it out here: #{SnapshotConfig.shared_instance.screenshots_path}".green
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
def clean_old_traces
|
|
@@ -83,8 +84,11 @@ module Snapshot
|
|
|
83
84
|
end
|
|
84
85
|
|
|
85
86
|
def copy_screenshots(language)
|
|
86
|
-
resulting_path = [
|
|
87
|
+
resulting_path = [SnapshotConfig.shared_instance.screenshots_path, language].join('/')
|
|
88
|
+
resulting_path.gsub!("~", ENV['HOME']) # some strange bug requires this
|
|
89
|
+
|
|
87
90
|
FileUtils.mkdir_p resulting_path
|
|
91
|
+
|
|
88
92
|
Dir.glob("#{TRACE_DIR}/**/*.png") do |file|
|
|
89
93
|
FileUtils.cp_r(file, resulting_path + '/')
|
|
90
94
|
end
|
|
@@ -22,6 +22,9 @@ module Snapshot
|
|
|
22
22
|
# @return (String) The path to the JavaScript file to use
|
|
23
23
|
attr_accessor :manual_js_file
|
|
24
24
|
|
|
25
|
+
# @return (String) The path, in which the screenshots should be stored
|
|
26
|
+
attr_accessor :screenshots_path
|
|
27
|
+
|
|
25
28
|
|
|
26
29
|
# A shared singleton
|
|
27
30
|
def self.shared_instance
|
|
@@ -46,7 +49,7 @@ module Snapshot
|
|
|
46
49
|
"iPhone 6 (#{self.ios_version} Simulator)",
|
|
47
50
|
"iPhone 6 Plus (#{self.ios_version} Simulator)",
|
|
48
51
|
"iPhone 5 (#{self.ios_version} Simulator)",
|
|
49
|
-
"iPhone
|
|
52
|
+
"iPhone 4s (#{self.ios_version} Simulator)"
|
|
50
53
|
]
|
|
51
54
|
|
|
52
55
|
self.languages = [
|
|
@@ -54,6 +57,8 @@ module Snapshot
|
|
|
54
57
|
'en-US'
|
|
55
58
|
]
|
|
56
59
|
|
|
60
|
+
self.screenshots_path = './screenshots'
|
|
61
|
+
|
|
57
62
|
self.project_path = (Dir.glob("./*.xcworkspace").first rescue nil)
|
|
58
63
|
self.project_path ||= (Dir.glob("./*.xcodeproj").first rescue nil)
|
|
59
64
|
end
|
|
@@ -82,6 +87,7 @@ module Snapshot
|
|
|
82
87
|
schemes = `#{command}`.split("Schemes:").last.split("\n").each { |a| a.strip! }.delete_if { |a| a == '' }
|
|
83
88
|
Helper.log.debug "Found available schemes: #{schemes}"
|
|
84
89
|
|
|
90
|
+
self.manual_scheme = schemes.first if schemes.count == 1
|
|
85
91
|
|
|
86
92
|
if self.manual_scheme
|
|
87
93
|
if not schemes.include?manual_scheme
|
|
@@ -33,6 +33,9 @@ module Snapshot
|
|
|
33
33
|
raise "js_file has to be an String".red unless value.kind_of?String
|
|
34
34
|
raise "js_file at path '#{value}' not found".red unless File.exists?value
|
|
35
35
|
@config.manual_js_file = value
|
|
36
|
+
when :screenshots_path
|
|
37
|
+
raise "screenshots_path has to be an String".red unless value.kind_of?String
|
|
38
|
+
@config.screenshots_path = value
|
|
36
39
|
when :project_path
|
|
37
40
|
raise "project_path has to be an String".red unless value.kind_of?String
|
|
38
41
|
|
|
@@ -48,14 +51,16 @@ module Snapshot
|
|
|
48
51
|
|
|
49
52
|
def verify_devices(value)
|
|
50
53
|
raise "Devices has to be an array".red unless value.kind_of?Array
|
|
54
|
+
@config.devices = []
|
|
51
55
|
value.each do |current|
|
|
52
56
|
current += " (#{@config.ios_version} Simulator)" unless current.include?"Simulator"
|
|
53
57
|
|
|
54
58
|
unless SnapshotFile.available_devices.include?current
|
|
55
59
|
raise "Device '#{current}' not found. Available device types: #{SnapshotFile.available_devices}".red
|
|
60
|
+
else
|
|
61
|
+
@config.devices << current
|
|
56
62
|
end
|
|
57
63
|
end
|
|
58
|
-
@config.devices = value
|
|
59
64
|
end
|
|
60
65
|
|
|
61
66
|
def verify_languages(value)
|
data/lib/snapshot/version.rb
CHANGED