om 2.1.2 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -0
- data/History.textile +6 -0
- data/gemfiles/gemfile.rails3 +11 -0
- data/gemfiles/gemfile.rails4 +10 -0
- data/lib/om.rb +1 -2
- data/lib/om/version.rb +1 -1
- data/lib/om/xml/term.rb +1 -0
- data/lib/om/xml/term_value_operators.rb +5 -3
- data/spec/integration/serialization_spec.rb +1 -2
- data/spec/unit/dynamic_node_spec.rb +11 -4
- data/spec/unit/term_value_operators_spec.rb +12 -7
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 047198eb8ea0cf1f0b32818fb21ea09be9f4edd7
|
4
|
+
data.tar.gz: 771c06c6304173f63d98db27a490eaf9adc38205
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7c61df6a42241e45281c0831dbf822282c2630a019617d13c3e8aca005e9b017a6b16adfb10541df0553091e272b428a90d73eb9a29a7c3f0816a863415aca5
|
7
|
+
data.tar.gz: 2d5a6d8d73f56fd06ac885a55468c38c62f642d3d5090ce7c1c7e81af32dc0f93183647a63bc5f919a771223df8347374846b8798b413fbdda66b761b7fd1c82
|
data/.travis.yml
ADDED
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
|
|
data/lib/om.rb
CHANGED
data/lib/om/version.rb
CHANGED
data/lib/om/xml/term.rb
CHANGED
@@ -29,7 +29,10 @@ module OM::XML::TermValueOperators
|
|
29
29
|
#
|
30
30
|
# @param [Hash] params
|
31
31
|
# @example
|
32
|
-
# {[{":person"=>"0"}, "role", "text"]=>
|
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
|
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
|
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(
|
12
|
-
t.foo(
|
13
|
-
t.date_created(:path=>'date.created'
|
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
|
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
|
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
|
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
|
403
|
-
@article.update_values([:title_info]=>{"0"=>"york", "1"=>
|
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
|
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-
|
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
|