watircats 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/README.md +6 -5
- data/lib/watircats/comparer.rb +13 -13
- data/lib/watircats/mapper.rb +12 -12
- data/lib/watircats/snapper.rb +7 -4
- data/lib/watircats/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8db0dd7100f49a4111d751dae08c83246a11e89
|
4
|
+
data.tar.gz: 6f38d5995b960361f2ab8d20120c03700b0d29a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d05e999a2c93621e415865156f48fa59f736e70e79d7a7046c27d0a7f321ccb977fd958397d6eb56950ebed3037cb6db3d78383f9105f64bd12a70d976e2985
|
7
|
+
data.tar.gz: 72dd10d1e5912dc34c6f130db57f986c0874ab06e90652fce138d0deb91c8cb64457ca58995e365c28ee232696fd169aecd8bb621e01ad3ea7a2fa1740264d18
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# WatirCats
|
2
|
+
[](http://badge.fury.io/rb/watircats)
|
2
3
|
|
3
4
|
WatirCats began as a simple fork of Wraith, from the developers at BBC News.
|
4
5
|
|
@@ -24,14 +25,14 @@ WatirCats uses Watir-Webdriver to grab screenshots of pages at multiple widths.
|
|
24
25
|
|
25
26
|
## Installation
|
26
27
|
|
27
|
-
`gem install
|
28
|
+
`gem install watircats`
|
28
29
|
|
29
30
|
or
|
30
31
|
|
31
32
|
- Checkout this repository
|
32
33
|
- `bundle install`
|
33
34
|
- `gem build watircats.gemspec`
|
34
|
-
- `gem install
|
35
|
+
- `gem install watircats-0.2.3.gem`
|
35
36
|
|
36
37
|
## Usage
|
37
38
|
|
@@ -65,10 +66,10 @@ If you want to add functionality to this project, pull requests are welcome.
|
|
65
66
|
## License
|
66
67
|
|
67
68
|
WatirCats is available to everyone under the terms of the MIT open source
|
68
|
-
|
69
|
+
license. Take a look at the LICENSE file in the code.
|
69
70
|
|
70
71
|
## Credits
|
71
72
|
|
72
|
-
* [Andrew
|
73
|
-
* [Wraith from BBC News](http://github.com/bbc-news/wraith)
|
73
|
+
* [Leaf Andrew](http://clockwork.net/people/andrew_leaf/) - author, maintainer
|
74
|
+
* [Wraith from BBC News](http://github.com/bbc-news/wraith) - original concept
|
74
75
|
|
data/lib/watircats/comparer.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module WatirCats
|
2
|
-
class Comparer
|
2
|
+
class Comparer
|
3
3
|
|
4
4
|
NO_CHANGE = "Snow"
|
5
5
|
ERROR = "Crimson"
|
@@ -10,10 +10,10 @@ module WatirCats
|
|
10
10
|
|
11
11
|
@@results = [ ]
|
12
12
|
@@strip_zero = WatirCats.config.strip_zero_differences || nil
|
13
|
-
|
13
|
+
|
14
14
|
@comparison_dir = WatirCats.config.output_dir.chomp("/")
|
15
15
|
# Get the last two directories that were created
|
16
|
-
|
16
|
+
|
17
17
|
previous_shots_folder = source_a.chomp("/")
|
18
18
|
latest_shots_folder = source_b.chomp("/")
|
19
19
|
|
@@ -26,13 +26,13 @@ module WatirCats
|
|
26
26
|
# Return self
|
27
27
|
self
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def reset_comparison_folder
|
31
31
|
if File.directory? @comparison_dir
|
32
32
|
dir_contents = Dir.glob("#{@comparison_dir}/*_compared.png")
|
33
33
|
if dir_contents.size > 0
|
34
34
|
dir_contents.each do |shot|
|
35
|
-
FileUtils.rm(shot)
|
35
|
+
FileUtils.rm(shot)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
else
|
@@ -46,7 +46,7 @@ module WatirCats
|
|
46
46
|
|
47
47
|
old_shots.each do |old_shot|
|
48
48
|
new_shot = old_shot.gsub(previous, latest)
|
49
|
-
|
49
|
+
|
50
50
|
next unless File.exists? new_shot
|
51
51
|
# Set a file prefix for output and info
|
52
52
|
base_name = old_shot.split("/").last.split(".").first
|
@@ -59,12 +59,12 @@ module WatirCats
|
|
59
59
|
elsif comparison.match(/^[1-9]/)
|
60
60
|
status = CHANGE
|
61
61
|
end
|
62
|
-
@@results << { :compared_shot => output_file,
|
62
|
+
@@results << { :compared_shot => output_file,
|
63
63
|
:result => comparison, :status_color => status }
|
64
64
|
|
65
65
|
# Remove the file if there is no change to be concerned with
|
66
|
-
if @@strip_zero == true
|
67
|
-
begin
|
66
|
+
if @@strip_zero == true
|
67
|
+
begin
|
68
68
|
FileUtils.rm "#{@comparison_dir}/#{output_file}" if status == NO_CHANGE
|
69
69
|
rescue Exception => msg
|
70
70
|
print msg
|
@@ -76,9 +76,9 @@ module WatirCats
|
|
76
76
|
# Run the generate thumbs
|
77
77
|
generate_thumbs if WatirCats.config.reporting_enabled
|
78
78
|
end
|
79
|
-
|
80
|
-
def generate_thumbs
|
81
|
-
|
79
|
+
|
80
|
+
def generate_thumbs
|
81
|
+
|
82
82
|
unless results.size < 1
|
83
83
|
unless File.directory? "#{@comparison_dir}/thumbs"
|
84
84
|
FileUtils.mkdir "#{@comparison_dir}/thumbs"
|
@@ -133,4 +133,4 @@ module WatirCats
|
|
133
133
|
end
|
134
134
|
|
135
135
|
end
|
136
|
-
end
|
136
|
+
end
|
data/lib/watircats/mapper.rb
CHANGED
@@ -6,7 +6,7 @@ module WatirCats
|
|
6
6
|
|
7
7
|
def initialize( base_url, scheme )
|
8
8
|
# Class variables that persist throughout the life of the application
|
9
|
-
|
9
|
+
|
10
10
|
@limit = WatirCats.config.limit
|
11
11
|
@proxy = WatirCats.config.proxy
|
12
12
|
|
@@ -17,7 +17,7 @@ module WatirCats
|
|
17
17
|
restrict_paths
|
18
18
|
|
19
19
|
@base_url = base_url
|
20
|
-
|
20
|
+
|
21
21
|
# If the :url_list option is passed, it is assumed to be a file of urls,
|
22
22
|
# one on each line. Otherwise, assume there is a sitemap
|
23
23
|
if WatirCats.config.url_list
|
@@ -29,7 +29,7 @@ module WatirCats
|
|
29
29
|
exit 1
|
30
30
|
end
|
31
31
|
else
|
32
|
-
xml = get_sitemap_as_xml( scheme, @base_url )
|
32
|
+
xml = get_sitemap_as_xml( scheme, @base_url )
|
33
33
|
urls = parse_sitemap_into_urls(xml)
|
34
34
|
end
|
35
35
|
|
@@ -45,7 +45,7 @@ module WatirCats
|
|
45
45
|
proxy = nil
|
46
46
|
end
|
47
47
|
|
48
|
-
begin
|
48
|
+
begin
|
49
49
|
sitemap_data = ::OpenURI.open_uri((the_scheme + "://" + base_url + "/sitemap.xml"), :proxy => proxy )
|
50
50
|
sitemap_xml = ::XmlSimple.xml_in(sitemap_data)
|
51
51
|
rescue Exception => msg
|
@@ -69,13 +69,13 @@ module WatirCats
|
|
69
69
|
# Determine if this is the first pass
|
70
70
|
if @@master_paths.size == 0
|
71
71
|
mode = :first_run
|
72
|
-
else
|
72
|
+
else
|
73
73
|
mode = :not_first
|
74
74
|
end
|
75
75
|
|
76
76
|
# Create an empty hash to store paths in
|
77
77
|
pending_paths = {}
|
78
|
-
|
78
|
+
|
79
79
|
# Iterate through the urls, grab only the valid paths post domain
|
80
80
|
# Store each path_key with the extrapolated path
|
81
81
|
urls.each do |url|
|
@@ -83,7 +83,7 @@ module WatirCats
|
|
83
83
|
|
84
84
|
# Handled paths to look for and avoid
|
85
85
|
if @subtree
|
86
|
-
next unless path.match @subtree
|
86
|
+
next unless path.match @subtree
|
87
87
|
end
|
88
88
|
if @avoided_path
|
89
89
|
next if path.match @avoided_path
|
@@ -105,7 +105,7 @@ module WatirCats
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
# Store master paths if this is the first pass
|
110
110
|
@@master_paths.merge! pending_paths if mode == :first_run
|
111
111
|
# return the paths to crawl
|
@@ -114,7 +114,7 @@ module WatirCats
|
|
114
114
|
|
115
115
|
def the_paths
|
116
116
|
# TODO: Insert logic to limit to a specific subtree here
|
117
|
-
|
117
|
+
|
118
118
|
# Return the paths if there is a @limit
|
119
119
|
return @the_paths.first(@limit.to_i) if @limit
|
120
120
|
@the_paths.first(@the_paths.length)
|
@@ -134,10 +134,10 @@ module WatirCats
|
|
134
134
|
|
135
135
|
# Only visit paths that match @subtree
|
136
136
|
@subtree = WatirCats.config.limited_path
|
137
|
-
if @subtree
|
137
|
+
if @subtree
|
138
138
|
@subtree = /#{WatirCats.config.limited_path}/
|
139
139
|
end
|
140
|
-
|
140
|
+
|
141
141
|
# If avoided_path is specified, avoid those
|
142
142
|
@avoided_path = WatirCats.config.avoided_path
|
143
143
|
if @avoided_path
|
@@ -146,4 +146,4 @@ module WatirCats
|
|
146
146
|
end
|
147
147
|
|
148
148
|
end
|
149
|
-
end
|
149
|
+
end
|
data/lib/watircats/snapper.rb
CHANGED
@@ -55,10 +55,10 @@ module WatirCats
|
|
55
55
|
|
56
56
|
# skip existing screenshots if we've specified that option
|
57
57
|
if WatirCats.config.skip_existing
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
if FileTest.exists?(file_name)
|
59
|
+
puts "Skipping existing file at " + file_name
|
60
|
+
return
|
61
|
+
end
|
62
62
|
end
|
63
63
|
|
64
64
|
|
@@ -125,6 +125,9 @@ module WatirCats
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
+
# Skip if a redirect matches the avoided path
|
129
|
+
next if @browser.url.match( /#{WatirCats.config.avoided_path}/ )
|
130
|
+
|
128
131
|
# For each width, resize the browser, take a screenshot
|
129
132
|
widths.each do |width|
|
130
133
|
resize_browser width
|
data/lib/watircats/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watircats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Leaf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: require_all
|