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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70fa4807988c11434a77e33b813f7878a10e75ac
4
- data.tar.gz: ffc6a190da14f82bc9caaaa3b5a18461b7c7402d
3
+ metadata.gz: 1e426ce2038b1ab10a4a8b8b5f9ee39c25764357
4
+ data.tar.gz: 13641a33960c37d27cec6bb94895a33e8a0cfe5d
5
5
  SHA512:
6
- metadata.gz: 4c9710f1daab033996894e4e2d3ce617c424657bb410d140ae3258bf4b281141a405641c5cbbd6ce6c4af2911dc13a123814a7861b055a259b9f0054b856d7c4
7
- data.tar.gz: 097980411cf8095f4f365118b02acda9f35704539582ea1d4974632e01a0d4713afdf2cb8d0854aaff7e0fad903b987e4c134ae71607b422b84c234e1a7887e9
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
@@ -1,3 +1,3 @@
1
1
  module Derelicte
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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
@@ -12,3 +12,7 @@ def file_contents(basename)
12
12
  path = File.join( File.dirname(__FILE__), 'files', basename )
13
13
  File.read(path)
14
14
  end
15
+
16
+ def doc_style(doc, tag_name)
17
+ doc.get_elements_by_tag_name(tag_name).item(0).get_attribute('style')
18
+ end
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.3
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-21 00:00:00.000000000 Z
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