om 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +25 -0
- data/.rvmrc +33 -0
- data/COMMON_OM_PATTERNS.textile +14 -0
- data/GETTING_FANCY.textile +143 -0
- data/GETTING_STARTED.textile +216 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +7 -1
- data/History.textile +4 -0
- data/QUERYING_DOCUMENTS.textile +134 -0
- data/README.textile +19 -10
- data/Rakefile +7 -28
- data/UPDATING_DOCUMENTS.textile +3 -0
- data/lib/om/samples/mods_article.rb +30 -15
- data/lib/om/version.rb +3 -0
- data/lib/om/xml/document.rb +1 -0
- data/lib/om/xml/term.rb +8 -0
- data/lib/om/xml/terminology.rb +10 -0
- data/lib/om.rb +5 -1
- data/lib/tasks/om.rake +56 -0
- data/om.gemspec +19 -207
- data/spec/unit/document_spec.rb +7 -1
- data/spec/unit/nokogiri_sanity_spec.rb +75 -0
- metadata +41 -523
data/Rakefile
CHANGED
@@ -1,30 +1,9 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
gem.name = "om"
|
8
|
-
gem.summary = %Q{OM (Opinionated Metadata): A library to help you tame sprawling XML schemas like MODS.}
|
9
|
-
gem.description = %Q{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}
|
10
|
-
gem.email = "matt.zumwalt@yourmediashelf.com"
|
11
|
-
gem.homepage = "http://github.com/mediashelf/om"
|
12
|
-
gem.authors = ["Matt Zumwalt"]
|
13
|
-
|
14
|
-
gem.add_dependency('nokogiri', ">= 1.4.2")
|
15
|
-
|
16
|
-
gem.add_development_dependency "rspec", "<2.0.0"
|
17
|
-
gem.add_development_dependency "mocha", ">= 0.9.8"
|
18
|
-
gem.add_development_dependency "ruby-debug"
|
19
|
-
gem.add_development_dependency "jeweler"
|
20
|
-
gem.add_development_dependency "equivalent-xml", ">= 0.2.4"
|
21
|
-
|
22
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
23
|
-
end
|
24
|
-
Jeweler::GemcutterTasks.new
|
25
|
-
rescue LoadError
|
26
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
27
|
-
end
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
# adding tasks defined in lib/tasks
|
5
|
+
Dir.glob('lib/tasks/*.rake').each { |r| import r }
|
6
|
+
|
28
7
|
|
29
8
|
require 'spec/rake/spectask'
|
30
9
|
Spec::Rake::SpecTask.new(:spec) do |spec|
|
@@ -44,7 +23,7 @@ task :default => :spec
|
|
44
23
|
|
45
24
|
require 'rake/rdoctask'
|
46
25
|
Rake::RDocTask.new do |rdoc|
|
47
|
-
version =
|
26
|
+
version = Om::VERSION
|
48
27
|
|
49
28
|
rdoc.rdoc_dir = 'rdoc'
|
50
29
|
rdoc.title = "om #{version}"
|
@@ -5,44 +5,52 @@ class OM::Samples::ModsArticle
|
|
5
5
|
set_terminology do |t|
|
6
6
|
t.root(:path=>"mods", :xmlns=>"http://www.loc.gov/mods/v3", :schema=>"http://www.loc.gov/standards/mods/v3/mods-3-2.xsd")
|
7
7
|
|
8
|
+
|
8
9
|
t.title_info(:path=>"titleInfo") {
|
9
|
-
t.main_title(:path=>"title", :label=>"title")
|
10
|
-
t.language(:path=>{:attribute=>"lang"})
|
10
|
+
t.main_title(:index_as=>[:facetable],:path=>"title", :label=>"title")
|
11
|
+
t.language(:index_as=>[:facetable],:path=>{:attribute=>"lang"})
|
11
12
|
}
|
12
|
-
t.
|
13
|
-
|
14
|
-
t.topic
|
13
|
+
t.language{
|
14
|
+
t.lang_code(:index_as=>[:facetable], :path=>"languageTerm", :attributes=>{:type=>"code"})
|
15
15
|
}
|
16
|
-
t.
|
16
|
+
t.abstract
|
17
|
+
t.subject {
|
18
|
+
t.topic(:index_as=>[:facetable])
|
19
|
+
}
|
20
|
+
t.topic_tag(:proxy=>[:subject, :topic])
|
21
|
+
# t.topic_tag(:index_as=>[:facetable],:path=>"subject", :default_content_path=>"topic")
|
17
22
|
# This is a mods:name. The underscore is purely to avoid namespace conflicts.
|
18
23
|
t.name_ {
|
19
24
|
# this is a namepart
|
20
|
-
t.namePart(:
|
25
|
+
t.namePart(:type=>:string, :label=>"generic name")
|
21
26
|
# affiliations are great
|
22
27
|
t.affiliation
|
28
|
+
t.institution(:path=>"affiliation", :index_as=>[:facetable], :label=>"organization")
|
23
29
|
t.displayForm
|
24
30
|
t.role(:ref=>[:role])
|
25
|
-
t.description
|
31
|
+
t.description(:index_as=>[:facetable])
|
26
32
|
t.date(:path=>"namePart", :attributes=>{:type=>"date"})
|
27
33
|
t.last_name(:path=>"namePart", :attributes=>{:type=>"family"})
|
28
34
|
t.first_name(:path=>"namePart", :attributes=>{:type=>"given"}, :label=>"first name")
|
29
35
|
t.terms_of_address(:path=>"namePart", :attributes=>{:type=>"termsOfAddress"})
|
36
|
+
t.computing_id
|
30
37
|
t.name_content(:path=>"text()")
|
31
38
|
}
|
32
39
|
# lookup :person, :first_name
|
33
|
-
t.person(:ref=>:name, :attributes=>{:type=>"personal"})
|
34
|
-
t.
|
35
|
-
t.
|
36
|
-
|
40
|
+
t.person(:ref=>:name, :attributes=>{:type=>"personal"}, :index_as=>[:facetable])
|
41
|
+
t.department(:proxy=>[:person,:description],:index_as=>[:facetable])
|
42
|
+
t.organization(:ref=>:name, :attributes=>{:type=>"corporate"}, :index_as=>[:facetable])
|
43
|
+
t.conference(:ref=>:name, :attributes=>{:type=>"conference"}, :index_as=>[:facetable])
|
37
44
|
t.role {
|
38
45
|
t.text(:path=>"roleTerm",:attributes=>{:type=>"text"})
|
39
46
|
t.code(:path=>"roleTerm",:attributes=>{:type=>"code"})
|
40
47
|
}
|
41
48
|
t.journal(:path=>'relatedItem', :attributes=>{:type=>"host"}) {
|
42
|
-
t.title_info
|
49
|
+
t.title_info(:index_as=>[:facetable],:ref=>[:title_info])
|
43
50
|
t.origin_info(:path=>"originInfo") {
|
44
51
|
t.publisher
|
45
52
|
t.date_issued(:path=>"dateIssued")
|
53
|
+
t.issuance(:index_as=>[:facetable])
|
46
54
|
}
|
47
55
|
t.issn(:path=>"identifier", :attributes=>{:type=>"issn"})
|
48
56
|
t.issue(:path=>"part") {
|
@@ -53,12 +61,19 @@ class OM::Samples::ModsArticle
|
|
53
61
|
t.start
|
54
62
|
t.end
|
55
63
|
}
|
56
|
-
t.publication_date(:path=>"date")
|
57
64
|
t.start_page(:proxy=>[:pages, :start])
|
58
65
|
t.end_page(:proxy=>[:pages, :end])
|
66
|
+
t.publication_date(:path=>"date")
|
59
67
|
}
|
60
68
|
}
|
61
|
-
|
69
|
+
t.note
|
70
|
+
t.location(:path=>"location") {
|
71
|
+
t.url(:path=>"url")
|
72
|
+
}
|
73
|
+
t.publication_url(:proxy=>[:location,:url])
|
74
|
+
t.peer_reviewed(:proxy=>[:journal,:origin_info,:issuance], :index_as=>[:facetable])
|
75
|
+
t.title(:proxy=>[:mods,:title_info, :main_title])
|
76
|
+
t.journal_title(:proxy=>[:journal, :title_info, :main_title])
|
62
77
|
end
|
63
78
|
|
64
79
|
# Changes from OM::Properties implementation
|
data/lib/om/version.rb
ADDED
data/lib/om/xml/document.rb
CHANGED
@@ -42,6 +42,7 @@ module OM::XML::Document
|
|
42
42
|
|
43
43
|
klass.send(:include, OM::XML::Container)
|
44
44
|
klass.send(:include, OM::XML::TermValueOperators)
|
45
|
+
klass.send(:include, OM::XML::Validation)
|
45
46
|
end
|
46
47
|
|
47
48
|
# Applies the property's corresponding xpath query, returning the result Nokogiri::XML::NodeSet
|
data/lib/om/xml/term.rb
CHANGED
@@ -1,7 +1,15 @@
|
|
1
|
+
# Special options: data_type, attributes, index_as
|
2
|
+
# is_root_term
|
3
|
+
#
|
1
4
|
class OM::XML::Term
|
2
5
|
|
3
6
|
# Term::Builder Class Definition
|
4
7
|
#
|
8
|
+
# @example
|
9
|
+
# tb2 = OM::XML::Term::Builder.new("my_term_name").path("fooPath").attributes({:lang=>"foo"}).index_as([:searchable, :facetable]).required(true).data_type(:text)
|
10
|
+
#
|
11
|
+
#
|
12
|
+
#
|
5
13
|
# When coding against Builders, remember that they rely on MethodMissing,
|
6
14
|
# so any time you call a method on the Builder that it doesn't explicitly recognize,
|
7
15
|
# the Builder will add your method & arguments to the it's settings and return itself.
|
data/lib/om/xml/terminology.rb
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# When you're defining a Terminology, you will usually use a "Terminology Builder":OM/XML/Terminology/Builder.html to create it
|
2
|
+
# Each line you put into a "Terminology Builder":OM/XML/Terminology/Builder.html is passed to the constructor for a "Term Builder":OM/XML/Term/Builder.html.
|
3
|
+
# See the "OM::XML::Term::Builder":OM/XML/Term/Builder.html API docs for complete description of your options for defining each Term.
|
4
|
+
#
|
5
|
+
# The most important thing to define in a Terminology is the root term. This is the place where you set namespaces and schemas for the Terminology
|
6
|
+
# @example Define a Terminology with a root term "mods", a default namespace of "http://www.loc.gov/mods/v3" and a schema of "http://www.loc.gov/standards/mods/v3/mods-3-2.xsd" (schema is optional)
|
7
|
+
# terminology_builder = OM::XML::Terminology::Builder.new do |t|
|
8
|
+
# t.root(:path=>"mods", :xmlns=>"http://www.loc.gov/mods/v3", :schema=>"http://www.loc.gov/standards/mods/v3/mods-3-2.xsd")
|
9
|
+
# end
|
10
|
+
# terminology = terminology_builder.build
|
1
11
|
class OM::XML::Terminology
|
2
12
|
|
3
13
|
class BadPointerError < StandardError; end
|
data/lib/om.rb
CHANGED
@@ -54,6 +54,10 @@ module OM
|
|
54
54
|
end
|
55
55
|
return flat_array
|
56
56
|
end
|
57
|
+
|
58
|
+
def self.version
|
59
|
+
Om::VERSION
|
60
|
+
end
|
57
61
|
end
|
58
62
|
|
59
63
|
module OM::XML; end
|
@@ -61,5 +65,5 @@ module OM::XML; end
|
|
61
65
|
require "om/tree_node"
|
62
66
|
require "om/xml"
|
63
67
|
require "om/samples"
|
64
|
-
|
68
|
+
require "om/version"
|
65
69
|
|
data/lib/tasks/om.rake
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
desc "Task to execute builds on a Hudson Continuous Integration Server."
|
2
|
+
task :hudson do
|
3
|
+
Rake::Task["om:doc"].invoke
|
4
|
+
Rake::Task["om:rcov"].invoke
|
5
|
+
Rake::Task["om:rspec"].invoke
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :om do
|
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']
|
14
|
+
end
|
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
|
22
|
+
end
|
23
|
+
|
24
|
+
# Use yard to build docs
|
25
|
+
begin
|
26
|
+
require 'yard'
|
27
|
+
require 'yard/rake/yardoc_task'
|
28
|
+
project_root = File.expand_path("#{File.dirname(__FILE__)}/../../")
|
29
|
+
doc_destination = File.join(project_root, 'doc')
|
30
|
+
|
31
|
+
YARD::Rake::YardocTask.new(:doc) do |yt|
|
32
|
+
readme_filename = 'README.textile'
|
33
|
+
textile_docs = []
|
34
|
+
Dir[File.join(project_root, "*.textile")].each_with_index do |f, index|
|
35
|
+
unless f.include?("/#{readme_filename}") # Skip readme, which is already built by the --readme option
|
36
|
+
textile_docs << '-'
|
37
|
+
textile_docs << f
|
38
|
+
end
|
39
|
+
end
|
40
|
+
yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) + textile_docs
|
41
|
+
# [ File.join(project_root, 'README.textile') ]
|
42
|
+
# [ File.join(project_root, 'README.textile'),'-', File.join(project_root,'GETTING_STARTED.textile') ]
|
43
|
+
yt.options = ['--output-dir', doc_destination, '--readme', readme_filename]
|
44
|
+
end
|
45
|
+
rescue LoadError
|
46
|
+
desc "Generate YARD Documentation"
|
47
|
+
task :doc do
|
48
|
+
abort "Please install the YARD gem to generate rdoc."
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
end
|
56
|
+
|
data/om.gemspec
CHANGED
@@ -1,218 +1,30 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "om/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
6
|
+
s.name = "om"
|
7
|
+
s.version = Om::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Matt Zumwalt"]
|
10
|
+
s.email = %q{matt.zumwalt@yourmediashelf.com}
|
11
|
+
s.homepage = %q{http://github.com/mediashelf/om}
|
12
|
+
s.summary = %q{OM (Opinionated Metadata): A library to help you tame sprawling XML schemas like MODS.}
|
13
13
|
s.description = %q{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}
|
14
|
-
|
14
|
+
|
15
|
+
s.add_dependency('nokogiri', ">= 1.4.2")
|
16
|
+
s.add_development_dependency "rspec", "<2.0.0"
|
17
|
+
s.add_development_dependency "mocha", ">= 0.9.8"
|
18
|
+
s.add_development_dependency "ruby-debug"
|
19
|
+
s.add_development_dependency "equivalent-xml", ">= 0.2.4"
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
24
|
s.extra_rdoc_files = [
|
16
25
|
"LICENSE",
|
17
26
|
"README.rdoc",
|
18
27
|
"README.textile"
|
19
28
|
]
|
20
|
-
s.files = [
|
21
|
-
".document",
|
22
|
-
"Gemfile",
|
23
|
-
"Gemfile.lock",
|
24
|
-
"History.textile",
|
25
|
-
"LICENSE",
|
26
|
-
"README.rdoc",
|
27
|
-
"README.textile",
|
28
|
-
"Rakefile",
|
29
|
-
"VERSION",
|
30
|
-
"container_spec.rb",
|
31
|
-
"lib/om.rb",
|
32
|
-
"lib/om/samples.rb",
|
33
|
-
"lib/om/samples/mods_article.rb",
|
34
|
-
"lib/om/tree_node.rb",
|
35
|
-
"lib/om/xml.rb",
|
36
|
-
"lib/om/xml/container.rb",
|
37
|
-
"lib/om/xml/document.rb",
|
38
|
-
"lib/om/xml/named_term_proxy.rb",
|
39
|
-
"lib/om/xml/node_generator.rb",
|
40
|
-
"lib/om/xml/template_registry.rb",
|
41
|
-
"lib/om/xml/term.rb",
|
42
|
-
"lib/om/xml/term_value_operators.rb",
|
43
|
-
"lib/om/xml/term_xpath_generator.rb",
|
44
|
-
"lib/om/xml/terminology.rb",
|
45
|
-
"lib/om/xml/validation.rb",
|
46
|
-
"lib/om/xml/vocabulary.rb",
|
47
|
-
"om.gemspec",
|
48
|
-
"spec/fixtures/CBF_MODS/ARS0025_016.xml",
|
49
|
-
"spec/fixtures/RUBRIC_mods_article_template.xml",
|
50
|
-
"spec/fixtures/mods-3-2.xsd",
|
51
|
-
"spec/fixtures/mods_articles/hydrangea_article1.xml",
|
52
|
-
"spec/fixtures/test_dummy_mods.xml",
|
53
|
-
"spec/integration/rights_metadata_integration_example_spec.rb",
|
54
|
-
"spec/spec.opts",
|
55
|
-
"spec/spec_helper.rb",
|
56
|
-
"spec/unit/container_spec.rb",
|
57
|
-
"spec/unit/document_spec.rb",
|
58
|
-
"spec/unit/named_term_proxy_spec.rb",
|
59
|
-
"spec/unit/node_generator_spec.rb",
|
60
|
-
"spec/unit/om_spec.rb",
|
61
|
-
"spec/unit/template_registry_spec.rb",
|
62
|
-
"spec/unit/term_builder_spec.rb",
|
63
|
-
"spec/unit/term_spec.rb",
|
64
|
-
"spec/unit/term_value_operators_spec.rb",
|
65
|
-
"spec/unit/term_xpath_generator_spec.rb",
|
66
|
-
"spec/unit/terminology_builder_spec.rb",
|
67
|
-
"spec/unit/terminology_spec.rb",
|
68
|
-
"spec/unit/validation_spec.rb",
|
69
|
-
"spec/unit/xml_spec.rb"
|
70
|
-
]
|
71
|
-
s.homepage = %q{http://github.com/mediashelf/om}
|
72
29
|
s.require_paths = ["lib"]
|
73
|
-
s.rubygems_version = %q{1.3.7}
|
74
|
-
s.summary = %q{OM (Opinionated Metadata): A library to help you tame sprawling XML schemas like MODS.}
|
75
|
-
s.test_files = [
|
76
|
-
"spec/integration/rights_metadata_integration_example_spec.rb",
|
77
|
-
"spec/spec_helper.rb",
|
78
|
-
"spec/unit/container_spec.rb",
|
79
|
-
"spec/unit/document_spec.rb",
|
80
|
-
"spec/unit/named_term_proxy_spec.rb",
|
81
|
-
"spec/unit/node_generator_spec.rb",
|
82
|
-
"spec/unit/om_spec.rb",
|
83
|
-
"spec/unit/template_registry_spec.rb",
|
84
|
-
"spec/unit/term_builder_spec.rb",
|
85
|
-
"spec/unit/term_spec.rb",
|
86
|
-
"spec/unit/term_value_operators_spec.rb",
|
87
|
-
"spec/unit/term_xpath_generator_spec.rb",
|
88
|
-
"spec/unit/terminology_builder_spec.rb",
|
89
|
-
"spec/unit/terminology_spec.rb",
|
90
|
-
"spec/unit/validation_spec.rb",
|
91
|
-
"spec/unit/xml_spec.rb"
|
92
|
-
]
|
93
|
-
|
94
|
-
if s.respond_to? :specification_version then
|
95
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
96
|
-
s.specification_version = 3
|
97
|
-
|
98
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
99
|
-
s.add_runtime_dependency(%q<om>, [">= 0"])
|
100
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
101
|
-
s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
|
102
|
-
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
103
|
-
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
104
|
-
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
105
|
-
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
106
|
-
s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
|
107
|
-
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
108
|
-
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
109
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
110
|
-
s.add_development_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
111
|
-
s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
|
112
|
-
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
113
|
-
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
114
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
115
|
-
s.add_development_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
116
|
-
s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
|
117
|
-
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
118
|
-
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
119
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
120
|
-
s.add_development_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
121
|
-
s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
|
122
|
-
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
123
|
-
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
124
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
125
|
-
s.add_development_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
126
|
-
s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
|
127
|
-
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
128
|
-
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
129
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
130
|
-
s.add_development_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
131
|
-
s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.2"])
|
132
|
-
s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
|
133
|
-
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
|
134
|
-
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
135
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
136
|
-
s.add_development_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
137
|
-
else
|
138
|
-
s.add_dependency(%q<om>, [">= 0"])
|
139
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
140
|
-
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
141
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
142
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
143
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
144
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
145
|
-
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
146
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
147
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
148
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
149
|
-
s.add_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
150
|
-
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
151
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
152
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
153
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
154
|
-
s.add_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
155
|
-
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
156
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
157
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
158
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
159
|
-
s.add_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
160
|
-
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
161
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
162
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
163
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
164
|
-
s.add_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
165
|
-
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
166
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
167
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
168
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
169
|
-
s.add_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
170
|
-
s.add_dependency(%q<nokogiri>, [">= 1.4.2"])
|
171
|
-
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
172
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
173
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
174
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
175
|
-
s.add_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
176
|
-
end
|
177
|
-
else
|
178
|
-
s.add_dependency(%q<om>, [">= 0"])
|
179
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
180
|
-
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
181
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
182
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
183
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
184
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
185
|
-
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
186
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
187
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
188
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
189
|
-
s.add_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
190
|
-
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
191
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
192
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
193
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
194
|
-
s.add_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
195
|
-
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
196
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
197
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
198
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
199
|
-
s.add_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
200
|
-
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
201
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
202
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
203
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
204
|
-
s.add_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
205
|
-
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
206
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
207
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
208
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
209
|
-
s.add_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
210
|
-
s.add_dependency(%q<nokogiri>, [">= 1.4.2"])
|
211
|
-
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
212
|
-
s.add_dependency(%q<mocha>, [">= 0.9.8"])
|
213
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
214
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
215
|
-
s.add_dependency(%q<equivalent-xml>, [">= 0.2.4"])
|
216
|
-
end
|
217
30
|
end
|
218
|
-
|
data/spec/unit/document_spec.rb
CHANGED
@@ -74,7 +74,13 @@ describe "OM::XML::Document" do
|
|
74
74
|
after(:all) do
|
75
75
|
Object.send(:remove_const, :DocumentTest)
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
|
+
it "should automatically include the necessary modules" do
|
79
|
+
DocumentTest.included_modules.should include(OM::XML::Container)
|
80
|
+
DocumentTest.included_modules.should include(OM::XML::TermValueOperators)
|
81
|
+
DocumentTest.included_modules.should include(OM::XML::Validation)
|
82
|
+
end
|
83
|
+
|
78
84
|
describe ".ox_namespaces" do
|
79
85
|
it "should merge terminology namespaces with document namespaces" do
|
80
86
|
@fixturemods.ox_namespaces.should == {"oxns"=>"http://www.loc.gov/mods/v3", "xmlns:ns2"=>"http://www.w3.org/1999/xlink", "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance", "xmlns:ns3"=>"http://www.loc.gov/mods/v3", "xmlns"=>"http://www.loc.gov/mods/v3"}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require "om"
|
3
|
+
|
4
|
+
describe "OM::XML::TermValueOperators" do
|
5
|
+
|
6
|
+
describe "find_by_terms" do
|
7
|
+
before(:each) do
|
8
|
+
@article = OM::Samples::ModsArticle.from_xml( fixture( File.join("mods_articles","hydrangea_article1.xml") ) )
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should do" do
|
12
|
+
@article.find_by_terms({:journal=>0}).length.should == 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "update_values" do
|
17
|
+
before(:each) do
|
18
|
+
@article = OM::Samples::ModsArticle.from_xml( fixture( File.join("mods_articles","hydrangea_article1.xml") ) )
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should respond with a hash of updated values and their indexes" do
|
22
|
+
test_args = {[{"person"=>"0"},"description"]=>{"-1"=>"mork", "1"=>"york"}}
|
23
|
+
result = @article.update_values(test_args)
|
24
|
+
result.should == {"person_0_description"=>{"0"=>"mork","1"=>"york"}}
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should update the xml in the specified datatsream and save those changes to Fedora" do
|
28
|
+
@article.term_values({:person=>0}, :first_name).should == ["GIVEN NAMES"]
|
29
|
+
test_args = {[{:person=>0}, :first_name]=>{"0"=>"Replacement FirstName"}}
|
30
|
+
@article.update_values(test_args)
|
31
|
+
@article.term_values({:person=>0}, :first_name).should == ["Replacement FirstName"]
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should update the xml according to the find_by_terms_and_values in the given hash" do
|
35
|
+
terms_update_hash = {[{":person"=>"0"}, "affiliation"]=>{"0"=>"affiliation1", "1"=>"affiliation2", "2"=>"affiliation3"}}
|
36
|
+
result = @article.update_values(terms_update_hash)
|
37
|
+
result.should == {"person_0_affiliation"=>{"0"=>"affiliation1", "1"=>"affiliation2", "2"=>"affiliation3"}}
|
38
|
+
|
39
|
+
# Trying again with a more complex update hash
|
40
|
+
terms_update_hash = {[{":person"=>"0"}, "affiliation"]=>{"0"=>"affiliation1", "1"=>"affiliation2", "2"=>"affiliation3"}, [{:person=>1}, :last_name]=>"Andronicus", [{"person"=>"1"},:first_name]=>["Titus"],[{:person=>1},:role]=>["otherrole1","otherrole2"] }
|
41
|
+
result = @article.update_values(terms_update_hash)
|
42
|
+
result.should == {"person_0_affiliation"=>{"0"=>"affiliation1", "1"=>"affiliation2", "2"=>"affiliation3"}, "person_1_last_name"=>{"0"=>"Andronicus"},"person_1_first_name"=>{"0"=>"Titus"}, "person_1_role"=>{"0"=>"otherrole1","1"=>"otherrole2"}}
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should work when you re-run the command" do
|
46
|
+
terms_update_hash = {[{":person"=>"0"}, "affiliation"]=>{"0"=>"affiliation1", "1"=>"affiliation2", "2"=>"affiliation3"}}
|
47
|
+
result = @article.update_values(terms_update_hash)
|
48
|
+
@article.term_values( {":person"=>"0"}, "affiliation" ).should == ["affiliation1", "affiliation2", "affiliation3"]
|
49
|
+
result.should == {"person_0_affiliation"=>{"0"=>"affiliation1", "1"=>"affiliation2", "2"=>"affiliation3"}}
|
50
|
+
|
51
|
+
# result = @article.update_values(terms_update_hash)
|
52
|
+
# result.should == {"person_0_affiliation"=>{"0"=>"affiliation1", "1"=>"affiliation2", "2"=>"affiliation3"}}
|
53
|
+
terms_update_hash = {[{":person"=>"0"}, "affiliation"]=>{"0"=>"affiliation1", "1"=>"affiliation2", "2"=>"affiliation3"}}
|
54
|
+
@article = OM::Samples::ModsArticle.from_xml( fixture( File.join("mods_articles","hydrangea_article1.xml") ) )
|
55
|
+
result = @article.update_values(terms_update_hash)
|
56
|
+
@article.term_values( {":person"=>"0"}, "affiliation" ).should == ["affiliation1", "affiliation2", "affiliation3"]
|
57
|
+
result.should == {"person_0_affiliation"=>{"0"=>"affiliation1", "1"=>"affiliation2", "2"=>"affiliation3"}}
|
58
|
+
result = @article.update_values(terms_update_hash)
|
59
|
+
|
60
|
+
terms_update_hash = {[{":person"=>"0"}, "affiliation"]=>{"0"=>"affiliation1", "1"=>"affiliation2", "2"=>"affiliation3"}}
|
61
|
+
@article = OM::Samples::ModsArticle.from_xml( fixture( File.join("mods_articles","hydrangea_article1.xml") ) )
|
62
|
+
result = @article.update_values(terms_update_hash)
|
63
|
+
@article.term_values( {":person"=>"0"}, "affiliation" ).should == ["affiliation1", "affiliation2", "affiliation3"]
|
64
|
+
result.should == {"person_0_affiliation"=>{"0"=>"affiliation1", "1"=>"affiliation2", "2"=>"affiliation3"}}
|
65
|
+
|
66
|
+
# Trying again with a more complex update hash
|
67
|
+
terms_update_hash = {[{":person"=>"0"}, "affiliation"]=>{"0"=>"affiliation1", "1"=>"affiliation2", "2"=>"affiliation3"}, [{:person=>1}, :last_name]=>"Andronicus", [{"person"=>"1"},:first_name]=>["Titus"],[{:person=>1},:role]=>["otherrole1","otherrole2"] }
|
68
|
+
result = @article.update_values(terms_update_hash)
|
69
|
+
result.should == {"person_0_affiliation"=>{"0"=>"affiliation1", "1"=>"affiliation2", "2"=>"affiliation3"}, "person_1_last_name"=>{"0"=>"Andronicus"},"person_1_first_name"=>{"0"=>"Titus"}, "person_1_role"=>{"0"=>"otherrole1","1"=>"otherrole2"}}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
end
|