autobrewster 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/autobrewster +5 -0
  2. data/lib/auto_brewster.rb +87 -0
  3. metadata +100 -0
data/bin/autobrewster ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'auto_brewster'
4
+
5
+ AutoBrewster::CLI.new(ARGV.dup).execute!
@@ -0,0 +1,87 @@
1
+ require File.expand_path('../auto_brewster/server', __FILE__)
2
+ require File.expand_path('../auto_brewster/screenshot', __FILE__)
3
+ require File.expand_path('../auto_brewster/cli', __FILE__)
4
+
5
+ module AutoBrewster
6
+ class << self
7
+ attr_accessor :server, :server_start, :server_port, :rackup_path, :hostname
8
+ attr_accessor :screen_widths, :url_paths
9
+ attr_accessor :path
10
+ attr_accessor :failfast
11
+
12
+ def configure
13
+ yield self
14
+ end
15
+
16
+ def setup
17
+ include_support
18
+ @server = AutoBrewster::Server.new(server, server_port, rackup_path, hostname)
19
+ @screenshot = AutoBrewster::Screenshot.new(@server, path, url_paths, screen_widths)
20
+ end
21
+
22
+ def compare_screens
23
+ setup
24
+ @screenshot.clear_compare_screens
25
+ start_test_server
26
+ @screenshot.capture(:compare)
27
+ @screenshot.compare_captured_screens
28
+ end
29
+
30
+ def clear_source_screens
31
+ setup
32
+ @screenshot.clear_source_screens
33
+ end
34
+
35
+ def start_test_server
36
+ return unless AutoBrewster.server_start
37
+ @server.start
38
+ end
39
+
40
+ def generate_source_screens
41
+ setup
42
+ start_test_server
43
+ @screenshot.capture(:source)
44
+ end
45
+
46
+ def server(&block)
47
+ if block_given?
48
+ @server = block
49
+ else
50
+ @server
51
+ end
52
+ end
53
+
54
+ def run_default_server(app, port)
55
+ require 'rack/handler/thin'
56
+ Thin::Logging.silent = true
57
+ Rack::Handler::Thin.run(app, :Port => port, :AccessLog => [])
58
+ end
59
+
60
+ private
61
+ def include_support
62
+ include_support_env
63
+ Dir.glob("#{path}/support/*.rb").map do |file|
64
+ require file unless file.end_with?('/env.rb')
65
+ end
66
+ end
67
+
68
+ def include_support_env
69
+ env_path = "#{path}/support/env.rb"
70
+ require env_path if File.exists?(env_path)
71
+ end
72
+ end
73
+ end
74
+
75
+ AutoBrewster.configure do |config|
76
+ config.server_start = true
77
+ config.server_port = 5001
78
+ config.path = "#{Dir.pwd}/test/brewster"
79
+ config.rackup_path = 'config.ru'
80
+ config.server {|app, port| AutoBrewster.run_default_server(app, port)}
81
+ config.hostname = false
82
+ config.failfast = false
83
+ config.screen_widths = [320, 1024]
84
+ config.url_paths = {
85
+ :home => '/'
86
+ }
87
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: autobrewster
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Chris Blackburn
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2013-08-24 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: thin
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: rspec
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 2
41
+ - 0
42
+ version: "2.0"
43
+ type: :development
44
+ version_requirements: *id002
45
+ - !ruby/object:Gem::Dependency
46
+ name: sinatra
47
+ prerelease: false
48
+ requirement: &id003 !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ~>
51
+ - !ruby/object:Gem::Version
52
+ segments:
53
+ - 1
54
+ - 4
55
+ version: "1.4"
56
+ type: :development
57
+ version_requirements: *id003
58
+ description: Combines PhantomJS and Imagemagick to provide screenshot-based comparison for CSS regression testing
59
+ email: chris@madebymade.co.uk
60
+ executables:
61
+ - autobrewster
62
+ extensions: []
63
+
64
+ extra_rdoc_files: []
65
+
66
+ files:
67
+ - lib/auto_brewster.rb
68
+ - bin/autobrewster
69
+ has_rdoc: true
70
+ homepage: https://github.com/madebymade/autobrewster
71
+ licenses: []
72
+
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ requirements: []
93
+
94
+ rubyforge_project:
95
+ rubygems_version: 1.3.6
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: CSS regression testing suite
99
+ test_files: []
100
+