dry_css 0.0.6 → 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/lib/dry_css/css.rb +19 -17
- data/lib/dry_css/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: 44af193810a4b87478215fdb6963169300cc528f
|
4
|
+
data.tar.gz: b6981de3127f1432527294236d949b22bc9ada8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e8435b7ab0879fd377438897218856018f7b51d71eae6c8c4a6b14163671c5e99c91155970db232796a187393ecf42fc500b417e609f18fcb55b7fcc784cde4
|
7
|
+
data.tar.gz: 6a73b695e408e1bdeb2355ece0b9371eeb92f3b83485fdb4c863b87c18f4590fc61bef81a89fa2921f7a5ae05d875806463e7ad155caa74c641e5d5cbe4273ee
|
data/lib/dry_css/css.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
module DryCss
|
2
2
|
class CSS
|
3
3
|
attr_reader :parser
|
4
|
-
def initialize(*
|
5
|
-
@parser =
|
6
|
-
uri.each do |u|
|
7
|
-
@parser.load_uri!(u)
|
8
|
-
end
|
4
|
+
def initialize(*uris)
|
5
|
+
@parser = load_uris(uris)
|
9
6
|
end
|
10
7
|
|
11
8
|
def colors
|
@@ -18,22 +15,27 @@ module DryCss
|
|
18
15
|
|
19
16
|
private
|
20
17
|
|
18
|
+
def load_uris(uris)
|
19
|
+
parser = DryCss::Parser.new
|
20
|
+
threads = []
|
21
|
+
uris.each do |u|
|
22
|
+
threads << Thread.new(u) do |uri|
|
23
|
+
parser.load_uri!(uri)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
threads.each{|thr| thr.join }
|
27
|
+
return parser
|
28
|
+
end
|
29
|
+
|
21
30
|
def scan_for(property)
|
22
|
-
|
23
|
-
@values_hash = {:counts => {}, :total => 0}
|
31
|
+
values_hash = {:counts => Hash.new(0), :total => 0}
|
24
32
|
@parser.each_selector do |selector, declarations, specificity|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@values_hash[:counts].merge!(val[1].to_sym => 1)
|
29
|
-
else
|
30
|
-
@values_hash[:counts][val[1].to_sym] += 1
|
31
|
-
end
|
32
|
-
@values_hash[:total] += 1
|
33
|
-
end
|
33
|
+
declarations.scan(/([\w-]+):[ ]?(#{property})/) do |prop,val|
|
34
|
+
values_hash[:counts][val.to_sym] += 1
|
35
|
+
values_hash[:total] += 1
|
34
36
|
end
|
35
37
|
end
|
36
|
-
return
|
38
|
+
return values_hash
|
37
39
|
end
|
38
40
|
|
39
41
|
end
|
data/lib/dry_css/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry_css
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gpxl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|