initial yummy commit
This commit is contained in:
commit
823d7b8ab4
|
@ -0,0 +1,20 @@
|
||||||
|
*.gem
|
||||||
|
*.rbc
|
||||||
|
.bundle
|
||||||
|
.config
|
||||||
|
.yardoc
|
||||||
|
Gemfile.lock
|
||||||
|
InstalledFiles
|
||||||
|
_yardoc
|
||||||
|
coverage
|
||||||
|
doc/
|
||||||
|
lib/bundler/man
|
||||||
|
pkg
|
||||||
|
rdoc
|
||||||
|
spec/reports
|
||||||
|
test/tmp
|
||||||
|
test/version_tmp
|
||||||
|
tmp
|
||||||
|
index.html
|
||||||
|
screenshots/
|
||||||
|
.DS_Store
|
|
@ -0,0 +1,4 @@
|
||||||
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
|
# Specify your gem's dependencies in hollandaise.gemspec
|
||||||
|
gemspec
|
|
@ -0,0 +1,22 @@
|
||||||
|
Copyright (c) 2012 John Bintz
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,33 @@
|
||||||
|
# Hollandaise sauce is a delicious delicacy.
|
||||||
|
|
||||||
|
TODO: Easily take a bunch of screenshots using Sauce Labs
|
||||||
|
FIXME: The method for instantiating Sauce Labs Selenium WebDriver browsers
|
||||||
|
TODO: Run all the screenshot taking in parallel for SPEEDS
|
||||||
|
BUG: Find them and destroy them!
|
||||||
|
|
||||||
|
## Preparation and Serving
|
||||||
|
|
||||||
|
* `gem install hollandaise`
|
||||||
|
* Create a ~/.sauce/ondemand.yml with:
|
||||||
|
|
||||||
|
username: my-sauce-labs-username
|
||||||
|
access_key: my-secret-access-key
|
||||||
|
|
||||||
|
* `hollandaise sauce http://my.cool.website/url/to/test/ browser browser ...`
|
||||||
|
|
||||||
|
Currently have three browsers available:
|
||||||
|
|
||||||
|
* `ie7`
|
||||||
|
* `ie8`
|
||||||
|
* `ie9`
|
||||||
|
|
||||||
|
Make more on the `Hollandaise::Browsers` module! All sorts of flavors!
|
||||||
|
|
||||||
|
## Adding your own ingredients
|
||||||
|
|
||||||
|
1. Fork it
|
||||||
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
||||||
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
||||||
|
4. Push to the branch (`git push origin my-new-feature`)
|
||||||
|
5. Create new Pull Request
|
||||||
|
6. Be *awesome*.
|
|
@ -0,0 +1,114 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require 'thor'
|
||||||
|
require 'sauce'
|
||||||
|
require 'thread'
|
||||||
|
require 'builder'
|
||||||
|
|
||||||
|
module Hollandaise
|
||||||
|
module Browsers
|
||||||
|
class << self
|
||||||
|
def for(browsers)
|
||||||
|
browsers.collect { |browser| self.send(browser) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def ie7
|
||||||
|
[ 'iexplore', '7', 'Windows 2003' ]
|
||||||
|
end
|
||||||
|
|
||||||
|
def ie8
|
||||||
|
[ 'iexplore', '8', 'Windows 2003' ]
|
||||||
|
end
|
||||||
|
|
||||||
|
def ie9
|
||||||
|
[ 'iexplore', '9', 'Windows 2008' ]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Hollandaise::CLI < Thor
|
||||||
|
desc "sauce URL BROWSER BROWSER...", "Take screenshots of a URL on Sauce Labs"
|
||||||
|
def sauce(url, *browsers)
|
||||||
|
threads = []
|
||||||
|
|
||||||
|
FileUtils.rm_rf(dir) if File.directory?(dir)
|
||||||
|
FileUtils.mkdir_p(dir)
|
||||||
|
|
||||||
|
mutex = Mutex.new
|
||||||
|
|
||||||
|
Hollandaise::Browsers.for(browsers).each do |browser|
|
||||||
|
info = { :browser_url => url, :job_name => "#{url}" }
|
||||||
|
[ :browser, :browser_version, :os ].each_with_index { |key, index| info[key] = browser[index] }
|
||||||
|
|
||||||
|
thread = Thread.new do
|
||||||
|
selenium = nil
|
||||||
|
|
||||||
|
Thread.stop if Thread.current == self
|
||||||
|
|
||||||
|
begin
|
||||||
|
target = screenshot_target_for(Thread.current[:browser])
|
||||||
|
FileUtils.mkdir_p(File.dirname(target))
|
||||||
|
|
||||||
|
mutex.synchronize { puts "#{target}..." }
|
||||||
|
|
||||||
|
selenium = Sauce::Selenium2.new(Thread.current[:info])
|
||||||
|
selenium.navigate.to url
|
||||||
|
selenium.execute_script %{window.resizeTo(1280, 1024)}
|
||||||
|
selenium.save_screenshot(target)
|
||||||
|
|
||||||
|
mutex.synchronize { puts "#{target} done!" }
|
||||||
|
ensure
|
||||||
|
selenium.stop if selenium
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
thread[:info] = info
|
||||||
|
thread[:browser] = browser
|
||||||
|
thread.run
|
||||||
|
threads << thread
|
||||||
|
end
|
||||||
|
|
||||||
|
threads.each(&:join)
|
||||||
|
|
||||||
|
html = Builder::XmlMarkup.new
|
||||||
|
html.html {
|
||||||
|
html.head {
|
||||||
|
html.title { "Sauce Labs screenshots for #{url}" }
|
||||||
|
}
|
||||||
|
|
||||||
|
html.body {
|
||||||
|
html.table {
|
||||||
|
html.tr {
|
||||||
|
browsers.each { |browser| html.th(browser) }
|
||||||
|
}
|
||||||
|
|
||||||
|
html.tr {
|
||||||
|
Hollandaise::Browsers.for(browsers).each { |browser|
|
||||||
|
html.td(:valign => 'top') {
|
||||||
|
html.img(:src => screenshot_target_for(browser))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File.open('index.html', 'wb') { |fh| fh.print html.to_s }
|
||||||
|
end
|
||||||
|
|
||||||
|
default_task :snapshot
|
||||||
|
|
||||||
|
no_tasks do
|
||||||
|
def dir
|
||||||
|
"screenshots"
|
||||||
|
end
|
||||||
|
|
||||||
|
def screenshot_target_for(browser)
|
||||||
|
File.join(dir, browser[2], "#{browser[0]} #{browser[1]}.png")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Hollandaise::CLI.start
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
require File.expand_path('../lib/hollandaise/version', __FILE__)
|
||||||
|
|
||||||
|
Gem::Specification.new do |gem|
|
||||||
|
gem.authors = ["John Bintz"]
|
||||||
|
gem.email = ["john@coswellproductions.com"]
|
||||||
|
gem.description = %q{TODO: Write a gem description}
|
||||||
|
gem.summary = %q{TODO: Write a gem summary}
|
||||||
|
gem.homepage = ""
|
||||||
|
|
||||||
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
||||||
|
gem.files = `git ls-files`.split("\n")
|
||||||
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
||||||
|
gem.name = "hollandaise"
|
||||||
|
gem.require_paths = ["lib"]
|
||||||
|
gem.version = Hollandaise::VERSION
|
||||||
|
|
||||||
|
gem.add_dependency 'sauce'
|
||||||
|
gem.add_dependency 'capybara'
|
||||||
|
gem.add_dependency 'thor'
|
||||||
|
gem.add_dependency 'builder'
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
require "hollandaise/version"
|
||||||
|
|
||||||
|
module Hollandaise
|
||||||
|
# Your code goes here...
|
||||||
|
end
|
|
@ -0,0 +1,3 @@
|
||||||
|
module Hollandaise
|
||||||
|
VERSION = "0.0.1"
|
||||||
|
end
|
Loading…
Reference in New Issue