aanand-deadweight 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/deadweight.gemspec +1 -1
  3. data/lib/deadweight.rb +20 -17
  4. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/deadweight.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{deadweight}
5
- s.version = "0.0.1"
5
+ s.version = "0.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Aanand Prasad"]
data/lib/deadweight.rb CHANGED
@@ -15,6 +15,7 @@ class Deadweight
15
15
  @log_file = STDERR
16
16
  end
17
17
 
18
+ # Find all unused CSS selectors and return them as an array.
18
19
  def run
19
20
  css = CssParser::Parser.new
20
21
 
@@ -66,12 +67,29 @@ class Deadweight
66
67
  unused_selectors
67
68
  end
68
69
 
69
- private
70
-
70
+ # Returns the Mechanize instance, if +mechanize+ is set to +true+.
71
71
  def agent
72
72
  @agent ||= initialize_agent
73
73
  end
74
74
 
75
+ # Fetch a path, using Mechanize if +mechanize+ is set to +true+.
76
+ def fetch(path)
77
+ log.info(path)
78
+
79
+ loc = root + path
80
+
81
+ if @mechanize
82
+ loc = "file://#{File.expand_path(loc)}" unless loc =~ %r{^\w+://}
83
+ page = agent.get(loc)
84
+ log.warn("#{path} redirected to #{page.uri}") unless page.uri.to_s == loc
85
+ page.body
86
+ else
87
+ open(loc).read
88
+ end
89
+ end
90
+
91
+ private
92
+
75
93
  def log
76
94
  @log ||= Logger.new(@log_file)
77
95
  end
@@ -91,20 +109,5 @@ class Deadweight
91
109
  raise
92
110
  end
93
111
  end
94
-
95
- def fetch(path)
96
- log.info(path)
97
-
98
- loc = root + path
99
-
100
- if @mechanize
101
- loc = "file://#{File.expand_path(loc)}" unless loc =~ %r{^\w+://}
102
- page = agent.get(loc)
103
- log.warn("#{path} redirected to #{page.uri}") unless page.uri.to_s == loc
104
- page.body
105
- else
106
- open(loc).read
107
- end
108
- end
109
112
  end
110
113
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aanand-deadweight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aanand Prasad