former 1.1.1 → 1.1.2
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.
- data/lib/former/builder.rb +2 -1
- data/lib/former/version.rb +1 -1
- data/test/builder_test.rb +12 -0
- metadata +4 -4
data/lib/former/builder.rb
CHANGED
@@ -16,7 +16,8 @@ module Former
|
|
16
16
|
node.traverse { |e| matches[e] = qs if e.text? and not matches.keys.include? e }
|
17
17
|
else
|
18
18
|
# otherwise, ignore just text requests
|
19
|
-
matches[node]
|
19
|
+
matches[node] ||= []
|
20
|
+
matches[node] += qs.select { |q| q[:query] != :text }
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
data/lib/former/version.rb
CHANGED
data/test/builder_test.rb
CHANGED
@@ -24,6 +24,11 @@ class AllTextParserNotBlank < Former::Builder
|
|
24
24
|
text { |e| not e.text.strip.empty? }
|
25
25
|
end
|
26
26
|
|
27
|
+
class DoubleImageMatch < Former::Builder
|
28
|
+
attr "img", :src
|
29
|
+
style_url "background-image"
|
30
|
+
end
|
31
|
+
|
27
32
|
class BuilderTest < Test::Unit::TestCase
|
28
33
|
def setup
|
29
34
|
@html_txt = '<p>some text<a class="important" href="http://alink.com">some link text<img src="/an/image/path"></a>last text</p>'
|
@@ -59,6 +64,13 @@ class BuilderTest < Test::Unit::TestCase
|
|
59
64
|
assert_equal "<p>\n</p><h1> </h1>other text<p></p>", p.to_html
|
60
65
|
end
|
61
66
|
|
67
|
+
def test_double_image_match
|
68
|
+
html = '<img alt="The dangers of vaccine denialism" class="left" src="http://img.washingtonpost.com/rf/image_90x60/2010-2019/WashingtonPost/2014/05/01/Editorial-Opinion/Images/Was8556714.jpg" style="display: block;">'
|
69
|
+
|
70
|
+
json = '[{"value":"http://img.washingtonpost.com/rf/image_90x60/2010-2019/WashingtonPost/2014/05/01/Editorial-Opinion/Images/Was8556714.jpg","nodename":"img","attr":"src"}]'
|
71
|
+
assert_equal DoubleImageMatch.new(html).to_json.to_s, json
|
72
|
+
end
|
73
|
+
|
62
74
|
def test_nohtml
|
63
75
|
p = Parser.new "some text that is long, and contains stuff!"
|
64
76
|
p.set_values :former_0 => "some other text"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: former
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
110
|
version: '0'
|
111
111
|
segments:
|
112
112
|
- 0
|
113
|
-
hash:
|
113
|
+
hash: 3580307951476950466
|
114
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
115
|
none: false
|
116
116
|
requirements:
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
segments:
|
121
121
|
- 0
|
122
|
-
hash:
|
122
|
+
hash: 3580307951476950466
|
123
123
|
requirements: []
|
124
124
|
rubyforge_project:
|
125
125
|
rubygems_version: 1.8.25
|