screengrab 0.3.2 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9389e49b61448d2e514a577597a2eeabab3a27d
4
- data.tar.gz: 5dcce367104bdd340e7326ab5b8afebe8bb2e0f4
3
+ metadata.gz: 743b0f8af7f0ec6de3aa80d03aa61847db7c8bfb
4
+ data.tar.gz: 7b7959a8b42f88eca5b1dc2885d78d59f5e95946
5
5
  SHA512:
6
- metadata.gz: fbd73085c982df0d8bf27b553db09eae485a17fac711bf13d9c1a6e240a5da3bc8f587a9d1dc971109bd9796d93ddc92e94b6a8d1bebc642084a5cb6b4c0db30
7
- data.tar.gz: 9e0d0e76b21219e90a182ea87dd7be781e7ba35ac8cfc0df4b3bf150b94ebea6c8ae0c5557396a1e2da33c189ba2a0e633622c5e91d05be89e64ac45f772d9c8
6
+ metadata.gz: 24dfcd3e54c91a52a1acf5bf863e1117300128e149ce1999855d504fb20c39226a5e89a31725c6692742b6ba9dfe21ca0ada6004ade40ceae628efefbc178a93
7
+ data.tar.gz: 7e98d055a361f43556567b0d4979ef0aab7eceff03d423a174c07bcb00fe85470a8c0acc0b37b915257fe69e379c7f65b3b3c44768fecc2436588fef658c35f2
data/README.md CHANGED
@@ -35,6 +35,8 @@ screengrab
35
35
 
36
36
  ###### Automated localized screenshots of your Android app on every device
37
37
 
38
+ `screengrab` generates localized screenshots of your Android app for different device types and languages for Google Play and can be uploaded using ([`supply`](https://github.com/fastlane/fastlane/tree/master/supply).
39
+
38
40
  <img src="assets/running-screengrab.gif" width="640">
39
41
 
40
42
  ### Why should I automate this process?
@@ -53,7 +55,7 @@ sudo gem install screengrab
53
55
 
54
56
  ##### Gradle dependency
55
57
  ```java
56
- androidTestCompile 'tools.fastlane:screengrab:0.3.0'
58
+ androidTestCompile 'tools.fastlane:screengrab:0.3.2'
57
59
  ```
58
60
 
59
61
  ##### Configuring your Manifest Permissions
@@ -152,7 +154,7 @@ If you're having trouble getting your device unlocked and the screen activated t
152
154
 
153
155
  ## [`fastlane`](https://fastlane.tools) Toolchain
154
156
 
155
- - [`fastlane`](https://fastlane.tools): Connect all deployment tools into one streamlined workflow
157
+ - [`fastlane`](https://fastlane.tools): The easiest way to automate building and releasing your iOS and Android apps
156
158
  - [`supply`](https://github.com/fastlane/fastlane/tree/master/supply): Upload screenshots, metadata and your app to the Play Store
157
159
 
158
160
  You can find all the tools on [fastlane.tools](https://fastlane.tools).
data/bin/screengrab CHANGED
@@ -1,65 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  $:.push File.expand_path("../../lib", __FILE__)
4
3
 
5
4
  require 'screengrab'
6
- require 'commander'
7
-
8
- HighLine.track_eof = false
9
-
10
- class ScreengrabApplication
11
- include Commander::Methods
12
-
13
- def run
14
- program :version, Screengrab::VERSION
15
- program :description, 'CLI for \'screengrab\' - Automate taking localized screenshots of your Android app on emulators or real devices'
16
- program :help, 'Authors', 'Andrea Falcone <afalcone@twitter.com>, Michael Furtak <mfurtak@twitter.com>'
17
- program :help, 'Website', 'https://fastlane.tools'
18
- program :help, 'GitHub', 'https://github.com/fastlane/screengrab'
19
- program :help_formatter, :compact
20
-
21
- global_option('--verbose', 'Shows a more verbose output') { $verbose = true }
22
-
23
- always_trace!
24
-
25
- FastlaneCore::CommanderGenerator.new.generate(Screengrab::Options.available_options)
26
-
27
- command :run do |c|
28
- c.syntax = 'screengrab'
29
- c.description = 'Take new screenshots based on the screengrabfile.'
30
-
31
- c.action do |args, options|
32
- o = options.__hash__.dup
33
- o.delete(:verbose)
34
- Screengrab.config = FastlaneCore::Configuration.create(Screengrab::Options.available_options, o)
35
- Screengrab.android_environment = Screengrab::AndroidEnvironment.new(Screengrab.config[:android_home],
36
- Screengrab.config[:build_tools_version])
37
-
38
- Screengrab::DependencyChecker.check(Screengrab.android_environment)
39
- Screengrab::Runner.new.run
40
- end
41
- end
42
-
43
- command :init do |c|
44
- c.syntax = 'screengrab init'
45
- c.description = "Creates a new Screengrabfile in the current directory"
46
-
47
- c.action do |args, options|
48
- require 'screengrab/setup'
49
- path = (Screengrab::Helper.fastlane_enabled? ? './fastlane' : '.')
50
- Screengrab::Setup.create(path)
51
- end
52
- end
53
-
54
- default_command :run
55
-
56
- run!
57
- end
58
- end
59
-
60
- begin
61
- FastlaneCore::UpdateChecker.start_looking_for_update('screengrab')
62
- ScreengrabApplication.new.run
63
- ensure
64
- FastlaneCore::UpdateChecker.show_update_status('screengrab', Screengrab::VERSION)
65
- end
5
+ require 'screengrab/commands_generator'
6
+ Screengrab::CommandsGenerator.start
@@ -0,0 +1,62 @@
1
+ require 'commander'
2
+
3
+ HighLine.track_eof = false
4
+
5
+ module Screengrab
6
+ class CommandsGenerator
7
+ include Commander::Methods
8
+
9
+ def self.start
10
+ FastlaneCore::UpdateChecker.start_looking_for_update('screengrab')
11
+ self.new.run
12
+ ensure
13
+ FastlaneCore::UpdateChecker.show_update_status('screengrab', Screengrab::VERSION)
14
+ end
15
+
16
+ def run
17
+ program :version, Screengrab::VERSION
18
+ program :description, 'CLI for \'screengrab\' - Automate taking localized screenshots of your Android app on emulators or real devices'
19
+ program :help, 'Authors', 'Andrea Falcone <afalcone@twitter.com>, Michael Furtak <mfurtak@twitter.com>'
20
+ program :help, 'Website', 'https://fastlane.tools'
21
+ program :help, 'GitHub', 'https://github.com/fastlane/screengrab'
22
+ program :help_formatter, :compact
23
+
24
+ global_option('--verbose', 'Shows a more verbose output') { $verbose = true }
25
+
26
+ always_trace!
27
+
28
+ FastlaneCore::CommanderGenerator.new.generate(Screengrab::Options.available_options)
29
+
30
+ command :run do |c|
31
+ c.syntax = 'screengrab'
32
+ c.description = 'Take new screenshots based on the screengrabfile.'
33
+
34
+ c.action do |args, options|
35
+ o = options.__hash__.dup
36
+ o.delete(:verbose)
37
+ Screengrab.config = FastlaneCore::Configuration.create(Screengrab::Options.available_options, o)
38
+ Screengrab.android_environment = Screengrab::AndroidEnvironment.new(Screengrab.config[:android_home],
39
+ Screengrab.config[:build_tools_version])
40
+
41
+ Screengrab::DependencyChecker.check(Screengrab.android_environment)
42
+ Screengrab::Runner.new.run
43
+ end
44
+ end
45
+
46
+ command :init do |c|
47
+ c.syntax = 'screengrab init'
48
+ c.description = "Creates a new Screengrabfile in the current directory"
49
+
50
+ c.action do |args, options|
51
+ require 'screengrab/setup'
52
+ path = (Screengrab::Helper.fastlane_enabled? ? './fastlane' : '.')
53
+ Screengrab::Setup.create(path)
54
+ end
55
+ end
56
+
57
+ default_command :run
58
+
59
+ run!
60
+ end
61
+ end
62
+ end
@@ -230,20 +230,24 @@ module Screengrab
230
230
 
231
231
  UI.verbose("Starting screenshot count is: #{starting_screenshot_count}")
232
232
 
233
- device_screenshots_paths.each do |device_path|
234
- if_device_path_exists(device_serial, device_path) do |path|
235
- @executor.execute(command: "adb -s #{device_serial} pull #{path} #{@config[:output_directory]}",
236
- print_all: false,
237
- print_command: true)
233
+ # Make a temp directory into which to pull the screenshots before they are moved to their final location.
234
+ # This makes directory cleanup easier, as the temp directory will be removed when the block completes.
235
+ Dir.mktmpdir do |tempdir|
236
+ device_screenshots_paths.each do |device_path|
237
+ if_device_path_exists(device_serial, device_path) do |path|
238
+ @executor.execute(command: "adb -s #{device_serial} pull #{path} #{tempdir}",
239
+ print_all: false,
240
+ print_command: true)
241
+ end
238
242
  end
239
- end
240
243
 
241
- # The SDK can't 100% determine what kind of device it is running on relative to the categories that
242
- # supply and Google Play care about (phone, 7" tablet, TV, etc.).
243
- #
244
- # Therefore, we'll move the pulled screenshots from their genericly named folder to one named by the
245
- # user provided device_type option value to match the directory structure that supply expects
246
- move_pulled_screenshots(device_type_dir_name)
244
+ # The SDK can't 100% determine what kind of device it is running on relative to the categories that
245
+ # supply and Google Play care about (phone, 7" tablet, TV, etc.).
246
+ #
247
+ # Therefore, we'll move the pulled screenshots from their genericly named folder to one named by the
248
+ # user provided device_type option value to match the directory structure that supply expects
249
+ move_pulled_screenshots(tempdir, device_type_dir_name)
250
+ end
247
251
 
248
252
  ending_screenshot_count = screenshot_file_names_in(@config[:output_directory], device_type_dir_name).length
249
253
 
@@ -259,23 +263,34 @@ module Screengrab
259
263
  ending_screenshot_count - starting_screenshot_count
260
264
  end
261
265
 
262
- def move_pulled_screenshots(device_type_dir_name)
266
+ def move_pulled_screenshots(pull_dir, device_type_dir_name)
263
267
  # Glob pattern that finds the pulled screenshots directory for each locale
264
- # (Matches: fastlane/metadata/android/en-US/images/screenshots)
265
- screenshots_dir_pattern = File.join(@config[:output_directory], '**', "screenshots")
268
+ # Possible matches:
269
+ # [pull_dir]/en-US/images/screenshots
270
+ # [pull_dir]/screengrab/en-US/images/screenshots
271
+ screenshots_dir_pattern = File.join(pull_dir, '**', "screenshots")
266
272
 
267
273
  Dir.glob(screenshots_dir_pattern, File::FNM_CASEFOLD).each do |screenshots_dir|
268
274
  src_screenshots = Dir.glob(File.join(screenshots_dir, '*.png'), File::FNM_CASEFOLD)
269
275
 
270
- # We move the screenshots by replacing the last segment of the screenshots directory path with
271
- # the device_type specific name
276
+ # The :output_directory is the final location for the screenshots, so we begin by replacing
277
+ # the temp directory portion of the path, with the output directory
278
+ dest_dir = screenshots_dir.gsub(pull_dir, @config[:output_directory])
279
+
280
+ # Different versions of adb are inconsistent about whether they will pull down the containing
281
+ # directory for the screenshots, so we'll try to remove that path from the directory name when
282
+ # creating the destination path.
283
+ # See: https://github.com/fastlane/fastlane/pull/4915#issuecomment-236368649
284
+ dest_dir = dest_dir.gsub('screengrab/', '')
285
+
286
+ # We then replace the last segment of the screenshots directory path with the device_type
287
+ # specific name, as expected by supply
272
288
  #
273
289
  # (Moved to: fastlane/metadata/android/en-US/images/phoneScreenshots)
274
- dest_dir = File.join(File.dirname(screenshots_dir), device_type_dir_name)
290
+ dest_dir = File.join(File.dirname(dest_dir), device_type_dir_name)
275
291
 
276
292
  FileUtils.mkdir_p(dest_dir)
277
293
  FileUtils.cp_r(src_screenshots, dest_dir)
278
- FileUtils.rm_r(screenshots_dir)
279
294
  UI.success "Screenshots copied to #{dest_dir}"
280
295
  end
281
296
  end
data/version.properties CHANGED
@@ -1,3 +1,3 @@
1
1
  major=0
2
- minor=3
3
- patch=2
2
+ minor=4
3
+ patch=0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: screengrab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Falcone
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-07 00:00:00.000000000 Z
12
+ date: 2016-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fastlane_core
@@ -199,6 +199,7 @@ files:
199
199
  - lib/assets/ScreengrabfileTemplate
200
200
  - lib/screengrab.rb
201
201
  - lib/screengrab/android_environment.rb
202
+ - lib/screengrab/commands_generator.rb
202
203
  - lib/screengrab/dependency_checker.rb
203
204
  - lib/screengrab/detect_values.rb
204
205
  - lib/screengrab/options.rb