former 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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] = qs.select { |q| q[:query] != :text }
19
+ matches[node] ||= []
20
+ matches[node] += qs.select { |q| q[:query] != :text }
20
21
  end
21
22
  end
22
23
  end
@@ -1,3 +1,3 @@
1
1
  module Former
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -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.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-03-13 00:00:00.000000000 Z
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: 563730102464635682
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: 563730102464635682
122
+ hash: 3580307951476950466
123
123
  requirements: []
124
124
  rubyforge_project:
125
125
  rubygems_version: 1.8.25