headhunter 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -4
- data/lib/headhunter/rack/capturing_middleware.rb +1 -1
- data/lib/headhunter/runner.rb +11 -6
- data/lib/headhunter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d287be5bc2f5e01f890c230b48551f4e5c2e8bd
|
4
|
+
data.tar.gz: 283aca4ad207e9bb2c61521c3d44acfde5a0c3ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c101581f77a54f142e17a96b1d981f1bcb2c24f466dd14a03cbd49b541bec26baad1930b12ffd8c40e147443d6e6341b21dccb9523d7c3899468efbc1ed344b8
|
7
|
+
data.tar.gz: a798b94f7f2d39abb98b2ddabe59f9bef8dd2193d7d4ce5d14c78f5b16816da0858ff851a8e4e67d4dc4f8cb2120b66f9bc5d1e97d791057bb1d5a176d2c8394
|
data/README.md
CHANGED
@@ -26,6 +26,10 @@ Just set the environment variable `HEADHUNTER` to `true` when running your tests
|
|
26
26
|
|
27
27
|
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.
|
28
28
|
|
29
|
+
$ rake HEADHUNTER=true
|
30
|
+
|
31
|
+
Precompiling assets for Headhunter... done!
|
32
|
+
|
29
33
|
30/30 |============================= 100 ==============================>| Time: 00:00:02
|
30
34
|
|
31
35
|
Finished in 2.65 seconds
|
@@ -47,11 +51,9 @@ Headhunter doesn't keep your tests from passing if invalid HTML or unused CSS is
|
|
47
51
|
|
48
52
|
## How it works
|
49
53
|
|
50
|
-
Headhunter registers itself as middleware in the Rack stack and triggers validation for every HTML response.
|
51
|
-
|
52
|
-
For every `.css` file, validation is also triggered. In addition, it iterates over every HTML page's selectors to see whether there exist any unused CSS definitions in your `.css` files.
|
54
|
+
Headhunter registers itself as middleware in the Rack stack and triggers validation for every HTML response. Headhunter also iterates over every `.css` file and triggers its validation. In addition, it checks which CSS selectors are really used in the HTML pages to see whether there exist any unused CSS definitions.
|
53
55
|
|
54
|
-
For being able to validate CSS, `rake assets:precompile` is triggered at the beginning of running tests. This may slow down starting your tests a bit.
|
56
|
+
For being able to validate CSS, `rake assets:precompile` is triggered at the beginning of running tests. This may slow down starting your tests a bit. **Notice: all precompiled assets will be removed after the tests have finished!**
|
55
57
|
|
56
58
|
## Requirements
|
57
59
|
|
@@ -74,6 +76,7 @@ You need a working internet connection to run CSS validation. As a Rails applica
|
|
74
76
|
- HTML and CSS sources should not be compressed, to allow more concise error messages
|
75
77
|
- Would be really useful to have the concrete URL of every validated HTML page. But can't find a way to extract it from Rack response.
|
76
78
|
- There are not tests yet. I first want to see whether this gem would be appreciated by the community, and if so, I will definitely add tests.
|
79
|
+
- Didn't try this with AJAX requests yet. Would be great if such responses would be validated, too!
|
77
80
|
|
78
81
|
## Disclaimer
|
79
82
|
|
data/lib/headhunter/runner.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module Headhunter
|
2
4
|
class Runner
|
5
|
+
ASSETS_PATH = 'public/assets'
|
6
|
+
|
3
7
|
attr_accessor :results
|
4
8
|
|
5
9
|
def initialize(root)
|
6
|
-
@root
|
10
|
+
@root = root
|
11
|
+
@temporary_assets = []
|
7
12
|
|
8
13
|
precompile_assets!
|
9
14
|
|
@@ -34,18 +39,18 @@ module Headhunter
|
|
34
39
|
private
|
35
40
|
|
36
41
|
def precompile_assets!
|
37
|
-
|
38
|
-
|
39
|
-
|
42
|
+
log.print "\nPrecompiling assets for Headhunter...".yellow
|
43
|
+
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
|
40
44
|
system 'rake assets:precompile HEADHUNTER=false &> /dev/null'
|
45
|
+
log.puts " done!\n".yellow
|
41
46
|
end
|
42
47
|
|
43
48
|
def remove_assets!
|
44
|
-
|
49
|
+
FileUtils.rm_r ASSETS_PATH if File.exist?(ASSETS_PATH)
|
45
50
|
end
|
46
51
|
|
47
52
|
def stylesheets
|
48
|
-
Dir
|
53
|
+
Dir["#{ASSETS_PATH}/*.css"]
|
49
54
|
end
|
50
55
|
end
|
51
56
|
end
|
data/lib/headhunter/version.rb
CHANGED