popart 0.1.1

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: 8e828b5786140a4a44daac950d186cbe9155efba
4
+ data.tar.gz: d40bd424a2ef9e3f1d0bf96771dc0fc0a5bcf4dc
5
+ SHA512:
6
+ metadata.gz: ceaab1659a2b41dec717f68a2871df7adb2ff39d6a667e17d208f49dd1ff10cbccb8d0deed1ea79511d0b4e469d508e26f9b658eeb28bddbbf6e4f7a5554f5d7
7
+ data.tar.gz: 179957657ec3307c7462551f88acbbe7c08297ce9fff9bf769528a3b1ce89c53aaa8bf04daeaf458fd785134b04d57278a1af8da57987f7f6e883f0580d4e1fb
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ # 0
2
+ ## 0.1
3
+ ### 0.1.1
4
+ Allowed for gem pushes
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in popart.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ popart (0.1.1)
5
+ parallel
6
+ selenium-webdriver
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ childprocess (0.6.2)
12
+ ffi (~> 1.0, >= 1.0.11)
13
+ diff-lcs (1.3)
14
+ ffi (1.9.17)
15
+ parallel (1.10.0)
16
+ rake (10.5.0)
17
+ rspec (3.5.0)
18
+ rspec-core (~> 3.5.0)
19
+ rspec-expectations (~> 3.5.0)
20
+ rspec-mocks (~> 3.5.0)
21
+ rspec-core (3.5.4)
22
+ rspec-support (~> 3.5.0)
23
+ rspec-expectations (3.5.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.5.0)
26
+ rspec-mocks (3.5.0)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.5.0)
29
+ rspec-support (3.5.0)
30
+ rubyzip (1.2.1)
31
+ selenium-webdriver (3.2.1)
32
+ childprocess (~> 0.5)
33
+ rubyzip (~> 1.0)
34
+ websocket (~> 1.0)
35
+ websocket (1.2.4)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ bundler (~> 1.10)
42
+ popart!
43
+ rake (~> 10.0)
44
+ rspec
45
+
46
+ BUNDLED WITH
47
+ 1.14.3
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Dylan Lacey
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Popart
2
+
3
+ Use Sauce Labs to generate screenshots for your site across a range of browsers.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'popart'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install popart
20
+
21
+ ## Usage
22
+
23
+ Currently, Popart only supports screenshots of a single page directly accessible by URL (with or without Sauce Connect).
24
+
25
+ To use Popart, install it (as above) then
26
+
27
+ `popart url_to_screenshot`.
28
+
29
+ This will cause Popart to take a shot with the default browsers (Chrome and Firefox Latest on Windows 10) and save them to `./screenshots`.
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ 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).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/popart. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
40
+
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 "popart"
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/popart ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ require "popart"
3
+
4
+ config = Popart::Config.new
5
+ config.initial_config
6
+
7
+ browsers = config.browsers.map { |b| Popart::Browser.new b }
8
+
9
+ STDOUT.puts "Fetching screenshots of #{config.site} and writing them to #{config.output_directory}"
10
+
11
+ screenshots = browsers.map do |browser|
12
+ screenshot = browser.perform do |session|
13
+ session.navigate.to config.site
14
+ session.screenshot_as :png
15
+ end
16
+
17
+ filename = browser.capabilities[:browserName] + '_' + browser.capabilities[:version] + '_' + browser.capabilities[:platform] + '.png'
18
+ filename.gsub! " ", "-"
19
+
20
+ File.open((File.join config.output_directory, filename), 'w') do |file|
21
+ file.write screenshot
22
+ end
23
+ end
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,19 @@
1
+ require_relative "selenium_session"
2
+
3
+ module Popart
4
+ class Browser
5
+ attr_reader :capabilities
6
+
7
+ def initialize capabilities
8
+ @capabilities = capabilities
9
+ end
10
+
11
+ def perform &block
12
+ unless @browser
13
+ @browser = SeleniumSession.new capabilities
14
+
15
+ yield @browser
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,63 @@
1
+ require "pathname"
2
+
3
+ module Popart
4
+ class Config
5
+
6
+ attr_accessor :browsers, :output_directory, :site
7
+
8
+ def default_browsers
9
+ [
10
+ {:browserName => 'Chrome', :platform => "Windows 10", :version => "latest"},
11
+ {:browserName => 'Firefox', :platform => "Windows 10", :version => "latest"}
12
+ ]
13
+ end
14
+
15
+ def default_output_directory
16
+ './screenshots'
17
+ end
18
+
19
+ def initial_config
20
+ fn = ARGV[1] ||= './config.json'
21
+ path = Pathname.new fn
22
+
23
+ load_from_file path if path.exist?
24
+
25
+ set_defaults
26
+ end
27
+
28
+ def load_from_file filename
29
+ config_hash = YAML.parse filename
30
+
31
+ @browsers = [config_hash[:browsers]].flatten
32
+ @output_directory = config_hash[:output_directory]
33
+ @site = config_hash[:site]
34
+ end
35
+
36
+ def set_defaults
37
+ @browsers ||= default_browsers
38
+ @output_directory ||= default_output_directory
39
+ set_site(@site ||= ARGV[0])
40
+
41
+ @output_directory = Pathname.new @output_directory
42
+
43
+ verify_output_directory
44
+ end
45
+
46
+ def set_site site
47
+ unless site
48
+ STDERR.puts "You must provide a site to screenshot."
49
+ exit
50
+ end
51
+
52
+ @site = URI site
53
+ end
54
+
55
+
56
+ def verify_output_directory
57
+ unless @output_directory.exist?
58
+ STDERR.puts "#{@output_directory} doesn't seem to exist; creating it."
59
+ Dir.mkdir @output_directory
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,54 @@
1
+ require "selenium-webdriver"
2
+
3
+ module Popart
4
+ class SeleniumSession
5
+
6
+ attr_reader :driver
7
+
8
+ def un
9
+ ENV["SAUCE_USERNAME"]
10
+ end
11
+
12
+ def pw
13
+ ENV["SAUCE_ACCESS_KEY"]
14
+ end
15
+
16
+ def auth
17
+ "#{un}:#{pw}"
18
+ end
19
+
20
+ def server
21
+ "ondemand.saucelabs.com"
22
+ end
23
+
24
+ def port
25
+ 80
26
+ end
27
+
28
+ def endpoint
29
+ "http://#{auth}@#{server}:#{port}/wd/hub"
30
+ end
31
+
32
+ def initialize desired_capabilities
33
+ @driver = Selenium::WebDriver.for :remote, :url => endpoint, :desired_capabilities => desired_capabilities
34
+
35
+ at_exit do
36
+ if @driver
37
+ begin
38
+ @driver.quit
39
+ rescue
40
+ #Not relevant anymore
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ def method_missing m, *args
47
+ if !args.empty?
48
+ @driver.send(m, *args)
49
+ else
50
+ @driver.send(m)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,3 @@
1
+ module Popart
2
+ VERSION = "0.1.1"
3
+ end
data/lib/popart.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "popart/version"
2
+ require "popart/config"
3
+ require "popart/browser"
4
+
5
+ module Popart
6
+
7
+ end
data/popart.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'popart/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "popart"
8
+ spec.version = Popart::VERSION
9
+ spec.authors = ["Dylan Lacey"]
10
+ spec.email = ["github@dylanlacey.com"]
11
+
12
+ spec.summary = %q{Check what your site looks like in multiple browsers.}
13
+ spec.description = %q{Popart shows you what your site looks like, rendered in
14
+ a bunch of browsers. Make your own piece of modern art, powered by Ruby,
15
+ sharing and the letter L. Also Sauce Labs.}
16
+ spec.homepage = "http://www.github.com/dylanlacey/popart"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+
27
+ spec.add_dependency "parallel"
28
+ spec.add_dependency "selenium-webdriver"
29
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: popart
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Dylan Lacey
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-03-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: parallel
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: selenium-webdriver
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: |-
84
+ Popart shows you what your site looks like, rendered in
85
+ a bunch of browsers. Make your own piece of modern art, powered by Ruby,
86
+ sharing and the letter L. Also Sauce Labs.
87
+ email:
88
+ - github@dylanlacey.com
89
+ executables: []
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - ".gitignore"
94
+ - ".rspec"
95
+ - CHANGELOG.md
96
+ - CODE_OF_CONDUCT.md
97
+ - Gemfile
98
+ - Gemfile.lock
99
+ - LICENSE
100
+ - README.md
101
+ - Rakefile
102
+ - bin/console
103
+ - bin/popart
104
+ - bin/setup
105
+ - lib/popart.rb
106
+ - lib/popart/browser.rb
107
+ - lib/popart/config.rb
108
+ - lib/popart/selenium_session.rb
109
+ - lib/popart/version.rb
110
+ - popart.gemspec
111
+ homepage: http://www.github.com/dylanlacey/popart
112
+ licenses: []
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.6.10
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Check what your site looks like in multiple browsers.
134
+ test_files: []