om 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ h3. 1.5.3
2
+
3
+ HYDRA-657 OM Terms that share a name with methods on Nokogiri Builders have incorrect builder templates
4
+ HYDRA-674 XML Builder templates incorrect for :none attributes
5
+
1
6
  h3. 1.5.2
2
7
 
3
8
  HYDRA-742 Can't modify frozen string (parameters in rails 3.2, when using ruby 1.9.3)
@@ -1,3 +1,3 @@
1
1
  module Om
2
- VERSION = "1.5.2"
2
+ VERSION = "1.5.3"
3
3
  end
@@ -253,20 +253,23 @@ class OM::XML::Term
253
253
  end
254
254
  if !self.attributes.nil?
255
255
  self.attributes.merge(extra_attributes).each_pair do |k,v|
256
- node_options << "\'#{k}\'=>\'#{v}\'"
256
+ node_options << "\'#{k}\'=>\'#{v}\'" unless v == :none
257
257
  end
258
258
  end
259
- if self.path.include?(":")
260
- ns_prefix = self.path[0..path.index(":")-1]
261
- path_name = self.path[path.index(":")+1..-1]
262
- template = "xml['#{ns_prefix}'].#{path_name}( #{OM::XML.delimited_list(node_options)} )" + node_child_template
259
+ builder_ref = "xml"
260
+ builder_method = self.path
261
+ if builder_method.include?(":")
262
+ builder_ref = "xml['#{self.path[0..path.index(":")-1]}']"
263
+ builder_method = self.path[path.index(":")+1..-1]
263
264
  elsif !self.namespace_prefix.nil? and self.namespace_prefix != 'oxns'
264
- template = "xml['#{self.namespace_prefix}'].#{self.path}( #{OM::XML.delimited_list(node_options)} )" + node_child_template
265
+ builder_ref = "xml['#{self.namespace_prefix}']"
265
266
  elsif self.path.kind_of?(Hash) && self.path[:attribute]
266
- template = "xml.@#{self.path[:attribute]}( #{OM::XML.delimited_list(node_options)} )" + node_child_template
267
- else
268
- template = "xml.#{self.path}( #{OM::XML.delimited_list(node_options)} )" + node_child_template
267
+ builder_method = "@#{self.path[:attribute]}"
268
+ end
269
+ if Nokogiri::XML::Builder.method_defined? builder_method.to_sym
270
+ builder_method += "_"
269
271
  end
272
+ template = "#{builder_ref}.#{builder_method}( #{OM::XML.delimited_list(node_options)} )" + node_child_template
270
273
  return template.gsub( /:::(.*?):::/ ) { '#{'+$1+'}' }
271
274
  end
272
275
 
@@ -7,8 +7,10 @@ describe "OM::XML::Term" do
7
7
  @test_name_part = OM::XML::Term.new(:namePart, {}).generate_xpath_queries!
8
8
  @test_volume = OM::XML::Term.new(:volume, :path=>"detail", :attributes=>{:type=>"volume"}, :default_content_path=>"number")
9
9
  @test_date = OM::XML::Term.new(:namePart, :attributes=>{:type=> "date"})
10
+ @test_person = OM::XML::Term.new(:namePart, :attributes=>{:type=> :none})
10
11
  @test_affiliation = OM::XML::Term.new(:affiliation)
11
12
  @test_role_code = OM::XML::Term.new(:roleTerm, :attributes=>{:type=>"code"})
13
+ @test_type = OM::XML::Term.new(:class)
12
14
  end
13
15
 
14
16
  describe '#new' do
@@ -161,6 +163,7 @@ describe "OM::XML::Term" do
161
163
 
162
164
  it "should generate a template call for passing into the builder block (assumes 'xml' as the argument for the block)" do
163
165
  @test_date.xml_builder_template.should == 'xml.namePart( \'#{builder_new_value}\', \'type\'=>\'date\' )'
166
+ @test_person.xml_builder_template.should == 'xml.namePart( \'#{builder_new_value}\' )'
164
167
  @test_affiliation.xml_builder_template.should == 'xml.affiliation( \'#{builder_new_value}\' )'
165
168
  end
166
169
  it "should accept extra options" do
@@ -193,7 +196,10 @@ describe "OM::XML::Term" do
193
196
  @xml_lang_attribute_term = OM::XML::Term.new(:xml_lang_attribute, :path=>{:attribute=>"xml:lang"})
194
197
  @xml_lang_attribute_term.xml_builder_template.should == "xml.@xml:lang( '\#{builder_new_value}' )"
195
198
  end
196
-
199
+
200
+ it "should generate a template call for passing into the builder block (assumes 'xml' as the argument for the block) for terms that share a name with an existing method on the builder" do
201
+ @test_type.xml_builder_template.should == 'xml.class_( \'#{builder_new_value}\' )'
202
+ end
197
203
  end
198
204
 
199
205
  end
@@ -317,6 +317,7 @@ describe "OM::XML::Terminology" do
317
317
 
318
318
  it "should generate a template call for passing into the builder block (assumes 'xml' as the argument for the block)" do
319
319
  @test_full_terminology.xml_builder_template(:person,:date).should == 'xml.namePart( \'#{builder_new_value}\', \'type\'=>\'date\' )'
320
+ @test_full_terminology.xml_builder_template(:person,:person_id).should == 'xml.namePart( \'#{builder_new_value}\' )'
320
321
  @test_full_terminology.xml_builder_template(:name,:affiliation).should == 'xml.affiliation( \'#{builder_new_value}\' )'
321
322
  end
322
323
  it "should accept extra options" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: om
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-08 00:00:00.000000000 Z
12
+ date: 2012-02-16 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &70117103404700 !ruby/object:Gem::Requirement
16
+ requirement: &2169684040 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.4.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70117103404700
24
+ version_requirements: *2169684040
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mediashelf-loggable
27
- requirement: &70117103404020 !ruby/object:Gem::Requirement
27
+ requirement: &2169683620 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70117103404020
35
+ version_requirements: *2169683620
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70117103403040 !ruby/object:Gem::Requirement
38
+ requirement: &2169683080 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '2.0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70117103403040
46
+ version_requirements: *2169683080
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: mocha
49
- requirement: &70117103402480 !ruby/object:Gem::Requirement
49
+ requirement: &2169682580 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.9.8
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70117103402480
57
+ version_requirements: *2169682580
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: equivalent-xml
60
- requirement: &70117103401760 !ruby/object:Gem::Requirement
60
+ requirement: &2169682120 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 0.2.4
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70117103401760
68
+ version_requirements: *2169682120
69
69
  description: ! 'OM (Opinionated Metadata): A library to help you tame sprawling XML
70
70
  schemas like MODS. Wraps Nokogiri documents in objects with miscellaneous helper
71
71
  methods for doing things like retrieve generated xpath queries or look up properties
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  version: '0'
162
162
  requirements: []
163
163
  rubyforge_project:
164
- rubygems_version: 1.8.15
164
+ rubygems_version: 1.8.6
165
165
  signing_key:
166
166
  specification_version: 3
167
167
  summary: ! 'OM (Opinionated Metadata): A library to help you tame sprawling XML schemas