derelicte 0.0.3-java → 0.0.4-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/derelicte/inliner_job.rb +9 -1
- data/lib/derelicte/version.rb +1 -1
- data/spec/lib/derelicte/inliner_job_spec.rb +13 -0
- data/spec/spec_helper.rb +4 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e426ce2038b1ab10a4a8b8b5f9ee39c25764357
|
4
|
+
data.tar.gz: 13641a33960c37d27cec6bb94895a33e8a0cfe5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fe185930fe5c37c2a78b5abbfda68769f3cb9ca4212b1054de07d4b3d9a02adcb5ae93157bdfb77cd7f81f2cda7cdb570fd2f4fe9fc611dfbbfdc17a6b2665e
|
7
|
+
data.tar.gz: 5569eb9aa5a3a51767f2a69c0759332e9b1245ffdc40aaf73cb4784cac2f4aaa9940dcd875d05d744959d499671590e99e95eb56b9434dea0a00f9d4d7b3bfc3
|
@@ -19,7 +19,7 @@ module Derelicte
|
|
19
19
|
def apply_rules_to(element)
|
20
20
|
rules = assignments.get(element)
|
21
21
|
return nil if rules.nil? || rules.length == 0
|
22
|
-
rule_str = rules.map(&:to_s).map(&:chomp).join
|
22
|
+
rule_str = unique_rules(rules).map(&:to_s).map(&:chomp).join
|
23
23
|
element.set_attribute('style', rule_str)
|
24
24
|
end
|
25
25
|
|
@@ -34,5 +34,13 @@ module Derelicte
|
|
34
34
|
yield(element)
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
def unique_rules(rules)
|
39
|
+
hash = rules.inject({}) do |hash, rule|
|
40
|
+
hash[rule.property] = rule
|
41
|
+
hash
|
42
|
+
end
|
43
|
+
hash.values
|
44
|
+
end
|
37
45
|
end
|
38
46
|
end
|
data/lib/derelicte/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ::Derelicte::InlinerJob do
|
4
|
+
let(:doc) { ::Derelicte.doc_from_str('<p class="red">ohai</p>') }
|
5
|
+
let(:analyzer) { ::Derelicte.css_analyzer_from_str('p { color: #ffffff; } .red { color: #ff0000; }') }
|
6
|
+
|
7
|
+
subject { described_class.new(doc, analyzer) }
|
8
|
+
|
9
|
+
it "does not duplicate style rules" do
|
10
|
+
subject.apply_rules_to_doc
|
11
|
+
expect(doc_style(doc, 'p')).to eq('color: #ff0000;')
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: derelicte
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Michael Ries
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- spec/files/ink_hero.html
|
115
115
|
- spec/files/simple_dom.html
|
116
116
|
- spec/files/xhtml_dom.html
|
117
|
+
- spec/lib/derelicte/inliner_job_spec.rb
|
117
118
|
- spec/lib/derelicte/inliner_spec.rb
|
118
119
|
- spec/lib/derelicte_spec.rb
|
119
120
|
- spec/spec_helper.rb
|
@@ -150,6 +151,7 @@ test_files:
|
|
150
151
|
- spec/files/ink_hero.html
|
151
152
|
- spec/files/simple_dom.html
|
152
153
|
- spec/files/xhtml_dom.html
|
154
|
+
- spec/lib/derelicte/inliner_job_spec.rb
|
153
155
|
- spec/lib/derelicte/inliner_spec.rb
|
154
156
|
- spec/lib/derelicte_spec.rb
|
155
157
|
- spec/spec_helper.rb
|