Compare commits
No commits in common. "master" and "cleanup" have entirely different histories.
@ -28,10 +28,7 @@ On Sauce labs:
|
||||
* `chromewin`
|
||||
* `ffwin10`
|
||||
|
||||
### Projects
|
||||
|
||||
`hollandaise project NAME` creates a new `hollandaise.rb` file. Fill it in with your project details.
|
||||
`hollandaise cook` runs that project, making appropriately-named directories. Sweet!
|
||||
Make more on the `Hollandaise::Browsers` module! All sorts of flavors!
|
||||
|
||||
## Adding your own ingredients
|
||||
|
||||
|
@ -8,7 +8,10 @@ $: << File.expand_path('../../lib', __FILE__)
|
||||
require 'hollandaise'
|
||||
require 'hollandaise/cli'
|
||||
|
||||
Hollandaise.load_config!
|
||||
begin
|
||||
load File.join(Dir.pwd, 'hollandaise.rb')
|
||||
rescue LoadError => e
|
||||
end
|
||||
|
||||
Hollandaise::CLI.start
|
||||
|
||||
|
@ -19,7 +19,5 @@ Gem::Specification.new do |gem|
|
||||
gem.add_dependency 'capybara'
|
||||
gem.add_dependency 'thor'
|
||||
gem.add_dependency 'arbre'
|
||||
gem.add_dependency 'rainbow'
|
||||
gem.add_dependency 'rack-proxy'
|
||||
end
|
||||
|
||||
|
@ -3,8 +3,6 @@ require 'hollandaise/browsers'
|
||||
require 'hollandaise/project'
|
||||
require 'hollandaise/browser'
|
||||
|
||||
require 'hollandaise/railtie' if defined?(Rails::Railtie)
|
||||
|
||||
module Hollandaise
|
||||
class << self
|
||||
attr_accessor :url, :browsers, :delay
|
||||
@ -14,17 +12,6 @@ module Hollandaise
|
||||
yield self
|
||||
end
|
||||
|
||||
def self.load_config!
|
||||
begin
|
||||
load File.join(Dir.pwd, 'hollandaise.rb')
|
||||
rescue LoadError => e
|
||||
begin
|
||||
load File.join(Dir.pwd, 'config/hollandaise.rb')
|
||||
rescue LoadError => e
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.project(name)
|
||||
project = Project.new(name)
|
||||
projects << project
|
||||
|
@ -3,12 +3,12 @@ module Hollandaise
|
||||
class Base
|
||||
attr_reader :browser
|
||||
|
||||
def run_and_take_screenshot(url, screen_size = [ 1280, 1024 ])
|
||||
def run_and_take_screenshot(url)
|
||||
@url = url
|
||||
|
||||
selenium.navigate.to url
|
||||
sleep @options[:delay].to_i
|
||||
selenium.manage.window.resize_to(*screen_size)
|
||||
selenium.execute_script %{window.resizeTo(1280, 1024)}
|
||||
take_screenshot
|
||||
end
|
||||
|
||||
|
@ -12,30 +12,8 @@ module Hollandaise
|
||||
@selenium ||= ::Sauce::Selenium2.new(info)
|
||||
end
|
||||
|
||||
def run_and_take_screenshot(url, *args)
|
||||
self.class.start_tunnel if URI(url).host == 'localhost'
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
def self.start_tunnel
|
||||
return @tunnel if @tunnel
|
||||
|
||||
@tunnel = ::Sauce::Connect.new
|
||||
@tunnel.connect
|
||||
@tunnel.wait_until_ready
|
||||
|
||||
at_exit do
|
||||
@tunnel.disconnect
|
||||
end
|
||||
end
|
||||
|
||||
def target
|
||||
dir.join(@os.to_s).join("#{@browser} #{@version || 'latest'}.png")
|
||||
end
|
||||
|
||||
def name
|
||||
"#{@browser} #{@version} #{@os}"
|
||||
dir.join(@os.to_s).join("#{@browser} #{@version}.png")
|
||||
end
|
||||
|
||||
def info
|
||||
|
@ -11,10 +11,6 @@ module Hollandaise
|
||||
@selenium ||= ::Selenium::WebDriver.for(@browser)
|
||||
end
|
||||
|
||||
def name
|
||||
@browser
|
||||
end
|
||||
|
||||
def target
|
||||
dir.join("#{@browser}.png")
|
||||
end
|
||||
|
@ -1,7 +1,4 @@
|
||||
require 'uri'
|
||||
require 'rainbow'
|
||||
require 'rack/proxy'
|
||||
require 'base64'
|
||||
|
||||
module Hollandaise
|
||||
class Project
|
||||
@ -10,51 +7,7 @@ module Hollandaise
|
||||
end
|
||||
|
||||
def root(root)
|
||||
@root = root
|
||||
end
|
||||
|
||||
def port
|
||||
32516
|
||||
end
|
||||
|
||||
def proxy_root(root)
|
||||
uri = URI(root)
|
||||
|
||||
@userinfo = uri.userinfo
|
||||
@host = uri.host
|
||||
@port = uri.port
|
||||
|
||||
@root = "http://localhost:#{port}#{uri.path}"
|
||||
end
|
||||
|
||||
def with_proxy
|
||||
if !@host
|
||||
yield
|
||||
else
|
||||
proxy = Class.new(Rack::Proxy) do
|
||||
def initialize(userinfo, host, port)
|
||||
@userinfo, @host, @port = userinfo, host, port
|
||||
end
|
||||
|
||||
def rewrite_env(env)
|
||||
env['HTTP_HOST'] = @host
|
||||
env['SERVER_PORT'] = @port
|
||||
env['HTTP_AUTHORIZATION'] = "Basic #{Base64.encode64(@userinfo)}"
|
||||
|
||||
env
|
||||
end
|
||||
end
|
||||
|
||||
server = Thread.new do
|
||||
Rack::Handler.default.run(proxy.new(@userinfo, @host, @port), :Port => port) do |server|
|
||||
Thread.current[:server] = server
|
||||
end
|
||||
end
|
||||
|
||||
yield
|
||||
|
||||
server[:server].stop
|
||||
end
|
||||
@root = URI(root)
|
||||
end
|
||||
|
||||
def screenshot(name, uri)
|
||||
@ -67,21 +20,11 @@ module Hollandaise
|
||||
@browsers = browsers
|
||||
end
|
||||
|
||||
def screen_size(size)
|
||||
@screen_size = size.split('x').collect(&:to_i)
|
||||
end
|
||||
|
||||
def run
|
||||
puts "Running #{@project_name}".foreground(:green)
|
||||
with_proxy do
|
||||
urls.each do |url, name|
|
||||
puts "... #{name} (#{url})".foreground(:yellow)
|
||||
|
||||
Hollandaise.chdir "#{@project_name}/#{name}" do
|
||||
browser_objects.run do |browser|
|
||||
puts " ... #{browser.name}".foreground(:white)
|
||||
browser.run_and_take_screenshot(url, @screen_size)
|
||||
end
|
||||
urls.each do |url, name|
|
||||
Hollandaise.chdir "#{@project_name}/#{name}" do
|
||||
browser_objects.run do |browser|
|
||||
browser.run_and_take_screenshot(url)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -90,7 +33,7 @@ module Hollandaise
|
||||
private
|
||||
def urls
|
||||
@screenshots.collect do |name, uri|
|
||||
[ File.join(@root, uri), name ]
|
||||
[ @root.merge(URI(uri)), name ]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
module Hollandaise
|
||||
class Railtie < ::Rails::Railtie
|
||||
rake_tasks do
|
||||
desc "Take screenshots from Hollandaise configuration"
|
||||
task :take_screenshots do
|
||||
Hollandaise.load_config!
|
||||
|
||||
Hollandaise.projects.each(&:run)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,3 +1,3 @@
|
||||
module Hollandaise
|
||||
VERSION = "0.1.1"
|
||||
VERSION = "0.0.1"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user