motion-frank-screenshots 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,48 @@
1
+ # motion-frank-screenshots
2
+
3
+ Take automated screenshots in RubyMotion apps using Frank.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'motion-frank-screenshots'
10
+
11
+ And then execute:
12
+
13
+ bundle install
14
+
15
+ Or install it yourself as:
16
+
17
+ gem install motion-frank-screenshots
18
+
19
+ Then run the following command once, to get everything set up:
20
+
21
+ rake frank:init_screenshots
22
+
23
+ ## Usage
24
+
25
+ To take a screenshot in your frank scenario, add the following line:
26
+
27
+ Then I take a screenshot into "<filename>"
28
+
29
+ This will take a picture of what is currently on your screen and store it in `screenshots/<filename>.png` in non-retina mode, `screenshots/<filename>@2x.png` for 3.5 inch retina mode and `screenshots/<filename>-568h@2x.png` for 4 inch retina mode.
30
+
31
+ To get started, you can add the following into `features/screenshots.feature`:
32
+
33
+ Feature:
34
+ As a RubyMotion developer
35
+ I want to take screenshots
36
+ So I can submit them with the app to the App Store
37
+
38
+ Scenario: Splash screen
39
+ Given I launch the app
40
+ Then I take a screenshot into "Default"
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create new Pull Request
@@ -0,0 +1,18 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise "This file must be required within a RubyMotion project Rakefile."
3
+ end
4
+
5
+ lib_dir_path = File.dirname(File.expand_path(__FILE__))
6
+ Motion::Project::App.setup do |app|
7
+ app.files.unshift(Dir.glob(File.join(lib_dir_path, "motion-frank-screenshots/**/*.rb")))
8
+ end
9
+
10
+ namespace 'frank' do
11
+ desc "Create first feature files"
12
+ task :init_screenshots do
13
+ target_dir = File.join(Rake.application.original_dir, 'features', 'step_definitions')
14
+ FileUtils.cp_r(File.join(lib_dir_path, 'steps', 'screenshot_steps.rb'), target_dir)
15
+ FileUtils.mkdir_p(File.join(Rake.application.original_dir, 'screenshots'))
16
+ File.open(File.join(Rake.application.original_dir, 'screenshots', '.gitignore'), 'w') { |file| file.puts '*.png' }
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ class AppDelegate
2
+ def screenshot(filename)
3
+ Screenshooter.shot(filename)
4
+ end
5
+ end
@@ -0,0 +1,35 @@
1
+ class Screenshooter
2
+ def self.shot(filename)
3
+ new(filename).shot
4
+ end
5
+
6
+ def initialize(filename)
7
+ @filename = filename
8
+ end
9
+
10
+ def shot
11
+ if BW::Device.retina?
12
+ UIGraphicsBeginImageContextWithOptions(App.window.bounds.size, false, UIScreen.mainScreen.scale)
13
+ else
14
+ UIGraphicsBeginImageContext(App.window.bounds.size)
15
+ end
16
+
17
+ App.window.layer.renderInContext(UIGraphicsGetCurrentContext())
18
+ image = UIGraphicsGetImageFromCurrentImageContext()
19
+ UIGraphicsEndImageContext()
20
+ data = UIImagePNGRepresentation(image)
21
+ data.writeToFile("#{@filename}#{appendix}.png", atomically:true)
22
+ end
23
+
24
+ def appendix
25
+ if BW::Device.retina?
26
+ if BW::Device.long_screen?
27
+ "-568h@2x"
28
+ else
29
+ "@2x"
30
+ end
31
+ else
32
+ ""
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ def code_path
2
+ Dir.pwd
3
+ end
4
+
5
+ Then /^I take a screenshot into "(.*)"$/ do |filename|
6
+ app_exec "screenshot:", "#{code_path}/screenshots/#{filename}"
7
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-frank-screenshots
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Thomas Kadauke
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: motion-frank
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: bubble-wrap
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Take automated screenshots for RubyMotion apps using Frank
63
+ email:
64
+ - thomas.kadauke@googlemail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - README.md
70
+ - lib/motion-frank-screenshots/app_delegate.rb
71
+ - lib/motion-frank-screenshots/screenshooter.rb
72
+ - lib/motion-frank-screenshots.rb
73
+ - lib/steps/screenshot_steps.rb
74
+ homepage: https://github.com/tkadauke/motion-frank-screenshots
75
+ licenses: []
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ segments:
87
+ - 0
88
+ hash: 1412018289300031946
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ segments:
96
+ - 0
97
+ hash: 1412018289300031946
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 1.8.25
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: Take automated screenshots for RubyMotion apps using Frank
104
+ test_files: []