derelicte 0.0.2-java → 0.0.3-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: 41cab4dd73d1b0a17862059bd4e9feca27472466
4
- data.tar.gz: 942726e6ad32e85600495157b9f77c563aa65d48
3
+ metadata.gz: 70fa4807988c11434a77e33b813f7878a10e75ac
4
+ data.tar.gz: ffc6a190da14f82bc9caaaa3b5a18461b7c7402d
5
5
  SHA512:
6
- metadata.gz: 09f486afd46ad9581d5ad2e52374cdf1a78a97e54d5c0ff041dc6c19948b1f7371f71365083190f80108a6f39c6d2ec1ce2bcb2e8629b221b9bfe0653c94d112
7
- data.tar.gz: 9b558ad919622a17d78e79d8167184b494ee369cd3f4cf7fee6c75eee17ca0f5360bd210584913d83ee757400a098510bbf8c42f52a544433d7ce49818e3aa22
6
+ metadata.gz: 4c9710f1daab033996894e4e2d3ce617c424657bb410d140ae3258bf4b281141a405641c5cbbd6ce6c4af2911dc13a123814a7861b055a259b9f0054b856d7c4
7
+ data.tar.gz: 097980411cf8095f4f365118b02acda9f35704539582ea1d4974632e01a0d4713afdf2cb8d0854aaff7e0fad903b987e4c134ae71607b422b84c234e1a7887e9
data/README.md CHANGED
@@ -34,6 +34,13 @@ Simplest possible usage:
34
34
  html = "<p>ohai</p>"
35
35
  css = "p { color: #ff0000; }"
36
36
 
37
- inliner = CSS::Inliner.new
38
- inlined_html = inliner.inline(html, css) # => "<p style=\"color: #ff0000;\">ohai</p>"
37
+ inlined_html = ::Derelicte.inline(html, css) # => "<p style=\"color: #ff0000;\">ohai</p>"
39
38
  ```
39
+
40
+ ## Roadmap
41
+
42
+ Some basic profiling shows that the current process spends about 1/3 of its time parsing the css rules and 1/3 of its time applying the rules to the DOM.
43
+
44
+ Future versions will probably have a threadsafe way of caching the parsed css files since you generally only have a couple of different css sources.
45
+
46
+ Future versions will also explore the possiblity of applying the rules to the DOM with raw java code to see how much of that time we can eliminate.
data/lib/derelicte.rb CHANGED
@@ -43,4 +43,8 @@ module Derelicte
43
43
  doc_str = serializer.write_to_string(doc)
44
44
  DOCTYPE + "\n" + doc_str
45
45
  end
46
+
47
+ def self.inline(html, css)
48
+ ::Derelicte::Inliner.new.inline(html,css)
49
+ end
46
50
  end
@@ -1,3 +1,3 @@
1
1
  module Derelicte
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe ::Derelicte do
4
+ subject { ::Derelicte }
5
+ let(:html) { 'html' }
6
+ let(:css) { 'css' }
7
+ let(:inlined) { 'inlined' }
8
+ let(:inliner) { ::Derelicte::Inliner.new }
9
+
10
+ it "has a convenience method for doing inlining" do
11
+ inliner.better_receive(:inline)
12
+ .with(html, css).and_return(inlined)
13
+
14
+ ::Derelicte::Inliner.better_receive(:new)
15
+ .with().and_return( inliner )
16
+
17
+ expect(subject.inline(html, css)).to eq(inlined)
18
+ end
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: derelicte
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: java
6
6
  authors:
7
7
  - Michael Ries
@@ -115,6 +115,7 @@ files:
115
115
  - spec/files/simple_dom.html
116
116
  - spec/files/xhtml_dom.html
117
117
  - spec/lib/derelicte/inliner_spec.rb
118
+ - spec/lib/derelicte_spec.rb
118
119
  - spec/spec_helper.rb
119
120
  homepage: https://github.com/hqmq/derelicte
120
121
  licenses:
@@ -150,4 +151,5 @@ test_files:
150
151
  - spec/files/simple_dom.html
151
152
  - spec/files/xhtml_dom.html
152
153
  - spec/lib/derelicte/inliner_spec.rb
154
+ - spec/lib/derelicte_spec.rb
153
155
  - spec/spec_helper.rb