hollandaise 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ index.html
19
+ screenshots/
20
+ .DS_Store
21
+ chromedriver.log
22
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hollandaise.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 John Bintz
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Hollandaise sauce is a delicious delicacy.
2
+
3
+ TODO: Easily take a bunch of screenshots using Sauce Labs or with your local browsers
4
+ FIXME: The method for instantiating Sauce Labs Selenium WebDriver browsers
5
+ TODO: Run all the screenshot taking in parallel for SPEEDS
6
+ BUG: Find them and destroy them!
7
+
8
+ ## Preparation and Serving
9
+
10
+ * `gem install hollandaise`
11
+ * Create a ~/.sauce/ondemand.yml with:
12
+
13
+ username: my-sauce-labs-username
14
+ access_key: my-secret-access-key
15
+
16
+ * `hollandaise sauce http://my.cool.website/url/to/test/ browser browser ...`
17
+
18
+ Browsers! Locally, using Selenium:
19
+
20
+ * `firefox`
21
+ * `chrome`
22
+
23
+ On Sauce labs:
24
+
25
+ * `ie7`
26
+ * `ie8`
27
+ * `ie9`
28
+ * `chromewin`
29
+ * `ffwin10`
30
+
31
+ ### Projects
32
+
33
+ `hollandaise project NAME` creates a new `hollandaise.rb` file. Fill it in with your project details.
34
+ `hollandaise cook` runs that project, making appropriately-named directories. Sweet!
35
+
36
+ ## Adding your own ingredients
37
+
38
+ 1. Fork it
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create new Pull Request
43
+ 6. Be *awesome*.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/hollandaise ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thor'
4
+ require 'builder'
5
+
6
+ $: << File.expand_path('../../lib', __FILE__)
7
+
8
+ require 'hollandaise'
9
+ require 'hollandaise/cli'
10
+
11
+ begin
12
+ load File.join(Dir.pwd, 'hollandaise.rb')
13
+ rescue LoadError => e
14
+ end
15
+
16
+ Hollandaise::CLI.start
17
+
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/hollandaise/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["John Bintz"]
6
+ gem.email = ["john@coswellproductions.com"]
7
+ gem.description = %q{Get delicious screenshots from Sauce Labs, easily}
8
+ gem.summary = %q{Get delicious screenshots from Sauce Labs, easily}
9
+ gem.homepage = ""
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "hollandaise"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Hollandaise::VERSION
17
+
18
+ gem.add_dependency 'sauce'
19
+ gem.add_dependency 'capybara'
20
+ gem.add_dependency 'thor'
21
+ gem.add_dependency 'arbre'
22
+ end
23
+
data/hollandaise.rb ADDED
@@ -0,0 +1,9 @@
1
+ Hollandaise.project "cats" do |p|
2
+ p.root 'http://my.site/'
3
+
4
+ p.screenshot 'Home', '/'
5
+ p.screenshot 'Archive', '/archive'
6
+
7
+ p.browsers :chrome
8
+ end
9
+
@@ -0,0 +1,41 @@
1
+ require "hollandaise/version"
2
+ require 'hollandaise/browsers'
3
+ require 'hollandaise/project'
4
+ require 'hollandaise/browser'
5
+
6
+ module Hollandaise
7
+ class << self
8
+ attr_accessor :url, :browsers, :delay
9
+ end
10
+
11
+ def self.configure
12
+ yield self
13
+ end
14
+
15
+ def self.project(name)
16
+ project = Project.new(name)
17
+ projects << project
18
+
19
+ yield project
20
+
21
+ project
22
+ end
23
+
24
+ def self.dir
25
+ @dir ||= Pathname("screenshots")
26
+ end
27
+
28
+ def self.chdir(name)
29
+ _odir = dir.clone
30
+ @dir = @dir.join(name)
31
+
32
+ yield
33
+
34
+ @dir = _odir
35
+ end
36
+
37
+ def self.projects
38
+ @projects ||= []
39
+ end
40
+ end
41
+
@@ -0,0 +1,19 @@
1
+ require 'hollandaise/browser/base'
2
+ require 'hollandaise/browser/sauce'
3
+ require 'hollandaise/browser/selenium'
4
+
5
+ module Hollandaise
6
+ module Browser
7
+ def self.for(browser, options)
8
+ browser = browser.dup
9
+
10
+ case browser.shift
11
+ when :sauce
12
+ Hollandaise::Browser::Sauce.new(*browser, options)
13
+ when :selenium
14
+ Hollandaise::Browser::Selenium.new(*browser, options)
15
+ end
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,33 @@
1
+ module Hollandaise
2
+ module Browser
3
+ class Base
4
+ attr_reader :browser
5
+
6
+ def run_and_take_screenshot(url)
7
+ @url = url
8
+
9
+ selenium.navigate.to url
10
+ sleep @options[:delay].to_i
11
+ selenium.execute_script %{window.resizeTo(1280, 1024)}
12
+ take_screenshot
13
+ end
14
+
15
+ def take_screenshot
16
+ target.parent.mkpath
17
+
18
+ selenium.save_screenshot(target.to_s)
19
+ end
20
+
21
+ def close
22
+ selenium.quit
23
+
24
+ @selenium = nil
25
+ end
26
+
27
+ def dir
28
+ Hollandaise.dir
29
+ end
30
+ end
31
+ end
32
+ end
33
+
@@ -0,0 +1,31 @@
1
+ module Hollandaise
2
+ module Browser
3
+ class Sauce < Base
4
+ def initialize(browser, version, os, options)
5
+ @browser, @version, @os, @options = browser, version, os, options
6
+ end
7
+
8
+ def selenium
9
+ require 'sauce'
10
+ require 'sauce/selenium'
11
+
12
+ @selenium ||= ::Sauce::Selenium2.new(info)
13
+ end
14
+
15
+ def target
16
+ dir.join(@os.to_s).join("#{@browser} #{@version}.png")
17
+ end
18
+
19
+ def info
20
+ {
21
+ :browser => @browser,
22
+ :browser_version => @version,
23
+ :os => @os,
24
+ :browser_url => @url,
25
+ :job_name => "#{@url}"
26
+ }
27
+ end
28
+ end
29
+ end
30
+ end
31
+
@@ -0,0 +1,20 @@
1
+ module Hollandaise
2
+ module Browser
3
+ class Selenium < Base
4
+ def initialize(browser, options)
5
+ @browser, @options = browser, options
6
+ end
7
+
8
+ def selenium
9
+ require 'selenium/webdriver'
10
+
11
+ @selenium ||= ::Selenium::WebDriver.for(@browser)
12
+ end
13
+
14
+ def target
15
+ dir.join("#{@browser}.png")
16
+ end
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,53 @@
1
+ module Hollandaise
2
+ class Browsers
3
+ def self.for(browsers, options = {})
4
+ new(browsers.flatten.collect { |browser| Hollandaise::Browser.for(self.send(browser), options) })
5
+ end
6
+
7
+ def self.ie7
8
+ [ :sauce, 'iexplore', '7', 'Windows 2003' ]
9
+ end
10
+
11
+ def self.ie8
12
+ [ :sauce, 'iexplore', '8', 'Windows 2003' ]
13
+ end
14
+
15
+ def self.ie9
16
+ [ :sauce, 'iexplore', '9', 'Windows 2008' ]
17
+ end
18
+
19
+ def self.ffwin10
20
+ [ :sauce, 'firefox', '10', 'Windows 2008' ]
21
+ end
22
+
23
+ def self.chromewin
24
+ [ :sauce, 'chrome', '', 'Windows 2008' ]
25
+ end
26
+
27
+ def self.firefox
28
+ [ :selenium, :firefox ]
29
+ end
30
+
31
+ def self.chrome
32
+ [ :selenium, :chrome ]
33
+ end
34
+
35
+ def initialize(browsers)
36
+ @browsers = browsers
37
+ end
38
+
39
+ def each(&block)
40
+ @browsers.each(&block)
41
+ end
42
+
43
+ def run
44
+ @browsers.each do |browser|
45
+ begin
46
+ yield browser
47
+ ensure
48
+ browser.close
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,73 @@
1
+ require 'arbre'
2
+ require 'pathname'
3
+
4
+ module Hollandaise
5
+ class CLI < Thor
6
+ include Thor::Actions
7
+ source_root File.expand_path('../../../skel', __FILE__)
8
+
9
+ desc "cook", "Use the config file and take all the screenshots listed in there"
10
+ def cook
11
+ Hollandaise.projects.each(&:run)
12
+ end
13
+
14
+ desc "project NAME", "Create a skeletal project file"
15
+ def project(name)
16
+ @name = name
17
+
18
+ template 'hollandaise.rb.tt', 'hollandaise.rb'
19
+ end
20
+
21
+ desc "sauce URL BROWSER BROWSER...", "Take screenshots of a URL on Sauce Labs"
22
+ method_options :delay => 0
23
+ def sauce(*browsers)
24
+ if browsers.first && browsers.first[%r{^http}]
25
+ url = browsers.shift
26
+ else
27
+ url = Hollandaise.url
28
+ end
29
+
30
+ if Hollandaise.browsers && browsers.empty?
31
+ browsers = Hollandaise.browsers
32
+ end
33
+
34
+ browser_objects = Hollandaise::Browsers.for(browsers, options)
35
+
36
+ browser_objects.run do |browser|
37
+ browser.run_and_take_screenshot(url)
38
+ end
39
+
40
+ html = Arbre::Context.new do
41
+ html do
42
+ head do
43
+ title "Sauce Labs screenshots for #{url}"
44
+ end
45
+
46
+ body do
47
+ table do
48
+ thead do
49
+ tr do
50
+ browser_objects.each do |browser|
51
+ th browser.browser
52
+ end
53
+ end
54
+ end
55
+
56
+ tbody do
57
+ browser_objects.each do |browser|
58
+ td(:valign => :top) do
59
+ img(:src => browser.target)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ File.open('index.html', 'wb') { |fh| fh.print html.to_s }
69
+ end
70
+
71
+ default_task :sauce
72
+ end
73
+ end
@@ -0,0 +1,45 @@
1
+ require 'uri'
2
+
3
+ module Hollandaise
4
+ class Project
5
+ def initialize(project_name)
6
+ @project_name = project_name
7
+ end
8
+
9
+ def root(root)
10
+ @root = URI(root)
11
+ end
12
+
13
+ def screenshot(name, uri)
14
+ @screenshots ||= []
15
+
16
+ @screenshots << [ name, uri ]
17
+ end
18
+
19
+ def browsers(*browsers)
20
+ @browsers = browsers
21
+ end
22
+
23
+ def run
24
+ urls.each do |url, name|
25
+ Hollandaise.chdir "#{@project_name}/#{name}" do
26
+ browser_objects.run do |browser|
27
+ browser.run_and_take_screenshot(url)
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ private
34
+ def urls
35
+ @screenshots.collect do |name, uri|
36
+ [ @root.merge(URI(uri)), name ]
37
+ end
38
+ end
39
+
40
+ def browser_objects
41
+ @browser_objects ||= Hollandaise::Browsers.for(@browsers)
42
+ end
43
+ end
44
+ end
45
+
@@ -0,0 +1,3 @@
1
+ module Hollandaise
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,9 @@
1
+ Hollandaise.project "<%= @name %>" do |p|
2
+ p.root 'http://my.site/'
3
+
4
+ p.screenshot 'Home', '/'
5
+ p.screenshot 'Archive', '/archive'
6
+
7
+ p.browsers :chrome
8
+ end
9
+
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hollandaise
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - John Bintz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sauce
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
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: capybara
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: thor
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
+ - !ruby/object:Gem::Dependency
63
+ name: arbre
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Get delicious screenshots from Sauce Labs, easily
79
+ email:
80
+ - john@coswellproductions.com
81
+ executables:
82
+ - hollandaise
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - .gitignore
87
+ - Gemfile
88
+ - LICENSE
89
+ - README.md
90
+ - Rakefile
91
+ - bin/hollandaise
92
+ - hollandaise.gemspec
93
+ - hollandaise.rb
94
+ - lib/hollandaise.rb
95
+ - lib/hollandaise/browser.rb
96
+ - lib/hollandaise/browser/base.rb
97
+ - lib/hollandaise/browser/sauce.rb
98
+ - lib/hollandaise/browser/selenium.rb
99
+ - lib/hollandaise/browsers.rb
100
+ - lib/hollandaise/cli.rb
101
+ - lib/hollandaise/project.rb
102
+ - lib/hollandaise/version.rb
103
+ - skel/hollandaise.rb.tt
104
+ homepage: ''
105
+ licenses: []
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 1.8.23
125
+ signing_key:
126
+ specification_version: 3
127
+ summary: Get delicious screenshots from Sauce Labs, easily
128
+ test_files: []
129
+ has_rdoc: