nom-xml 0.1.0 → 0.1.1

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.
@@ -15,6 +15,9 @@ module Nom::XML::Decorators::Terminology
15
15
 
16
16
  xpath = t.local_xpath
17
17
 
18
+ xpath += "[#{t.options[:if]}]" if t.options[:if]
19
+ xpath += "[not(#{t.options[:unless]})]" if t.options[:unless]
20
+
18
21
  xpath += "[#{args.join('][')}]" unless args.empty?
19
22
 
20
23
  result = case self
@@ -30,9 +33,9 @@ module Nom::XML::Decorators::Terminology
30
33
  when m.nil?
31
34
  result
32
35
  when m.is_a?(Symbol)
33
- result.collect { |r| r.send(m) }
36
+ result.collect { |r| r.send(m) }.compact
34
37
  when m.is_a?(Proc)
35
- result.collect { |r| m.call(r) }
38
+ result.collect { |r| m.call(r) }.compact
36
39
  else
37
40
  raise "Unknown accessor class: #{m.class}"
38
41
  end
@@ -1,5 +1,5 @@
1
1
  module Nom
2
2
  module XML
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
@@ -25,6 +25,8 @@ describe "Nutrition" do
25
25
  t.c do |c|
26
26
  c.nested
27
27
  end
28
+
29
+ t.d :if => 'my-custom-function()'
28
30
  end
29
31
 
30
32
  xml.nom!
@@ -111,6 +113,24 @@ describe "Nutrition" do
111
113
 
112
114
  subject.asdf.should == 1
113
115
  end
116
+
117
+ it "should evaluate if" do
118
+ mock_term = mock(:local_xpath => '//asdf', :options => {:if => 'my-custom-function()' })
119
+ @term_accessors = { :asdf => mock_term }
120
+
121
+ subject.should_receive(:xpath).with('//asdf[my-custom-function()]', anything).and_return([1])
122
+
123
+ subject.asdf.should == [1]
124
+ end
125
+
126
+ it "should evaluate unless" do
127
+ mock_term = mock(:local_xpath => '//asdf', :options => {:unless => 'my-custom-function()' })
128
+ @term_accessors = { :asdf => mock_term }
129
+
130
+ subject.should_receive(:xpath).with('//asdf[not(my-custom-function())]', anything).and_return([1])
131
+
132
+ subject.asdf.should == [1]
133
+ end
114
134
  end
115
135
 
116
136
  describe "#terms" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nom-xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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: 2012-11-06 00:00:00.000000000 Z
12
+ date: 2012-11-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -174,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
174
174
  version: '0'
175
175
  segments:
176
176
  - 0
177
- hash: 2818954073322895052
177
+ hash: -2240857808020887200
178
178
  required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  none: false
180
180
  requirements:
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
183
  version: '0'
184
184
  segments:
185
185
  - 0
186
- hash: 2818954073322895052
186
+ hash: -2240857808020887200
187
187
  requirements: []
188
188
  rubyforge_project:
189
189
  rubygems_version: 1.8.23