om 1.4.3 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,9 +2,11 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
+ gem 'ruby-debug', :platform => :ruby_18
6
+ gem 'ruby-debug19', :platform => :ruby_19
5
7
 
6
8
  group :development, :test do
7
9
  gem "rcov"
8
10
  gem "yard"
9
- gem "RedCloth"
11
+ gem "RedCloth", "~> 4.2.9"
10
12
  end
data/Gemfile.lock CHANGED
@@ -1,39 +1,65 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- om (1.3.0)
4
+ om (1.4.3)
5
5
  mediashelf-loggable
6
6
  nokogiri (>= 1.4.2)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- RedCloth (4.2.7)
12
- columnize (0.3.2)
13
- equivalent-xml (0.2.6)
11
+ RedCloth (4.2.9)
12
+ archive-tar-minitar (0.5.2)
13
+ columnize (0.3.5)
14
+ diff-lcs (1.1.3)
15
+ equivalent-xml (0.2.8)
14
16
  nokogiri (>= 1.4.3)
15
- linecache (0.43)
16
- mediashelf-loggable (0.4.7)
17
- mocha (0.9.12)
18
- nokogiri (1.4.4)
19
- rcov (0.9.9)
20
- rspec (1.3.1)
17
+ linecache (0.46)
18
+ rbx-require-relative (> 0.0.4)
19
+ linecache19 (0.5.12)
20
+ ruby_core_source (>= 0.1.4)
21
+ mediashelf-loggable (0.4.9)
22
+ metaclass (0.0.1)
23
+ mocha (0.10.0)
24
+ metaclass (~> 0.0.1)
25
+ nokogiri (1.5.0)
26
+ rbx-require-relative (0.0.5)
27
+ rcov (0.9.11)
28
+ rspec (2.7.0)
29
+ rspec-core (~> 2.7.0)
30
+ rspec-expectations (~> 2.7.0)
31
+ rspec-mocks (~> 2.7.0)
32
+ rspec-core (2.7.1)
33
+ rspec-expectations (2.7.0)
34
+ diff-lcs (~> 1.1.2)
35
+ rspec-mocks (2.7.0)
21
36
  ruby-debug (0.10.4)
22
37
  columnize (>= 0.1)
23
38
  ruby-debug-base (~> 0.10.4.0)
24
39
  ruby-debug-base (0.10.4)
25
40
  linecache (>= 0.3)
26
- yard (0.6.8)
41
+ ruby-debug-base19 (0.11.25)
42
+ columnize (>= 0.3.1)
43
+ linecache19 (>= 0.5.11)
44
+ ruby_core_source (>= 0.1.4)
45
+ ruby-debug19 (0.11.6)
46
+ columnize (>= 0.3.1)
47
+ linecache19 (>= 0.5.11)
48
+ ruby-debug-base19 (>= 0.11.19)
49
+ ruby_core_source (0.1.5)
50
+ archive-tar-minitar (>= 0.5.2)
51
+ yard (0.7.4)
27
52
 
28
53
  PLATFORMS
29
54
  ruby
30
55
 
31
56
  DEPENDENCIES
32
- RedCloth
57
+ RedCloth (~> 4.2.9)
33
58
  equivalent-xml (>= 0.2.4)
34
59
  mocha (>= 0.9.8)
35
60
  om!
36
61
  rcov
37
- rspec (< 2.0.0)
62
+ rspec (~> 2.0)
38
63
  ruby-debug
64
+ ruby-debug19
39
65
  yard
data/History.textile CHANGED
@@ -1,3 +1,16 @@
1
+ h3. 1.4.4
2
+
3
+ HYDRA-415 https://jira.duraspace.org/browse/HYDRA-415 Fixed insert of attribute nodes
4
+ update to rspec2
5
+ compatibility fixes for ruby 1.9
6
+ RedCloth updated to 4.2.9
7
+ Replace local 'delimited_list' logic with Array#join
8
+
9
+ h3. 1.4.3
10
+
11
+ HYDRA-681 https://jira.duraspace.org/browse/HYDRA-681 Om was calling .dirty when updating nodes, it should only do that when it's operating on a Nokogiri:Datastream
12
+ HYDRA-682 https://jira.duraspace.org/browse/HYDRA-682 Om first level terms support update
13
+
1
14
  h3. 1.4.2
2
15
 
3
16
  "HYDRA-667":https://jira.duraspace.org/browse/HYDRA-667 Fixed bug where updating nodes wasn't marking the document as dirty
data/Rakefile CHANGED
@@ -4,18 +4,8 @@ Bundler::GemHelper.install_tasks
4
4
  # adding tasks defined in lib/tasks
5
5
  Dir.glob('lib/tasks/*.rake').each { |r| import r }
6
6
 
7
-
8
- require 'spec/rake/spectask'
9
- Spec::Rake::SpecTask.new(:spec) do |spec|
10
- spec.libs << 'lib' << 'spec'
11
- spec.spec_files = FileList['spec/**/*_spec.rb']
12
- end
13
-
14
- Spec::Rake::SpecTask.new(:rcov) do |spec|
15
- spec.libs << 'lib' << 'spec'
16
- spec.pattern = 'spec/**/*_spec.rb'
17
- spec.rcov = true
18
- end
7
+ task :spec => ['om:rspec']
8
+ task :rcov => ['om:rcov']
19
9
 
20
10
  # task :spec => :check_dependencies
21
11
 
data/lib/om/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Om
2
- VERSION = "1.4.3"
2
+ VERSION = "1.4.4"
3
3
  end
data/lib/om/xml.rb CHANGED
@@ -23,7 +23,7 @@ module OM::XML
23
23
 
24
24
  # Transforms an array of values into a string delimited by +delimiter+
25
25
  def self.delimited_list( values_array, delimiter=", ")
26
- result = values_array.collect{|a| a + delimiter}.to_s.chomp(delimiter)
26
+ values_array.join(delimiter)
27
27
  end
28
28
 
29
29
  # Class Methods -- These methods will be available on classes that include this Module
@@ -20,6 +20,10 @@ module OM::XML::Container
20
20
  return tmpl
21
21
  end
22
22
 
23
+ # By default, new OM Document instances will create an empty xml document, but if you override self.xml_template to return a different object (e.g. Nokogiri::XML::Document), that will be created instead.
24
+ # You can make this method create the documents however you want as long as it returns a Nokogiri::XML::Document.
25
+ # In the tutorials, we use Nokogiri::XML::Builder in this mehtod and call its .doc method at the end of xml_template in order to return the Nokogiri::XML::Document object. Instead of using Nokogiri::XML::Builder, you could put your template into an actual xml file and have xml_template use Nokogiri::XML::Document.parse to load it. That’s up to you.
26
+ # @return Nokogiri::XML::Document
23
27
  def xml_template
24
28
  Nokogiri::XML::Document.parse("")
25
29
  end
@@ -50,11 +50,7 @@ class OM::XML::NamedTermProxy
50
50
 
51
51
  # Any unknown method calls will be proxied to the proxied term
52
52
  def method_missing method, *args, &block
53
- if args.empty?
54
- return self.proxied_term.send(method)
55
- else
56
- return self.proxied_term.send(method, args)
57
- end
53
+ return self.proxied_term.send(method, *args)
58
54
  end
59
55
 
60
- end
56
+ end
data/lib/om/xml/term.rb CHANGED
@@ -253,6 +253,8 @@ class OM::XML::Term
253
253
  template = "xml['#{ns_prefix}'].#{path_name}( #{OM::XML.delimited_list(node_options)} )" + node_child_template
254
254
  elsif !self.namespace_prefix.nil? and self.namespace_prefix != 'oxns'
255
255
  template = "xml['#{self.namespace_prefix}'].#{self.path}( #{OM::XML.delimited_list(node_options)} )" + node_child_template
256
+ elsif self.path.kind_of?(Hash) && self.path[:attribute]
257
+ template = "xml.@#{self.path[:attribute]}( #{OM::XML.delimited_list(node_options)} )" + node_child_template
256
258
  else
257
259
  template = "xml.#{self.path}( #{OM::XML.delimited_list(node_options)} )" + node_child_template
258
260
  end
@@ -138,8 +138,12 @@ module OM::XML::TermValueOperators
138
138
  builder = Nokogiri::XML::Builder.with(parent_node) do |xml|
139
139
  new_values.each do |builder_new_value|
140
140
  builder_new_value.gsub!(/'/, "\\\\'") # escape any apostrophes in the new value
141
- builder_arg = eval('"'+ template + '"') # this inserts builder_new_value into the builder template
142
- eval(builder_arg)
141
+ if matchdata = /xml\.@(\w+)/.match(template)
142
+ parent_node.set_attribute(matchdata[1], builder_new_value)
143
+ else
144
+ builder_arg = eval('"'+ template + '"') # this inserts builder_new_value into the builder template
145
+ eval(builder_arg)
146
+ end
143
147
  end
144
148
  end
145
149
  return parent_node
@@ -220,11 +220,9 @@ module OM::XML::TermXpathGenerator
220
220
  return xpath
221
221
  end
222
222
 
223
- # Turns an Array into a String containing values separated by a delimiter. Defaults to comma as a delimiter.
224
- # @param [Array] values_array to convert
225
- # @param [String] delimiter. Default: ", "
226
- def self.delimited_list( values_array, delimiter=", ")
227
- result = values_array.collect{|a| a + delimiter}.to_s.chomp(delimiter)
223
+ # @see OM::XML.delimited_list
224
+ def self.delimited_list(*args)
225
+ OM::XML.delimited_list(*args)
228
226
  end
229
227
 
230
228
  # Adds xpath xpath node index predicate to the end of your xpath query
data/lib/tasks/om.rake CHANGED
@@ -7,18 +7,16 @@ end
7
7
 
8
8
  namespace :om do
9
9
 
10
- require 'spec/rake/spectask'
11
- Spec::Rake::SpecTask.new(:rspec) do |spec|
12
- spec.libs << 'lib' << 'spec'
13
- spec.spec_files = FileList['spec/**/*_spec.rb']
10
+ require 'rspec/core/rake_task'
11
+ RSpec::Core::RakeTask.new(:rspec) do |spec|
12
+ spec.pattern = FileList['spec/**/*_spec.rb']
13
+ spec.pattern += FileList['spec/*_spec.rb']
14
14
  end
15
15
 
16
- require 'rcov/rcovtask'
17
- Spec::Rake::SpecTask.new(:rcov) do |spec|
18
- spec.libs << 'lib' << 'spec'
19
- spec.pattern = 'spec/**/*_spec.rb'
20
- spec.rcov_opts << "--exclude \"gems/*\" --rails"
21
- spec.rcov = true
16
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
17
+ spec.pattern = FileList['spec/**/*_spec.rb']
18
+ spec.pattern += FileList['spec/*_spec.rb']
19
+ spec.rcov = true
22
20
  end
23
21
 
24
22
  # Use yard to build docs
data/om.gemspec CHANGED
@@ -14,9 +14,8 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.add_dependency('nokogiri', ">= 1.4.2")
16
16
  s.add_dependency('mediashelf-loggable')
17
- s.add_development_dependency "rspec", "<2.0.0"
17
+ s.add_development_dependency "rspec", "~> 2.0"
18
18
  s.add_development_dependency "mocha", ">= 0.9.8"
19
- s.add_development_dependency "ruby-debug"
20
19
  s.add_development_dependency "equivalent-xml", ">= 0.2.4"
21
20
 
22
21
  s.files = `git ls-files`.split("\n")
data/spec/spec_helper.rb CHANGED
@@ -1,15 +1,11 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
1
  require 'om'
4
- require 'spec'
5
- require 'spec/autorun'
2
+ require 'rspec'
6
3
  require 'equivalent-xml/rspec_matchers'
7
- require 'ruby-debug'
8
4
 
9
- Spec::Runner.configure do |config|
5
+ RSpec.configure do |config|
10
6
  config.mock_with :mocha
11
7
  end
12
8
 
13
9
  def fixture(file)
14
10
  File.new(File.join(File.dirname(__FILE__), 'fixtures', file))
15
- end
11
+ end
@@ -22,6 +22,19 @@ describe "OM::XML::DynamicNode" do
22
22
  @article.abstract.should == ["My Abstract"]
23
23
  end
24
24
 
25
+ describe "setting attributes" do
26
+ it "when they exist" do
27
+ @article.title_info(0).main_title.main_title_lang = "ger"
28
+ @article.title_info(0).main_title.main_title_lang.should == ["ger"]
29
+ end
30
+ it "when they don't exist" do
31
+ title = @article.title_info(0)
32
+ title.language = "rus"
33
+ @article.title_info(0).language.should == ["rus"]
34
+ end
35
+
36
+ end
37
+
25
38
  it "should find elements two deep" do
26
39
  #TODO reimplement so that method_missing with name is only called once. Create a new method for name.
27
40
  @article.name.name_content.val.should == ["Describes a person"]
@@ -183,9 +183,8 @@ describe "OM::XML::Term" do
183
183
  end
184
184
 
185
185
  it "should support terms that are attributes" do
186
- pending "HYDRA-415"
187
186
  @type_attribute_term = OM::XML::Term.new(:type_attribute, :path=>{:attribute=>:type})
188
- @type_attribute_term.xml_builder_template.should == "TODO!"
187
+ @type_attribute_term.xml_builder_template.should == "xml.@type( '\#{builder_new_value}' )"
189
188
  end
190
189
 
191
190
  it "should support terms with namespaced attributes" do
@@ -194,9 +193,8 @@ describe "OM::XML::Term" do
194
193
  end
195
194
 
196
195
  it "should support terms that are namespaced attributes" do
197
- pending "HYDRA-415"
198
196
  @xml_lang_attribute_term = OM::XML::Term.new(:xml_lang_attribute, :path=>{:attribute=>"xml:lang"})
199
- @xml_lang_attribute_term.xml_builder_template.should == "TODO!"
197
+ @xml_lang_attribute_term.xml_builder_template.should == "xml.@xml:lang( '\#{builder_new_value}' )"
200
198
  end
201
199
 
202
200
  end
@@ -258,13 +258,13 @@ describe "OM::XML::TermValueOperators" do
258
258
  end
259
259
 
260
260
  it "should support adding attribute values" do
261
- pending
262
- pointer = [:title_info, :language]
261
+ pointer = [{:title_info=>0}, :language]
263
262
  test_val = "language value"
263
+ debugger
264
264
  @article.term_values_append(
265
- :parent_select => :title_info,
266
- :parent_index => :first,
267
- :template => [:title_info, :language],
265
+ :parent_select => [{:title_info=>0}],
266
+ :parent_index => 0,
267
+ :template => [{:title_info=>0}, :language],
268
268
  :values => test_val
269
269
  )
270
270
  @article.term_values(*pointer).first.should == test_val
@@ -123,11 +123,13 @@ describe "OM::XML::Terminology" do
123
123
  # role_term.xpath_constrained.should == '//oxns:name[contains(oxns:role/oxns:roleTerm, "#{constraint_value}")]'.gsub('"', '\"')
124
124
  end
125
125
 
126
- it "supports treating attributes as properties" do
127
- language_term = @test_full_terminology.retrieve_term(:title_info, :language)
128
- language_term.xpath.should == '//oxns:titleInfo/@lang'
129
- language_term.xpath_relative.should == '@lang'
130
- language_term.xpath_constrained.should == '//oxns:titleInfo/@lang[contains(., "#{constraint_value}")]'.gsub('"', '\"')
126
+ describe "treating attributes as properties" do
127
+ it "should build correct xpath" do
128
+ language_term = @test_full_terminology.retrieve_term(:title_info, :language)
129
+ language_term.xpath.should == '//oxns:titleInfo/@lang'
130
+ language_term.xpath_relative.should == '@lang'
131
+ language_term.xpath_constrained.should == '//oxns:titleInfo/@lang[contains(., "#{constraint_value}")]'.gsub('"', '\"')
132
+ end
131
133
  end
132
134
 
133
135
  it "should support deep nesting of properties" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: om
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 3
10
- version: 1.4.3
9
+ - 4
10
+ version: 1.4.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Zumwalt
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-19 00:00:00 -05:00
18
+ date: 2011-12-14 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -54,14 +54,13 @@ dependencies:
54
54
  requirement: &id003 !ruby/object:Gem::Requirement
55
55
  none: false
56
56
  requirements:
57
- - - <
57
+ - - ~>
58
58
  - !ruby/object:Gem::Version
59
- hash: 15
59
+ hash: 3
60
60
  segments:
61
61
  - 2
62
62
  - 0
63
- - 0
64
- version: 2.0.0
63
+ version: "2.0"
65
64
  type: :development
66
65
  version_requirements: *id003
67
66
  - !ruby/object:Gem::Dependency
@@ -80,24 +79,10 @@ dependencies:
80
79
  version: 0.9.8
81
80
  type: :development
82
81
  version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
- name: ruby-debug
85
- prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- hash: 3
92
- segments:
93
- - 0
94
- version: "0"
95
- type: :development
96
- version_requirements: *id005
97
82
  - !ruby/object:Gem::Dependency
98
83
  name: equivalent-xml
99
84
  prerelease: false
100
- requirement: &id006 !ruby/object:Gem::Requirement
85
+ requirement: &id005 !ruby/object:Gem::Requirement
101
86
  none: false
102
87
  requirements:
103
88
  - - ">="
@@ -109,7 +94,7 @@ dependencies:
109
94
  - 4
110
95
  version: 0.2.4
111
96
  type: :development
112
- version_requirements: *id006
97
+ version_requirements: *id005
113
98
  description: "OM (Opinionated Metadata): A library to help you tame sprawling XML schemas like MODS. Wraps Nokogiri documents in objects with miscellaneous helper methods for doing things like retrieve generated xpath queries or look up properties based on a simplified DSL"
114
99
  email: matt.zumwalt@yourmediashelf.com
115
100
  executables: []