deadweight 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/README.md +123 -0
  2. data/lib/deadweight.rb +37 -11
  3. data/lib/deadweight/hijack.rb +13 -0
  4. data/lib/deadweight/hijack/rails.rb +35 -0
  5. data/lib/deadweight/rack/capturing_middleware.rb +26 -0
  6. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/lib/css_parser.rb +25 -12
  7. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/lib/css_parser/parser.rb +120 -54
  8. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/lib/css_parser/regexps.rb +1 -1
  9. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/lib/css_parser/rule_set.rb +24 -13
  10. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/test/fixtures/import-circular-reference.css +0 -0
  11. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/test/fixtures/import-with-media-types.css +0 -0
  12. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/test/fixtures/import1.css +0 -0
  13. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/test/fixtures/simple.css +0 -0
  14. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/test/fixtures/subdir/import2.css +0 -0
  15. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/test/test_css_parser_basic.rb +4 -1
  16. data/vendor/gems/css_parser-1.1.5/test/test_css_parser_loading.rb +139 -0
  17. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/test/test_css_parser_media_types.rb +39 -4
  18. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/test/test_css_parser_misc.rb +1 -2
  19. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/test/test_css_parser_regexps.rb +1 -1
  20. data/vendor/gems/css_parser-1.1.5/test/test_helper.rb +6 -0
  21. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/test/test_merging.rb +16 -1
  22. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/test/test_rule_set.rb +16 -1
  23. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/test/test_rule_set_creating_shorthand.rb +1 -1
  24. data/vendor/gems/{css_parser-1.0.0 → css_parser-1.1.5}/test/test_rule_set_expanding_shorthand.rb +1 -1
  25. metadata +79 -54
  26. data/.document +0 -5
  27. data/.gitignore +0 -6
  28. data/README.rdoc +0 -85
  29. data/Rakefile +0 -58
  30. data/VERSION +0 -1
  31. data/deadweight.gemspec +0 -84
  32. data/test/cli_test.rb +0 -21
  33. data/test/deadweight_test.rb +0 -72
  34. data/test/fixtures/index.html +0 -16
  35. data/test/fixtures/index2.html +0 -21
  36. data/test/fixtures/style.css +0 -24
  37. data/test/rake_task_test.rb +0 -26
  38. data/test/test_helper.rb +0 -47
  39. data/vendor/gems/css_parser-1.0.0/test/test_css_parser_downloading.rb +0 -81
  40. data/vendor/gems/css_parser-1.0.0/test/test_helper.rb +0 -8
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/test_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
2
 
3
3
  # Test cases for reading and generating CSS shorthand properties
4
4
  class RuleSetCreatingShorthandTests < Test::Unit::TestCase
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/test_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
2
 
3
3
  class RuleSetExpandingShorthandTests < Test::Unit::TestCase
4
4
  include CssParser
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deadweight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Aanand Prasad
@@ -9,96 +14,116 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-18 00:00:00 -05:00
13
- default_executable: deadweight
17
+ date: 2011-03-04 00:00:00 +00:00
18
+ default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
- name: hpricot
21
+ name: nokogiri
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
17
31
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: shoulda
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
20
38
  requirements:
21
39
  - - ">="
22
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
23
43
  version: "0"
24
- version:
44
+ type: :development
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: mechanize
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ type: :development
58
+ version_requirements: *id003
25
59
  description:
26
60
  email: aanand.prasad@gmail.com
27
61
  executables:
28
62
  - deadweight
29
63
  extensions: []
30
64
 
31
- extra_rdoc_files:
32
- - LICENSE
33
- - README.rdoc
65
+ extra_rdoc_files: []
66
+
34
67
  files:
35
- - .document
36
- - .gitignore
37
68
  - LICENSE
38
- - README.rdoc
39
- - Rakefile
40
- - VERSION
69
+ - README.md
41
70
  - bin/deadweight
42
- - deadweight.gemspec
43
71
  - lib/deadweight.rb
44
72
  - lib/deadweight/cli.rb
73
+ - lib/deadweight/hijack.rb
74
+ - lib/deadweight/hijack/rails.rb
75
+ - lib/deadweight/rack/capturing_middleware.rb
45
76
  - lib/deadweight/rake_task.rb
46
- - test/cli_test.rb
47
- - test/deadweight_test.rb
48
- - test/fixtures/index.html
49
- - test/fixtures/index2.html
50
- - test/fixtures/style.css
51
- - test/rake_task_test.rb
52
- - test/test_helper.rb
53
- - vendor/gems/css_parser-1.0.0/lib/css_parser.rb
54
- - vendor/gems/css_parser-1.0.0/lib/css_parser/parser.rb
55
- - vendor/gems/css_parser-1.0.0/lib/css_parser/regexps.rb
56
- - vendor/gems/css_parser-1.0.0/lib/css_parser/rule_set.rb
57
- - vendor/gems/css_parser-1.0.0/test/fixtures/import-circular-reference.css
58
- - vendor/gems/css_parser-1.0.0/test/fixtures/import-with-media-types.css
59
- - vendor/gems/css_parser-1.0.0/test/fixtures/import1.css
60
- - vendor/gems/css_parser-1.0.0/test/fixtures/simple.css
61
- - vendor/gems/css_parser-1.0.0/test/fixtures/subdir/import2.css
62
- - vendor/gems/css_parser-1.0.0/test/test_css_parser_basic.rb
63
- - vendor/gems/css_parser-1.0.0/test/test_css_parser_downloading.rb
64
- - vendor/gems/css_parser-1.0.0/test/test_css_parser_media_types.rb
65
- - vendor/gems/css_parser-1.0.0/test/test_css_parser_misc.rb
66
- - vendor/gems/css_parser-1.0.0/test/test_css_parser_regexps.rb
67
- - vendor/gems/css_parser-1.0.0/test/test_helper.rb
68
- - vendor/gems/css_parser-1.0.0/test/test_merging.rb
69
- - vendor/gems/css_parser-1.0.0/test/test_rule_set.rb
70
- - vendor/gems/css_parser-1.0.0/test/test_rule_set_creating_shorthand.rb
71
- - vendor/gems/css_parser-1.0.0/test/test_rule_set_expanding_shorthand.rb
77
+ - vendor/gems/css_parser-1.1.5/lib/css_parser.rb
78
+ - vendor/gems/css_parser-1.1.5/lib/css_parser/parser.rb
79
+ - vendor/gems/css_parser-1.1.5/lib/css_parser/regexps.rb
80
+ - vendor/gems/css_parser-1.1.5/lib/css_parser/rule_set.rb
81
+ - vendor/gems/css_parser-1.1.5/test/fixtures/import-circular-reference.css
82
+ - vendor/gems/css_parser-1.1.5/test/fixtures/import-with-media-types.css
83
+ - vendor/gems/css_parser-1.1.5/test/fixtures/import1.css
84
+ - vendor/gems/css_parser-1.1.5/test/fixtures/simple.css
85
+ - vendor/gems/css_parser-1.1.5/test/fixtures/subdir/import2.css
86
+ - vendor/gems/css_parser-1.1.5/test/test_css_parser_basic.rb
87
+ - vendor/gems/css_parser-1.1.5/test/test_css_parser_loading.rb
88
+ - vendor/gems/css_parser-1.1.5/test/test_css_parser_media_types.rb
89
+ - vendor/gems/css_parser-1.1.5/test/test_css_parser_misc.rb
90
+ - vendor/gems/css_parser-1.1.5/test/test_css_parser_regexps.rb
91
+ - vendor/gems/css_parser-1.1.5/test/test_helper.rb
92
+ - vendor/gems/css_parser-1.1.5/test/test_merging.rb
93
+ - vendor/gems/css_parser-1.1.5/test/test_rule_set.rb
94
+ - vendor/gems/css_parser-1.1.5/test/test_rule_set_creating_shorthand.rb
95
+ - vendor/gems/css_parser-1.1.5/test/test_rule_set_expanding_shorthand.rb
72
96
  has_rdoc: true
73
97
  homepage: http://github.com/aanand/deadweight
74
- licenses: []
75
-
98
+ licenses:
99
+ - MIT
76
100
  post_install_message:
77
- rdoc_options:
78
- - --charset=UTF-8
101
+ rdoc_options: []
102
+
79
103
  require_paths:
80
104
  - lib
81
105
  required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
82
107
  requirements:
83
108
  - - ">="
84
109
  - !ruby/object:Gem::Version
110
+ segments:
111
+ - 0
85
112
  version: "0"
86
- version:
87
113
  required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
88
115
  requirements:
89
116
  - - ">="
90
117
  - !ruby/object:Gem::Version
118
+ segments:
119
+ - 0
91
120
  version: "0"
92
- version:
93
121
  requirements: []
94
122
 
95
123
  rubyforge_project:
96
- rubygems_version: 1.3.5
124
+ rubygems_version: 1.3.7
97
125
  signing_key:
98
126
  specification_version: 3
99
127
  summary: A coverage tool for finding unused CSS
100
- test_files:
101
- - test/cli_test.rb
102
- - test/deadweight_test.rb
103
- - test/rake_task_test.rb
104
- - test/test_helper.rb
128
+ test_files: []
129
+
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- *.sw?
2
- .DS_Store
3
- coverage
4
- rdoc
5
- pkg
6
- test.log
@@ -1,85 +0,0 @@
1
- = deadweight
2
-
3
- Deadweight is a CSS coverage tool. Given a set of stylesheets and a set of URLs, it determines which selectors are actually used and reports which can be "safely" deleted.
4
-
5
- === Screencast!
6
-
7
- Ryan Bates has worked his magic once again. Head over here for an excellent introduction to deadweight: http://railscasts.com/episodes/180-finding-unused-css
8
-
9
- === Install It
10
-
11
- gem install deadweight -s http://gemcutter.org
12
-
13
- === Make a Rake Task
14
-
15
- # lib/tasks/deadweight.rake
16
-
17
- require 'deadweight'
18
-
19
- Deadweight::RakeTask.new do |dw|
20
- dw.stylesheets = %w( /stylesheets/style.css )
21
- dw.pages = %w( / /page/1 /about )
22
- end
23
-
24
- Running <tt>rake deadweight</tt> will output all unused rules, one per line. Note that it looks at http://localhost:3000 by default, so you'll need to have <tt>script/server</tt> (or whatever your server command looks like) running.
25
-
26
- === Or Run it From the Command Line
27
-
28
- $ deadweight -s styles.css -s ie.css index.html about.html
29
-
30
- You can pipe in CSS rules from STDIN:
31
-
32
- $ cat styles.css | deadweight index.html
33
-
34
- And you can use it as an HTTP proxy:
35
-
36
- $ deadweight -l deadweight.log -s styles.css -w http://github.com/ -P
37
-
38
- There's also experimental support for Lyndon (http://github.com/defunkt/lyndon) with <tt>-L</tt>.
39
-
40
- === Or Call it Directly
41
-
42
- require 'deadweight'
43
-
44
- dw = Deadweight.new
45
- dw.stylesheets = %w( /stylesheets/style.css )
46
- dw.pages = %w( / /page/1 /about )
47
- puts dw.run
48
-
49
- === Things to Note
50
-
51
- - You can tell it what URL root to use (rather than <tt>http://localhost:3000</tt>) by setting +root+.
52
- - It's completely dumb about any classes, IDs or tags that are only added by your Javascript layer, but you can filter them out by setting +ignore_selectors+.
53
- - You can optionally tell it to use Mechanize, and set up more complicated targets for scraping by specifying them as Procs.
54
- - If you have the <tt>colored</tt> gem installed, it'll spruce up the STDERR output.
55
-
56
- === A More Complex Example, In Light of All That
57
-
58
- # lib/tasks/deadweight.rake
59
-
60
- require 'deadweight'
61
-
62
- Deadweight::RakeTask.new do |dw|
63
- dw.mechanize = true
64
-
65
- dw.root = 'http://staging.example.com'
66
-
67
- dw.stylesheets = %w( /stylesheets/style.css )
68
-
69
- dw.pages = %w( / /page/1 /about )
70
-
71
- dw.pages << proc {
72
- fetch('/login')
73
- form = agent.page.forms.first
74
- form.username = 'username'
75
- form.password = 'password'
76
- agent.submit(form)
77
- fetch('/secret-page')
78
- }
79
-
80
- dw.ignore_selectors = /hover|lightbox|superimposed_kittens/
81
- end
82
-
83
- == Copyright
84
-
85
- Copyright (c) 2009 Aanand Prasad. See LICENSE for details.
data/Rakefile DELETED
@@ -1,58 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "deadweight"
8
- gem.summary = "A coverage tool for finding unused CSS"
9
- gem.email = "aanand.prasad@gmail.com"
10
- gem.homepage = "http://github.com/aanand/deadweight"
11
- gem.authors = ["Aanand Prasad"]
12
-
13
- gem.add_dependency('hpricot')
14
- end
15
-
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
- end
20
-
21
- require 'rake/testtask'
22
- Rake::TestTask.new(:test) do |test|
23
- test.libs << 'lib' << 'test'
24
- test.pattern = 'test/**/*_test.rb'
25
- test.verbose = true
26
- end
27
-
28
- begin
29
- require 'rcov/rcovtask'
30
- Rcov::RcovTask.new do |test|
31
- test.libs << 'test'
32
- test.pattern = 'test/**/*_test.rb'
33
- test.verbose = true
34
- end
35
- rescue LoadError
36
- task :rcov do
37
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
- end
39
- end
40
-
41
-
42
- task :default => :test
43
-
44
- require 'rake/rdoctask'
45
- Rake::RDocTask.new do |rdoc|
46
- if File.exist?('VERSION.yml')
47
- config = YAML.load(File.read('VERSION.yml'))
48
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
49
- else
50
- version = ""
51
- end
52
-
53
- rdoc.rdoc_dir = 'rdoc'
54
- rdoc.title = "deadweight #{version}"
55
- rdoc.rdoc_files.include('README*')
56
- rdoc.rdoc_files.include('lib/**/*.rb')
57
- end
58
-
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.3
@@ -1,84 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{deadweight}
8
- s.version = "0.1.3"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Aanand Prasad"]
12
- s.date = %q{2010-01-18}
13
- s.default_executable = %q{deadweight}
14
- s.email = %q{aanand.prasad@gmail.com}
15
- s.executables = ["deadweight"]
16
- s.extra_rdoc_files = [
17
- "LICENSE",
18
- "README.rdoc"
19
- ]
20
- s.files = [
21
- ".document",
22
- ".gitignore",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "bin/deadweight",
28
- "deadweight.gemspec",
29
- "lib/deadweight.rb",
30
- "lib/deadweight/cli.rb",
31
- "lib/deadweight/rake_task.rb",
32
- "test/cli_test.rb",
33
- "test/deadweight_test.rb",
34
- "test/fixtures/index.html",
35
- "test/fixtures/index2.html",
36
- "test/fixtures/style.css",
37
- "test/rake_task_test.rb",
38
- "test/test_helper.rb",
39
- "vendor/gems/css_parser-1.0.0/lib/css_parser.rb",
40
- "vendor/gems/css_parser-1.0.0/lib/css_parser/parser.rb",
41
- "vendor/gems/css_parser-1.0.0/lib/css_parser/regexps.rb",
42
- "vendor/gems/css_parser-1.0.0/lib/css_parser/rule_set.rb",
43
- "vendor/gems/css_parser-1.0.0/test/fixtures/import-circular-reference.css",
44
- "vendor/gems/css_parser-1.0.0/test/fixtures/import-with-media-types.css",
45
- "vendor/gems/css_parser-1.0.0/test/fixtures/import1.css",
46
- "vendor/gems/css_parser-1.0.0/test/fixtures/simple.css",
47
- "vendor/gems/css_parser-1.0.0/test/fixtures/subdir/import2.css",
48
- "vendor/gems/css_parser-1.0.0/test/test_css_parser_basic.rb",
49
- "vendor/gems/css_parser-1.0.0/test/test_css_parser_downloading.rb",
50
- "vendor/gems/css_parser-1.0.0/test/test_css_parser_media_types.rb",
51
- "vendor/gems/css_parser-1.0.0/test/test_css_parser_misc.rb",
52
- "vendor/gems/css_parser-1.0.0/test/test_css_parser_regexps.rb",
53
- "vendor/gems/css_parser-1.0.0/test/test_helper.rb",
54
- "vendor/gems/css_parser-1.0.0/test/test_merging.rb",
55
- "vendor/gems/css_parser-1.0.0/test/test_rule_set.rb",
56
- "vendor/gems/css_parser-1.0.0/test/test_rule_set_creating_shorthand.rb",
57
- "vendor/gems/css_parser-1.0.0/test/test_rule_set_expanding_shorthand.rb"
58
- ]
59
- s.homepage = %q{http://github.com/aanand/deadweight}
60
- s.rdoc_options = ["--charset=UTF-8"]
61
- s.require_paths = ["lib"]
62
- s.rubygems_version = %q{1.3.5}
63
- s.summary = %q{A coverage tool for finding unused CSS}
64
- s.test_files = [
65
- "test/cli_test.rb",
66
- "test/deadweight_test.rb",
67
- "test/rake_task_test.rb",
68
- "test/test_helper.rb"
69
- ]
70
-
71
- if s.respond_to? :specification_version then
72
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
73
- s.specification_version = 3
74
-
75
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
76
- s.add_runtime_dependency(%q<hpricot>, [">= 0"])
77
- else
78
- s.add_dependency(%q<hpricot>, [">= 0"])
79
- end
80
- else
81
- s.add_dependency(%q<hpricot>, [">= 0"])
82
- end
83
- end
84
-
@@ -1,21 +0,0 @@
1
- require 'test_helper'
2
-
3
- class CliTest < Test::Unit::TestCase
4
- COMMAND = "ruby -rubygems -Ilib bin/deadweight"
5
- FULL_COMMAND = "#{COMMAND} -s test/fixtures/style.css test/fixtures/index.html 2>/dev/null"
6
-
7
- should "output unused selectors on STDOUT" do
8
- assert_correct_selectors_in_output(`#{FULL_COMMAND}`)
9
- end
10
-
11
- should "accept CSS rules on STDIN" do
12
- assert `echo ".something { display: block; }" | #{FULL_COMMAND}`.include?('.something')
13
- end
14
-
15
- should "accept a [-r | --root] argument and relative paths" do
16
- %w(-r --root).each do |arg|
17
- assert_correct_selectors_in_output(`#{COMMAND} #{arg} test/fixtures -s /style.css /index.html 2>/dev/null`)
18
- end
19
- end
20
- end
21
-