flypbook 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 57d4985df996adb726bc3c03cf9b1e3afe30da52
4
+ data.tar.gz: 169b1df9ce265b55009f3c806d77c71c56bf05d3
5
+ SHA512:
6
+ metadata.gz: 1b195174bd8695a7fd698f0dc0bbb7465843b4be20421ee1ab1b1458754f02f89c48991eb01c64da8e6b25bd2d817418246d2eb09eac1800a359f2234470f148
7
+ data.tar.gz: d74d148b61e933214771a3e7a293e7255ad8adf7eb4000813d481c2a519ac6d91160bb0b3cb7a48d16cdf45e3246f38b66c8ff3ff68ac4ef1d49ea3feffacdc7
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.0
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.13.7
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at cgunadi@pivotal.io. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in flypbook.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Pivotal Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Flypbook
2
+
3
+ We’re working on a beach project where we create a library that will take screenshots of a journey test and put them in Google Drive every time we check in new code to GitHub that can help PMs and ADs and Sales show iterative delivery.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'flypbook'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install flypbook
20
+
21
+ ## Usage
22
+
23
+ #### Geckodriver
24
+
25
+ Download the geckodriver for Firefox [here](https://github.com/mozilla/geckodriver/releases/) and add the file to your PATH. Also, install Firefox.
26
+
27
+ ### Google Drive Integration
28
+
29
+ In order to save screenshots to Google Drive, you need to set up credentials via the Google Developer Console. Please follow the [command line authorization instructions](https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md) steps 1 through 6. For step two, if using the pivotal.io domain, select an existing project called `labs-lmorley`.
30
+
31
+ After you receive your client id and secret, you'll also need to get a refresh token.
32
+
33
+ ```
34
+ $ export GOOGLE_CLIENT_ID=<your client ID here>
35
+ $ export GOOGLE_CLIENT_SECRET=<your client secret here>
36
+ ```
37
+
38
+ After that, run `retrieve_refresh_token` and set the refresh token:
39
+
40
+ ```
41
+ $ export GOOGLE_REFRESH_TOKEN=<your refresh token here>
42
+ ```
43
+
44
+ ## Development
45
+
46
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
47
+
48
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
49
+
50
+ ## Contributing
51
+
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/pivotal/flypbook. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
53
+
54
+
55
+ ## License
56
+
57
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "flypbook"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'google_drive'
4
+
5
+ credentials = Google::Auth::UserRefreshCredentials.new(
6
+ client_id: ENV['GOOGLE_CLIENT_ID'],
7
+ client_secret: ENV['GOOGLE_CLIENT_SECRET'],
8
+ scope: GoogleDrive::Session::DEFAULT_SCOPE,
9
+ redirect_uri: 'urn:ietf:wg:oauth:2.0:oob')
10
+
11
+ puts("\n1. Open this page:\n#{credentials.authorization_uri}\n\n")
12
+ puts('2. Enter the authorization code shown in the page:')
13
+ credentials.code = $stdin.gets.chomp
14
+ credentials.fetch_access_token!
15
+
16
+ puts '\n\nExport the refresh token as follows:'
17
+ puts
18
+ puts "export GOOGLE_REFRESH_TOKEN=#{credentials.refresh_token}"
data/flypbook.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'flypbook/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "flypbook"
8
+ spec.version = Flypbook::VERSION
9
+ spec.authors = ["Chris Gunadi", "Brian Watkins", "Tyson McNulty", "Liam Morley", "Mitchell Rosen"]
10
+ spec.email = ["cgunadi@pivotal.io", "bwatkins@pivotal.io", "tmcnulty@pivotal.io", "lmorley@pivotal.io", "mrosen@pivotal.io"]
11
+
12
+ spec.summary = "Automatic screenshot capture for Capybara"
13
+ # spec.description = %q{TODO: Write a longer description or delete this line.}
14
+ spec.homepage = "http://pivotal.io"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "rspec", "~> 3.0"
25
+ spec.add_dependency "capybara", "~> 2.11"
26
+ spec.add_dependency "selenium-webdriver", "~> 3.0"
27
+ spec.add_dependency "google_drive", "~> 2.1"
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.13"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "sinatra", "~> 1.4"
32
+ end
data/lib/flypbook.rb ADDED
@@ -0,0 +1,42 @@
1
+ require 'flypbook/version'
2
+ require 'capybara'
3
+
4
+ require 'flypbook/photo_store'
5
+ require 'flypbook/google_drive'
6
+
7
+ module Flypbook
8
+ module DriverExtensions
9
+ def visit(path)
10
+ PhotoStore.take_screenshot 'visit-before'
11
+ super(path)
12
+ PhotoStore.take_screenshot 'visit-after'
13
+ end
14
+ end
15
+
16
+ module CapybaraSeleniumNodeExtensions
17
+ def click
18
+ PhotoStore.take_screenshot 'click'
19
+ super
20
+ end
21
+ end
22
+
23
+ class Capybara::Selenium::Driver
24
+ prepend DriverExtensions
25
+ end
26
+
27
+ class Capybara::Selenium::Node
28
+ prepend CapybaraSeleniumNodeExtensions
29
+ end
30
+
31
+ RSpec.configure do |config|
32
+ config.after do
33
+ PhotoStore.take_screenshot 'after' unless ENV['FLYPBOOK_SPEC'] == 'testing'
34
+ end
35
+
36
+ config.after(:suite) do
37
+ unless ENV['FLYPBOOK_SPEC'] == 'testing'
38
+ GoogleDrive.new(ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], ENV['GOOGLE_REFRESH_TOKEN']).upload
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,25 @@
1
+ require 'google_drive'
2
+
3
+ module Flypbook
4
+ class GoogleDrive
5
+ def initialize(client_id, client_secret, refresh_token)
6
+ credentials = ::Google::Auth::UserRefreshCredentials.new(
7
+ client_id: client_id,
8
+ client_secret: client_secret,
9
+ scope: ::GoogleDrive::Session::DEFAULT_SCOPE,
10
+ redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
11
+ refresh_token: refresh_token
12
+ )
13
+ @session = ::GoogleDrive::Session.new(credentials)
14
+ end
15
+
16
+ def upload
17
+ root_collection = @session.root_collection
18
+ flypbook = root_collection.subcollection_by_title('Flypbook') || root_collection.create_subcollection('Flypbook')
19
+ current_run_collection = flypbook.create_subcollection "journey_#{DateTime.now}"
20
+ PhotoStore.screenshots.each do |screenshot|
21
+ current_run_collection.add @session.upload_from_file(screenshot, screenshot, convert: false)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,14 @@
1
+ module Flypbook
2
+ class PhotoStore
3
+ @screenshots = []
4
+ class << self
5
+ attr_reader :screenshots
6
+
7
+ def take_screenshot(identifier)
8
+ filename = "#{identifier}-#{@screenshots.length + 1}.png"
9
+ Capybara.current_session.save_screenshot filename
10
+ @screenshots << filename
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module Flypbook
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flypbook
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Gunadi
8
+ - Brian Watkins
9
+ - Tyson McNulty
10
+ - Liam Morley
11
+ - Mitchell Rosen
12
+ autorequire:
13
+ bindir: exe
14
+ cert_chain: []
15
+ date: 2017-01-13 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: rspec
19
+ requirement: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - "~>"
22
+ - !ruby/object:Gem::Version
23
+ version: '3.0'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - "~>"
29
+ - !ruby/object:Gem::Version
30
+ version: '3.0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: capybara
33
+ requirement: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - "~>"
36
+ - !ruby/object:Gem::Version
37
+ version: '2.11'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - "~>"
43
+ - !ruby/object:Gem::Version
44
+ version: '2.11'
45
+ - !ruby/object:Gem::Dependency
46
+ name: selenium-webdriver
47
+ requirement: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - "~>"
50
+ - !ruby/object:Gem::Version
51
+ version: '3.0'
52
+ type: :runtime
53
+ prerelease: false
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - "~>"
57
+ - !ruby/object:Gem::Version
58
+ version: '3.0'
59
+ - !ruby/object:Gem::Dependency
60
+ name: google_drive
61
+ requirement: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - "~>"
64
+ - !ruby/object:Gem::Version
65
+ version: '2.1'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '2.1'
73
+ - !ruby/object:Gem::Dependency
74
+ name: bundler
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '1.13'
80
+ type: :development
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '1.13'
87
+ - !ruby/object:Gem::Dependency
88
+ name: rake
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '10.0'
94
+ type: :development
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - "~>"
99
+ - !ruby/object:Gem::Version
100
+ version: '10.0'
101
+ - !ruby/object:Gem::Dependency
102
+ name: sinatra
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '1.4'
108
+ type: :development
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - "~>"
113
+ - !ruby/object:Gem::Version
114
+ version: '1.4'
115
+ description:
116
+ email:
117
+ - cgunadi@pivotal.io
118
+ - bwatkins@pivotal.io
119
+ - tmcnulty@pivotal.io
120
+ - lmorley@pivotal.io
121
+ - mrosen@pivotal.io
122
+ executables:
123
+ - retrieve_refresh_token
124
+ extensions: []
125
+ extra_rdoc_files: []
126
+ files:
127
+ - ".gitignore"
128
+ - ".rspec"
129
+ - ".ruby-version"
130
+ - ".travis.yml"
131
+ - CODE_OF_CONDUCT.md
132
+ - Gemfile
133
+ - LICENSE.txt
134
+ - README.md
135
+ - Rakefile
136
+ - bin/console
137
+ - bin/setup
138
+ - exe/retrieve_refresh_token
139
+ - flypbook.gemspec
140
+ - lib/flypbook.rb
141
+ - lib/flypbook/google_drive.rb
142
+ - lib/flypbook/photo_store.rb
143
+ - lib/flypbook/version.rb
144
+ homepage: http://pivotal.io
145
+ licenses:
146
+ - MIT
147
+ metadata: {}
148
+ post_install_message:
149
+ rdoc_options: []
150
+ require_paths:
151
+ - lib
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubyforge_project:
164
+ rubygems_version: 2.6.8
165
+ signing_key:
166
+ specification_version: 4
167
+ summary: Automatic screenshot capture for Capybara
168
+ test_files: []