om 2.1.2 → 2.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 488ae138adaa9a02906a669cfd607f93f4a3579d
4
- data.tar.gz: 7ca3f44c638ead4ab8cf05d3f84e7a43cbfdc5b5
3
+ metadata.gz: 047198eb8ea0cf1f0b32818fb21ea09be9f4edd7
4
+ data.tar.gz: 771c06c6304173f63d98db27a490eaf9adc38205
5
5
  SHA512:
6
- metadata.gz: 1d0bc70088ba01c72ed720b3f3b5d2934688d69bbe366ea27ac027bae53e7c939b44c0c1736c033fc0a04f2c07deb75c316eb7be3d504adbf858c1a51a2ad1fd
7
- data.tar.gz: 0c2fda47f9a07f3802e24d636b7a60ca070c7db3d39de1503737a2fd3829f757f0805d1d6f90077db5ed99db0f895bfdb45f7aab0413f79e507ac43bfc7cebd6
6
+ metadata.gz: d7c61df6a42241e45281c0831dbf822282c2630a019617d13c3e8aca005e9b017a6b16adfb10541df0553091e272b428a90d73eb9a29a7c3f0816a863415aca5
7
+ data.tar.gz: 2d5a6d8d73f56fd06ac885a55468c38c62f642d3d5090ce7c1c7e81af32dc0f93183647a63bc5f919a771223df8347374846b8798b413fbdda66b761b7fd1c82
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+
5
+ gemfile:
6
+ - gemfiles/gemfile.rails3
7
+ - gemfiles/gemfile.rails4
8
+
9
+ notifications:
10
+ irc: "irc.freenode.org#projecthydra"
data/History.textile CHANGED
@@ -1,3 +1,9 @@
1
+ h3. 2.2.0 (20 June 2013)
2
+ Deprecate passing Hash values into DynamicNode#val= or
3
+ Document#update_attributes. This behavior will be removed in 3.0.0
4
+ Rails 4 support
5
+ Pass nil in order to remove a node (instead of blank string)
6
+
1
7
  h3. 2.1.2 (3 May 2013)
2
8
  Fix missing comma after exception
3
9
 
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec :path=>"../"
4
+
5
+ gem 'activemodel', '~> 3.2.13'
6
+
7
+ group :development, :test do
8
+ gem 'rcov', :platform => :mri_18
9
+ gem 'simplecov', :platform => :mri_19
10
+ gem 'simplecov-rcov', :platform => :mri_19
11
+ end
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec :path=>"../"
4
+
5
+ gem 'activemodel', '4.0.0.rc1'
6
+
7
+ group :development, :test do
8
+ gem 'simplecov', :platform => :mri_19
9
+ gem 'simplecov-rcov', :platform => :mri_19
10
+ end
data/lib/om.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'rubygems'
2
- require 'active_support/concern'
3
- require 'active_model/dirty'
2
+ require 'active_model'
4
3
  require 'deprecation'
5
4
  require 'nokogiri'
6
5
 
data/lib/om/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Om
2
- VERSION = "2.1.2"
2
+ VERSION = "2.2.1"
3
3
  end
data/lib/om/xml/term.rb CHANGED
@@ -91,6 +91,7 @@ class OM::XML::Term
91
91
 
92
92
  # @param val [String,Date,Integer]
93
93
  def serialize (val)
94
+ return if val.nil?
94
95
  case type
95
96
  when :date, :integer
96
97
  val.to_s
@@ -29,7 +29,10 @@ module OM::XML::TermValueOperators
29
29
  #
30
30
  # @param [Hash] params
31
31
  # @example
32
- # {[{":person"=>"0"}, "role", "text"]=>{"0"=>"role1", "1"=>"role2", "2"=>"role3"}, [{:person=>1}, :family_name]=>"Andronicus", [{"person"=>"1"},:given_name]=>["Titus"],[{:person=>1},:role,:text]=>["otherrole1","otherrole2"] }
32
+ # {[{":person"=>"0"}, "role", "text"]=>["role1", "role2", "role3"],
33
+ # [{:person=>1}, :family_name]=>"Andronicus",
34
+ # [{"person"=>"1"},:given_name]=>["Titus"],
35
+ # [{:person=>1},:role,:text]=>["otherrole1","otherrole2"] }
33
36
  def update_values(params={})
34
37
  # remove any terms from params that this datastream doesn't recognize
35
38
 
@@ -205,7 +208,6 @@ module OM::XML::TermValueOperators
205
208
 
206
209
  def term_value_update(node_select,node_index,new_value,opts={})
207
210
  ng_xml_will_change!
208
- # template = opts.fetch(:template,nil)
209
211
 
210
212
  node = find_by_terms_and_value(*node_select)[node_index]
211
213
  if delete_on_update?(node, new_value)
@@ -216,7 +218,7 @@ module OM::XML::TermValueOperators
216
218
  end
217
219
 
218
220
  def delete_on_update?(node, new_value)
219
- new_value == "" || new_value == :delete
221
+ new_value.nil? || new_value == :delete
220
222
  end
221
223
 
222
224
  # def term_value_set(term_ref, query_opts, node_index, new_value)
@@ -137,8 +137,7 @@ EOF
137
137
  <active>true</active>
138
138
  </outer>'
139
139
  end
140
- it "should serialize nil values" do
141
- # I'm not sure that this is the correct behavior for this. Should it remove nodes or just blank them.
140
+ it "should serialize empty string values" do
142
141
  subject.my_int = [nil]
143
142
  subject.my_date = [nil]
144
143
  subject.active = [nil]
@@ -8,13 +8,13 @@ describe "OM::XML::DynamicNode" do
8
8
 
9
9
  set_terminology do |t|
10
10
  t.root(:path=>"dc", :xmlns=>"http://purl.org/dc/terms/")
11
- t.creator( :namespace_prefix => "dcterms")
12
- t.foo(:namespace_prefix => "dcterms")
13
- t.date_created(:path=>'date.created', :namespace_prefix => "dcterms")
11
+ t.creator()
12
+ t.foo()
13
+ t.date_created(:path=>'date.created')
14
14
  end
15
15
 
16
16
  def self.xml_template
17
- Nokogiri::XML::Document.parse("<dc xmlns:dcterms='http://purl.org/dc/terms/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'/>")
17
+ Nokogiri::XML::Document.parse("<dc xmlns='http://purl.org/dc/terms/' />")
18
18
  end
19
19
 
20
20
  end
@@ -23,6 +23,7 @@ describe "OM::XML::DynamicNode" do
23
23
  after do
24
24
  Object.send(:remove_const, :Sample)
25
25
  end
26
+
26
27
  it "should create templates for dynamic nodes" do
27
28
  @sample.creator = "Foo"
28
29
  @sample.creator.should == ['Foo']
@@ -31,6 +32,12 @@ describe "OM::XML::DynamicNode" do
31
32
  @sample.creator = ["Foo", "Bar"]
32
33
  @sample.creator.should == ['Foo', 'Bar']
33
34
  end
35
+
36
+ it "should create templates for dynamic nodes with empty string values" do
37
+ @sample.creator = ['']
38
+ @sample.creator.should == ['']
39
+ end
40
+
34
41
  it "should create templates for plain nodes" do
35
42
  @sample.foo = ['in a galaxy far far away']
36
43
  @sample.foo.should == ['in a galaxy far far away']
@@ -45,6 +45,11 @@ describe "OM::XML::TermValueOperators" do
45
45
  person_1_roles[0].text.should == "otherrole1"
46
46
  person_1_roles[1].text.should == "otherrole2"
47
47
  end
48
+
49
+ it "should allow setting a blank string " do
50
+ @article.update_values({[:title_info, :main_title]=>['']})
51
+ @article.term_values(:title_info, :main_title).should == ["", "Artikkelin otsikko Hydrangea artiklan 1", "TITLE OF HOST JOURNAL"] end
52
+
48
53
  it "should call term_value_update if the corresponding node already exists" do
49
54
  @article.should_receive(:term_value_update).with('//oxns:titleInfo/oxns:title', 0, "My New Title")
50
55
  @article.update_values( {[:title_info, :main_title] => "My New Title"} )
@@ -208,7 +213,7 @@ describe "OM::XML::TermValueOperators" do
208
213
  @article.update_values(att)
209
214
  @article.term_values(:journal, :title_info).should == ['york', 'mangle', 'mork']
210
215
 
211
- @article.update_values({[:journal, :title_info]=>{"1"=>""}})
216
+ @article.update_values({[:journal, :title_info]=>{"1"=>nil}})
212
217
  @article.term_values(:journal, :title_info).should == ['york', 'mork']
213
218
 
214
219
  @article.update_values({[:journal, :title_info]=>{"0"=>:delete}})
@@ -224,11 +229,11 @@ describe "OM::XML::TermValueOperators" do
224
229
  end
225
230
 
226
231
  it "by default, setting to empty string deletes the node" do
227
- @article.update_values({[:journal, :title_info]=>{"1"=>""}})
232
+ @article.update_values({[:journal, :title_info]=>{"1"=>nil}})
228
233
  @article.term_values(:journal, :title_info).should == ['york', 'mork']
229
234
  end
230
235
 
231
- it "if delete_on_update? returns false, setting to empty string won't delete node" do
236
+ it "if delete_on_update? returns false, setting to nil won't delete node" do
232
237
  @article.stub('delete_on_update?').and_return(false)
233
238
  @article.update_values({[:journal, :title_info]=>{"1"=>""}})
234
239
  @article.term_values(:journal, :title_info).should == ['york', '', 'mork']
@@ -389,18 +394,18 @@ describe "OM::XML::TermValueOperators" do
389
394
  )
390
395
  1.should == 2
391
396
  end
392
- it "should delete nodes if value is :delete or empty string" do
397
+ it "should delete nodes if value is :delete or nil" do
393
398
  @article.update_values([:title_info]=>{"0"=>"york", "1"=>"mangle","2"=>"mork"})
394
399
  xpath = @article.class.terminology.xpath_for(:title_info)
395
400
 
396
- @article.term_value_update([:title_info], 1, "")
401
+ @article.term_value_update([:title_info], 1, nil)
397
402
  @article.term_values(:title_info).should == ['york', 'mork']
398
403
 
399
404
  @article.term_value_update([:title_info], 1, :delete)
400
405
  @article.term_values(:title_info).should == ['york']
401
406
  end
402
- it "should create empty nodes if value is nil" do
403
- @article.update_values([:title_info]=>{"0"=>"york", "1"=>nil,"2"=>"mork"})
407
+ it "should create empty nodes if value is empty string" do
408
+ @article.update_values([:title_info]=>{"0"=>"york", "1"=>'',"2"=>"mork"})
404
409
  @article.term_values(:title_info).should == ['york', "", "mork"]
405
410
  end
406
411
  end
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: 2.1.2
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-04 00:00:00.000000000 Z
12
+ date: 2013-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -206,6 +206,7 @@ extra_rdoc_files:
206
206
  files:
207
207
  - .document
208
208
  - .gitignore
209
+ - .travis.yml
209
210
  - COMMON_OM_PATTERNS.textile
210
211
  - GETTING_FANCY.textile
211
212
  - GETTING_STARTED.textile
@@ -218,6 +219,8 @@ files:
218
219
  - UPDATING_DOCUMENTS.textile
219
220
  - container_spec.rb
220
221
  - devel/notes.txt
222
+ - gemfiles/gemfile.rails3
223
+ - gemfiles/gemfile.rails4
221
224
  - lib/om.rb
222
225
  - lib/om/tree_node.rb
223
226
  - lib/om/version.rb