headhunter 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +15 -8
- data/README.md +6 -24
- data/docs/headhunter.png +0 -0
- data/docs/money.png +0 -0
- data/docs/screenshot.png +0 -0
- data/lib/headhunter/css_hunter.rb +5 -5
- data/lib/headhunter/css_validator.rb +11 -7
- data/lib/headhunter/html_validator.rb +5 -5
- data/lib/headhunter/local_response.rb +20 -0
- data/lib/headhunter/runner.rb +7 -7
- data/lib/headhunter/version.rb +1 -1
- metadata +49 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df58d59328c6942d9153f49b22765fbef1aa7c62
|
4
|
+
data.tar.gz: 4e7c82703bb398fbb1a08f3d8b33e80f4793621e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68c02e914808c4fababacc1edea8d50d5c7576522154d023434edf6b54fe46fe4026998a57e7991b24848de0eac634b2a85da8105c844a1389fdf6f790dd0922
|
7
|
+
data.tar.gz: 5b93567d530e2e222476b825f5e0f53f33d3c1f8bb05f90571c06ead976462f3a61741ed9ed32d93135023a2a87aa2a1f9d806dcaad7d56d51562ff062ce12d0
|
data/Gemfile.lock
CHANGED
@@ -1,34 +1,37 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
headhunter (0.
|
4
|
+
headhunter (0.1.3)
|
5
5
|
colorize
|
6
|
-
css_parser (
|
6
|
+
css_parser (>= 1.2.6)
|
7
7
|
html_validation
|
8
8
|
nokogiri
|
9
|
-
rspec
|
10
9
|
|
11
10
|
GEM
|
12
11
|
remote: https://rubygems.org/
|
13
12
|
specs:
|
14
13
|
addressable (2.3.5)
|
14
|
+
awesome_print (1.2.0)
|
15
|
+
coderay (1.1.0)
|
15
16
|
colorize (0.6.0)
|
16
|
-
|
17
|
+
coolline (0.4.3)
|
18
|
+
css_parser (1.3.5)
|
17
19
|
addressable
|
18
|
-
rdoc
|
19
20
|
diff-lcs (1.2.5)
|
20
21
|
fuubar (1.3.2)
|
21
22
|
rspec (>= 2.14.0, < 3.1.0)
|
22
23
|
ruby-progressbar (~> 1.3)
|
23
24
|
gem-release (0.7.1)
|
24
25
|
html_validation (1.0.0)
|
25
|
-
|
26
|
+
method_source (0.8.2)
|
26
27
|
mini_portile (0.5.2)
|
27
28
|
nokogiri (1.6.1)
|
28
29
|
mini_portile (~> 0.5.0)
|
30
|
+
pry (0.9.12.6)
|
31
|
+
coderay (~> 1.0)
|
32
|
+
method_source (~> 0.8)
|
33
|
+
slop (~> 3.4)
|
29
34
|
rake (10.1.1)
|
30
|
-
rdoc (4.1.1)
|
31
|
-
json (~> 1.4)
|
32
35
|
rspec (2.14.1)
|
33
36
|
rspec-core (~> 2.14.0)
|
34
37
|
rspec-expectations (~> 2.14.0)
|
@@ -38,13 +41,17 @@ GEM
|
|
38
41
|
diff-lcs (>= 1.1.3, < 2.0)
|
39
42
|
rspec-mocks (2.14.4)
|
40
43
|
ruby-progressbar (1.4.0)
|
44
|
+
slop (3.4.7)
|
41
45
|
|
42
46
|
PLATFORMS
|
43
47
|
ruby
|
44
48
|
|
45
49
|
DEPENDENCIES
|
50
|
+
awesome_print
|
51
|
+
coolline
|
46
52
|
fuubar
|
47
53
|
gem-release
|
48
54
|
headhunter!
|
55
|
+
pry
|
49
56
|
rake
|
50
57
|
rspec (>= 2.0)
|
data/README.md
CHANGED
@@ -5,8 +5,9 @@
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/headhunter.png)](http://badge.fury.io/rb/headhunter)
|
6
6
|
[![Code Climate](https://codeclimate.com/github/jmuheim/headhunter.png)](https://codeclimate.com/github/jmuheim/headhunter)
|
7
7
|
[![Travis CI](https://api.travis-ci.org/jmuheim/headhunter.png)](https://travis-ci.org/jmuheim/headhunter)
|
8
|
+
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/jmuheim/headhunter/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
8
9
|
|
9
|
-
Headhunter is an HTML and CSS validation tool that injects itself into your Rails feature tests and auto
|
10
|
+
Headhunter is an HTML and CSS validation tool that injects itself into your Rails feature tests and auto<strong>magic</strong>ally checks all your generated HTML and CSS for validity.
|
10
11
|
|
11
12
|
In addition, it also looks out for unused (and therefore superfluous) CSS selectors.
|
12
13
|
|
@@ -32,28 +33,7 @@ $ HEADHUNTER=true cucumber
|
|
32
33
|
|
33
34
|
Headhunter doesn't keep your tests from passing if invalid HTML or unused CSS is found. Instead it displays a short statistic after the tests are run.
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
Precompiling assets for Headhunter... done!
|
38
|
-
|
39
|
-
30/30 |============================= 100 ==============================>| Time: 00:00:02
|
40
|
-
|
41
|
-
Finished in 2.65 seconds
|
42
|
-
30 examples, 0 failures
|
43
|
-
|
44
|
-
Validated 42 HTML pages.
|
45
|
-
41 pages are valid.
|
46
|
-
1 page is invalid.
|
47
|
-
Open .validation/results.html to view full results.
|
48
|
-
|
49
|
-
Validated 1 stylesheets.
|
50
|
-
1 stylesheet is invalid.
|
51
|
-
application.css:
|
52
|
-
- Line 1: Property bla doesn't exist
|
53
|
-
|
54
|
-
Found 23 CSS selectors.
|
55
|
-
20 selectors are in use.
|
56
|
-
3 selectors are not in use: a img, #flash.failure, input[type='file']
|
36
|
+
![Headhunter output](docs/screenshot.png)
|
57
37
|
|
58
38
|
## How it works
|
59
39
|
|
@@ -65,7 +45,7 @@ For being able to validate CSS, `rake assets:precompile` is triggered at the beg
|
|
65
45
|
|
66
46
|
## Requirements
|
67
47
|
|
68
|
-
**[Tidy HTML](http://tidy.sourceforge.net/)** should be installed on a typical OSX and Linux installation already
|
48
|
+
**[Tidy HTML](http://tidy.sourceforge.net/)** should be installed on a typical OSX and Linux installation already - you're not developing on a Windows machine, are you?! If you want to validate HTML5 (and you should want to!), install the HTML5 version like described here: [homebrew tidy html5](http://techblog.willshouse.com/2013/10/21/homebrew-tidy-html5/).
|
69
49
|
|
70
50
|
You need a **Java Runtime Environment** to run CSS validation. This should normally already be available on OSX and Linux machines, too. A local copy ([`css-validator.jar`](http://jigsaw.w3.org/css-validator/DOWNLOAD.html)) of the [W3 CSS Validation Service](http://jigsaw.w3.org/css-validator/) is used.
|
71
51
|
|
@@ -79,6 +59,8 @@ You need a **Java Runtime Environment** to run CSS validation. This should norma
|
|
79
59
|
- In feature tests, the same views are getting rendered again and again. These same sources shouldn't be validated over and over again!
|
80
60
|
- More configuration options needed! CSS1, CSS2, CSS2.1, CSS3! XHTML, HTML5, etc.
|
81
61
|
- Better output needed! With context lines, etc.
|
62
|
+
- Look out for multiple used IDs on the same page and raise error!
|
63
|
+
- Look out for invalid tags and raise error (tidy doesn't seem to do this?!)!
|
82
64
|
|
83
65
|
## Disclaimer
|
84
66
|
|
data/docs/headhunter.png
CHANGED
Binary file
|
data/docs/money.png
CHANGED
Binary file
|
data/docs/screenshot.png
ADDED
Binary file
|
@@ -21,11 +21,11 @@ module Headhunter
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def report
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
puts "Found #{@used_selectors.size + @unused_selectors.size + @error_selectors.size} CSS selectors.".yellow
|
25
|
+
puts "#{@used_selectors.size} selectors are in use.".green if @used_selectors.size > 0
|
26
|
+
puts "#{@unused_selectors.size} selectors are not in use: #{@unused_selectors.sort.join(', ').red}".red if @unused_selectors.size > 0
|
27
|
+
puts "#{@error_selectors.size} selectors could not be parsed: #{@error_selectors.sort.join(', ').red}".red if @unused_selectors.size > 0
|
28
|
+
puts
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
@@ -24,12 +24,16 @@ module Headhunter
|
|
24
24
|
class CssValidator
|
25
25
|
USE_LOCAL_VALIDATOR = true
|
26
26
|
|
27
|
-
def initialize(stylesheets)
|
27
|
+
def initialize(stylesheets = [])
|
28
28
|
@profile = 'css3' # TODO: Option for profile css1 and css21
|
29
29
|
@stylesheets = stylesheets
|
30
30
|
@messages_per_stylesheet = {}
|
31
31
|
end
|
32
32
|
|
33
|
+
def add_stylesheet(stylesheet)
|
34
|
+
@stylesheets << stylesheet
|
35
|
+
end
|
36
|
+
|
33
37
|
def process!
|
34
38
|
@stylesheets.each do |stylesheet|
|
35
39
|
css = fetch(stylesheet)
|
@@ -43,17 +47,17 @@ module Headhunter
|
|
43
47
|
end
|
44
48
|
|
45
49
|
def report
|
46
|
-
|
47
|
-
|
48
|
-
|
50
|
+
puts "Validated #{@stylesheets.size} stylesheets.".yellow
|
51
|
+
puts "#{x_stylesheets_be(@stylesheets.size - @messages_per_stylesheet.size)} valid.".green if @messages_per_stylesheet.size < @stylesheets.size
|
52
|
+
puts "#{x_stylesheets_be(@messages_per_stylesheet.size)} invalid.".red if @messages_per_stylesheet.size > 0
|
49
53
|
|
50
54
|
@messages_per_stylesheet.each_pair do |stylesheet, messages|
|
51
|
-
|
55
|
+
puts " #{extract_filename(stylesheet)}:".red
|
52
56
|
|
53
|
-
messages.each { |message|
|
57
|
+
messages.each { |message| puts " - #{message}".red }
|
54
58
|
end
|
55
59
|
|
56
|
-
|
60
|
+
puts
|
57
61
|
end
|
58
62
|
|
59
63
|
private
|
@@ -34,11 +34,11 @@ module Headhunter
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def report
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
puts "Validated #{@valid_results.size + @invalid_results.size} HTML pages.".yellow
|
38
|
+
puts "#{x_pages_be(@valid_results.size)} valid.".green if @valid_results.size > 0
|
39
|
+
puts "#{x_pages_be(@invalid_results.size)} invalid.".red if @invalid_results.size > 0
|
40
|
+
puts 'Open .validation/results.html to view full results.'
|
41
|
+
puts
|
42
42
|
end
|
43
43
|
|
44
44
|
private
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
module Headhunter
|
4
|
+
class LocalResponse
|
5
|
+
attr_reader :body
|
6
|
+
|
7
|
+
def initialize(body)
|
8
|
+
@body = body
|
9
|
+
@headers = {'x-w3c-validator-status' => valid?}
|
10
|
+
end
|
11
|
+
|
12
|
+
def [](key)
|
13
|
+
@headers[key]
|
14
|
+
end
|
15
|
+
|
16
|
+
def valid?
|
17
|
+
REXML::Document.new(@body).root.each_element('//m:validity') { |e| return e.text == 'true' }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/headhunter/runner.rb
CHANGED
@@ -13,9 +13,9 @@ module Headhunter
|
|
13
13
|
precompile_assets!
|
14
14
|
|
15
15
|
@html_validator = HtmlValidator.new
|
16
|
-
@css_validator = CssValidator.new(stylesheets)
|
17
16
|
@css_hunter = CssHunter.new(stylesheets)
|
18
17
|
|
18
|
+
@css_validator = CssValidator.new(stylesheets)
|
19
19
|
@css_validator.process!
|
20
20
|
end
|
21
21
|
|
@@ -25,9 +25,9 @@ module Headhunter
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def clean_up!
|
28
|
-
|
28
|
+
print "Headhunter is removing precompiled assets...".yellow
|
29
29
|
remove_assets!
|
30
|
-
|
30
|
+
puts " done!".yellow
|
31
31
|
end
|
32
32
|
|
33
33
|
def report
|
@@ -41,16 +41,16 @@ module Headhunter
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def precompile_assets!
|
44
|
-
|
44
|
+
print "Headhunter is removing eventually existing assets...".yellow
|
45
45
|
remove_assets! # Remove existing assets! This seems to be necessary to make sure that they don't exist twice, see http://stackoverflow.com/questions/20938891
|
46
46
|
sleep 1
|
47
|
-
|
47
|
+
puts " done!".yellow
|
48
48
|
|
49
49
|
sleep 1
|
50
50
|
|
51
|
-
|
51
|
+
print "Headhunter is precompiling assets...".yellow
|
52
52
|
system 'rake assets:precompile HEADHUNTER=false &> /dev/null'
|
53
|
-
|
53
|
+
puts " done!\n".yellow
|
54
54
|
end
|
55
55
|
|
56
56
|
def remove_assets!
|
data/lib/headhunter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: headhunter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Muheim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: css_parser
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.2.6
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.2.6
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -73,7 +73,7 @@ dependencies:
|
|
73
73
|
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
|
-
type: :
|
76
|
+
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
@@ -94,6 +94,48 @@ dependencies:
|
|
94
94
|
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: coolline
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: awesome_print
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
97
139
|
- !ruby/object:Gem::Dependency
|
98
140
|
name: gem-release
|
99
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,6 +195,7 @@ files:
|
|
153
195
|
- lib/headhunter/css_hunter.rb
|
154
196
|
- lib/headhunter/css_validator.rb
|
155
197
|
- lib/headhunter/html_validator.rb
|
198
|
+
- lib/headhunter/local_response.rb
|
156
199
|
- lib/headhunter/rack/capturing_middleware.rb
|
157
200
|
- lib/headhunter/rails.rb
|
158
201
|
- lib/headhunter/runner.rb
|
@@ -166,6 +209,7 @@ files:
|
|
166
209
|
- README.md
|
167
210
|
- docs/headhunter.png
|
168
211
|
- docs/money.png
|
212
|
+
- docs/screenshot.png
|
169
213
|
homepage: http://github.com/jmuheim/headhunter
|
170
214
|
licenses:
|
171
215
|
- MIT
|