dry_css 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 715b08fff1108bbcfbd82a55c80c98f263c5338e
4
- data.tar.gz: 9ff80abc74feef65d18959150a3fec5dd4b759d6
3
+ metadata.gz: 44af193810a4b87478215fdb6963169300cc528f
4
+ data.tar.gz: b6981de3127f1432527294236d949b22bc9ada8d
5
5
  SHA512:
6
- metadata.gz: 8122f42b01fb9e686bfb2eb413854d04cb101681f1d857cbe9de1037f7a917a88941e5acce66f4ae6eff9409717048a0ba31d53e8986717bbeef03862f1e80f4
7
- data.tar.gz: 14c54241520404ce04304cc5792b35b9cc9e78f5861d0e505767ff1f2915459cf4e913cff5a545f0effbc4fd239a193d429bb0d4b9bcf8b34a33a44d74a7aa9a
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(*uri)
5
- @parser = DryCss::Parser.new
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
- @property = property
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
- if d_val = declarations.scan(/([\w-]+):[ ]?(#{@property})/)
26
- d_val.each do |val|
27
- if @values_hash[:counts][val[1].to_sym].nil?
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 @values_hash
38
+ return values_hash
37
39
  end
38
40
 
39
41
  end
@@ -1,3 +1,3 @@
1
1
  module DryCss
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
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.6
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-16 00:00:00.000000000 Z
11
+ date: 2013-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler