hydra-mods 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,10 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ group :test do
6
+ gem 'cucumber-rails', '>=1.2.0', :require=>false
7
+ gem 'rcov', :platform => :mri_18
8
+ gem 'simplecov', :platform => :mri_19
9
+ gem 'simplecov-rcov', :platform => :mri_19
10
+ end
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'hydra-mods'
6
- s.version = '0.0.1'
6
+ s.version = '0.0.2'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Matt Zumwalt, Bess Sadler, Julie Meloni, Naomi Dushay, Jessie Keck, John Scofield, Justin Coyne & many more. See https://github.com/projecthydra/hydra-head/contributors"]
9
9
  s.email = ["hydra-tech@googlegroups.com"]
@@ -11,7 +11,11 @@ Gem::Specification.new do |s|
11
11
  s.summary = "Hydra MODS components split out from hydra-head"
12
12
  s.description = "Hydra MODS components split out from hydra-head"
13
13
 
14
- s.add_dependency "hydra-head"
14
+ s.add_dependency 'active-fedora', "~>4.1"
15
+ s.add_development_dependency "rspec"
16
+ s.add_development_dependency "mocha"
17
+ s.add_development_dependency "rspec-rails"
18
+ s.add_development_dependency "cucumber"
15
19
 
16
20
  s.files = `git ls-files`.split("\n")
17
21
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -0,0 +1,37 @@
1
+ <mods version="3.4" xsi:schemaLocation="http://www.loc.gov/mods/v3
2
+ http://www.loc.gov/standards/mods/v3/mods-3-4.xsd" xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
+ <!-- this is meant to be a fairly simple MODS example. -->
4
+ <titleInfo>
5
+ <title>main title</title>
6
+ <subTitle>subtitle</subTitle>
7
+ </titleInfo>
8
+
9
+ <name type="personal">
10
+ <namePart type="family">Hydra</namePart>
11
+ <namePart type="given">Hubert</namePart>
12
+ <affiliation>Project Hydra</affiliation>
13
+ <role>
14
+ <roleTerm authority="marcrelator" type="text">Creator</roleTerm>
15
+ </role>
16
+ </name>
17
+ <name type="conference">
18
+ <namePart>some conference</namePart>
19
+ <role>
20
+ <roleTerm authority="marcrelator" type="text">Host</roleTerm>
21
+ </role>
22
+ </name>
23
+
24
+ <abstract>abstract</abstract>
25
+
26
+ <subject>
27
+ <topic>topic 1</topic>
28
+ <topic>topic 2</topic>
29
+ </subject>
30
+ <subject authority="authority source (RFCD, LCSH)">
31
+ <topic>authority controlled topic</topic>
32
+ </subject>
33
+
34
+ <identifier type="uri">http://projecthydra.org/testdata/</identifier>
35
+ <identifier type="doi">doi:10.1006/jmbi.1995.0238</identifier>
36
+
37
+ </mods>
@@ -0,0 +1,99 @@
1
+ <mods version="3.0" xsi:schemaLocation="http://www.loc.gov/mods/v3
2
+ http://www.loc.gov/standards/mods/v3/mods-3-0.xsd" xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
+
4
+ <titleInfo>
5
+ <nonSort>THE</nonSort>
6
+ <title>ARTICLE TITLE</title>
7
+ <subTitle>SUBTITLE</subTitle>
8
+ </titleInfo>
9
+ <titleInfo type="alternative">
10
+ <title>VARYING FORM OF TITLE</title>
11
+ </titleInfo>
12
+
13
+ <name type="personal">
14
+ <namePart type="family">FAMILY NAME</namePart>
15
+ <namePart type="given">GIVEN NAMES</namePart>
16
+ <namePart type="termsOfAddress">DR.</namePart>
17
+ <displayForm>NAME AS IT APPEARS</displayForm>
18
+ <affiliation>FACULTY, UNIVERSITY</affiliation>
19
+ <role>
20
+ <roleTerm authority="marcrelator" type="text">Creator</roleTerm>
21
+ </role>
22
+ </name>
23
+ <name type="personal">
24
+ <namePart type="family">Lacks</namePart>
25
+ <namePart type="given">Henrietta</namePart>
26
+ <displayForm>HeLa</displayForm>
27
+ <affiliation>Baltimore</affiliation>
28
+ <role>
29
+ <roleTerm authority="marcrelator" type="text">Contributor</roleTerm>
30
+ </role>
31
+ </name>
32
+ <name type="corporate">
33
+ <namePart>NSF</namePart>
34
+ <role>
35
+ <roleTerm authority="marcrelator" type="text">Funder</roleTerm>
36
+ </role>
37
+ </name>
38
+ <name type="conference">
39
+ <namePart>some conference</namePart>
40
+ <role>
41
+ <roleTerm authority="marcrelator" type="text">Host</roleTerm>
42
+ </role>
43
+ </name>
44
+
45
+ <typeOfResource>text</typeOfResource>
46
+ <genre authority="local">journal article</genre>
47
+
48
+ <abstract>ABSTRACT</abstract>
49
+ <subject>
50
+ <topic>TOPIC 1</topic>
51
+ <topic>TOPIC 2</topic>
52
+ </subject>
53
+ <subject authority="AUTHORITY SOURCE (RFCD, LCSH)">
54
+ <topic>CONTROLLED TERM</topic>
55
+ </subject>
56
+
57
+ <language>
58
+ <languageTerm authority="iso639-2b" type="code">en-aus </languageTerm>
59
+ </language>
60
+
61
+ <physicalDescription>
62
+ <internetMediaType>application/pdf</internetMediaType>
63
+ <extent>36 p.</extent>
64
+ </physicalDescription>
65
+
66
+ <relatedItem type="host">
67
+ <titleInfo>
68
+ <title>TITLE OF HOST JOURNAL</title>
69
+ </titleInfo>
70
+ <originInfo>
71
+ <publisher>PUBLISHER</publisher>
72
+ <dateIssued>DATE</dateIssued>
73
+ </originInfo>
74
+ <identifier type="issn">0013-8908</identifier>
75
+ <part>
76
+ <detail type="volume">
77
+ <number>2</number>
78
+ </detail>
79
+ <detail type="level">
80
+ <number>2</number>
81
+ </detail>
82
+ <extent unit="pages">
83
+ <start>195</start>
84
+ <end>230</end>
85
+ </extent>
86
+ <date>FEB. 2007</date>
87
+ </part>
88
+ </relatedItem>
89
+
90
+ <identifier type="uri">http://URL.edu.au/</identifier>
91
+ <identifier type="doi">doi:10.1006/jmbi.1995.0238</identifier>
92
+ <location>
93
+ <url>http://URL.edu.au/</url>
94
+ </location>
95
+ <accessCondition type="restrictionOnAccess">EMBARGO NOTE</accessCondition>
96
+ <accessCondition type="use and reproduction">OPEN ACCESS</accessCondition>
97
+
98
+ </mods>
99
+
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/combustion_test.sqlite
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ #
3
+ end
@@ -0,0 +1,3 @@
1
+ ActiveRecord::Schema.define do
2
+ #
3
+ end
@@ -0,0 +1 @@
1
+ *.log
File without changes
@@ -0,0 +1,29 @@
1
+ # Need way to find way to stub current_user and RoleMapper in order to run these tests
2
+ require 'spec_helper'
3
+
4
+
5
+ require 'hydra/datastream/mods_article'
6
+ describe Hydra::Datastream::CommonModsIndexMethods do
7
+
8
+ subject { Hydra::Datastream::ModsArticle.from_xml(fixture("mods_article.xml")) }
9
+
10
+ describe "extract_person_full_names" do
11
+ it "should return an array of Solr::Field objects for :person_full_name_facet" do
12
+ full_names = subject.extract_person_full_names
13
+ full_names.should be_kind_of Hash
14
+ full_names["person_full_name_facet"].should == ["FAMILY NAME, GIVEN NAMES", "Lacks, Henrietta"]
15
+ end
16
+ end
17
+ describe "extract_person_organizations" do
18
+ it "should return an array of Solr::Field objects for :mods_organization_facet" do
19
+ orgs = subject.extract_person_organizations
20
+ orgs.should be_kind_of Hash
21
+ orgs["mods_organization_facet"].should be_kind_of Array
22
+ orgs["mods_organization_facet"].length.should == 2
23
+ orgs["mods_organization_facet"].first.should == "FACULTY, UNIVERSITY"
24
+ orgs["mods_organization_facet"].last.should == "Baltimore"
25
+ end
26
+ end
27
+ end
28
+
29
+
@@ -0,0 +1,104 @@
1
+ require 'spec_helper'
2
+ require "nokogiri"
3
+
4
+ describe Hydra::Datastream::ModsBasic do
5
+
6
+ context "general behaviors" do
7
+ subject { Hydra::Datastream::ModsBasic.new(nil, nil) }
8
+
9
+ it "should be a kind of ActiveFedora::NokogiriDatastream" do
10
+ subject.should be_kind_of(ActiveFedora::NokogiriDatastream)
11
+ end
12
+
13
+ it "should include mods name behaviors" do
14
+ subject.class.included_modules.should include(Hydra::Datastream::CommonModsIndexMethods)
15
+ subject.should respond_to(:extract_person_full_names)
16
+ end
17
+
18
+ it "should have relator terms translation methods specific to this model" do
19
+ subject.class.should respond_to(:person_relator_terms)
20
+ subject.class.should respond_to(:conference_relator_terms)
21
+ subject.class.should respond_to(:organization_relator_terms)
22
+ end
23
+ end
24
+
25
+ MODS_NS = 'http://www.loc.gov/mods/v3'
26
+
27
+ context "creating new mods xml" do
28
+ subject { Hydra::Datastream::ModsBasic.new(nil, nil) }
29
+
30
+ it "should have an xml_template method returning desired xml" do
31
+ empty_xml = subject.class.xml_template
32
+ empty_xml.should be_a_kind_of(Nokogiri::XML::Document)
33
+ root = empty_xml.root
34
+ root.namespace.href.should == MODS_NS
35
+ root.get_attribute("version").should == "3.4"
36
+ # Ruby 1.8.7:
37
+ # root.get_attribute("xsi:schemaLocation").end_with?("http://www.loc.gov/standards/mods/v3/mods-3-4.xsd").should be_true
38
+ # Ruby 1.9.3:
39
+ #root.get_attribute("schemaLocation").end_with?("http://www.loc.gov/standards/mods/v3/mods-3-4.xsd").should be_true
40
+
41
+ # check some descendant nodes
42
+ title_node = root.at_xpath('mods:titleInfo/mods:title', {'mods' => MODS_NS} )
43
+ title_node.should_not be_nil
44
+ title_node.text.should == ""
45
+ personal_name_node = root.at_xpath("mods:name[@type='personal']", {'mods' => MODS_NS} )
46
+ personal_name_node.should_not be_nil
47
+ personal_name_node.text.should == ""
48
+ end
49
+ end
50
+
51
+
52
+ context "reading existing Mods xml" do
53
+ subject { Hydra::Datastream::ModsBasic.from_xml(fixture("example_mods.xml")) }
54
+
55
+ it "should get correct values from OM terminology" do
56
+ tests = [
57
+ [:main_title, 'main title'],
58
+ [[:title_info, :subtitle], 'subtitle'],
59
+
60
+ [:abstract, 'abstract'],
61
+
62
+ # FIXME: whitespace issues
63
+ # [[:subject, :topic], ['topic 1', 'topic 2', 'authority controlled topic']],
64
+ # [:topic_tag, ['topic 1', 'topic 2', 'authority controlled topic']],
65
+
66
+ [:identifier, ['http://projecthydra.org/testdata/', 'doi:10.1006/jmbi.1995.0238']],
67
+ [:doi, 'doi:10.1006/jmbi.1995.0238'],
68
+ [:uri, 'http://projecthydra.org/testdata/'],
69
+
70
+ [[:name, :namePart], ['Hydra', 'Hubert', 'some conference']],
71
+ [[:name, :last_name], 'Hydra'],
72
+ [[:person, :last_name], 'Hydra'],
73
+ [[:name, :first_name], 'Hubert'],
74
+ [[:person, :first_name], 'Hubert'],
75
+ # FIXME: whitespace issues
76
+ # [:role, ['Creator', 'Host']],
77
+ # [:person, 'Hydra Hubert Project Hydra Creator'],
78
+ # [:conference, 'some conference Host'],
79
+ ]
80
+
81
+ tests.each do |terms, exp|
82
+ terms = [terms] unless terms.class == Array
83
+ exp = [exp] unless exp.class == Array
84
+ subject.term_values(*terms).should == exp
85
+ end
86
+ end
87
+ end
88
+ =begin
89
+ context "updating Mods xml" do
90
+ it "should do something" do
91
+ pending "to be implemented"
92
+ end
93
+ it "should be able to insert new name nodes" do
94
+ pending "test to be implemented"
95
+ end
96
+ it "should be able to add additional topics" do
97
+ pending "to be implemented"
98
+ end
99
+ it "should be able to remove nodes, including the last of a node" do
100
+ pending "to be implemented"
101
+ end
102
+ end
103
+ =end
104
+ end
@@ -0,0 +1,49 @@
1
+ # -*- encoding : utf-8 -*-
2
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
3
+ # Has been customized by Blacklight to work when application is in one place,
4
+ # and actual spec/ stuff is in another (the blacklight gem checkout).
5
+
6
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'app', 'models'))
8
+
9
+ ENV["RAILS_ENV"] ||= 'test'
10
+
11
+
12
+ if ENV['COVERAGE'] and RUBY_VERSION =~ /^1.9/
13
+ require 'simplecov'
14
+ require 'simplecov-rcov'
15
+
16
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
17
+ SimpleCov.start do
18
+ add_filter "/test_support/"
19
+ add_filter "/tmp/"
20
+
21
+ add_filter do |source_file|
22
+ source_file.lines.count < 5
23
+ end
24
+ end
25
+ end
26
+
27
+ require 'combustion'
28
+ Combustion.initialize!
29
+ require 'rspec/rails'
30
+ require 'hydra/mods'
31
+ require 'hydra/datastream/common_mods_index_methods'
32
+ require 'hydra/datastream/mods_basic'
33
+
34
+ RSpec.configure do |config|
35
+ # == Mock Framework
36
+ #
37
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
38
+ #
39
+ config.mock_with :mocha
40
+
41
+ config.color_enabled = true
42
+
43
+ end
44
+
45
+ def fixture(file)
46
+ File.new(File.join(File.dirname(__FILE__), 'fixtures', file))
47
+ end
48
+
49
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-mods
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,17 +10,81 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-06-07 00:00:00.000000000 Z
13
+ date: 2012-06-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: hydra-head
16
+ name: active-fedora
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '4.1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '4.1'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rspec
17
33
  requirement: !ruby/object:Gem::Requirement
18
34
  none: false
19
35
  requirements:
20
36
  - - ! '>='
21
37
  - !ruby/object:Gem::Version
22
38
  version: '0'
23
- type: :runtime
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: mocha
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: rspec-rails
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: cucumber
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
24
88
  prerelease: false
25
89
  version_requirements: !ruby/object:Gem::Requirement
26
90
  none: false
@@ -43,7 +107,6 @@ files:
43
107
  - app/models/hydra/datastream/mods_dataset.rb
44
108
  - app/models/hydra/datastream/mods_generic_content.rb
45
109
  - app/models/hydra/datastream/mods_image.rb
46
- - app/models/mods_asset.rb
47
110
  - hydra-mods.gemspec
48
111
  - lib/hydra-mods.rb
49
112
  - lib/hydra/common_mods_index_methods.rb
@@ -54,6 +117,17 @@ files:
54
117
  - lib/hydra/mods_generic_content.rb
55
118
  - lib/hydra/mods_image.rb
56
119
  - lib/uva/mods_index_methods.rb
120
+ - spec/fixtures/example_mods.xml
121
+ - spec/fixtures/mods_article.xml
122
+ - spec/internal/config/database.yml
123
+ - spec/internal/config/routes.rb
124
+ - spec/internal/db/combustion_test.sqlite
125
+ - spec/internal/db/schema.rb
126
+ - spec/internal/log/.gitignore
127
+ - spec/internal/public/favicon.ico
128
+ - spec/models/common_mods_index_methods_spec.rb
129
+ - spec/models/mods_basic_ds_spec.rb
130
+ - spec/spec_helper.rb
57
131
  homepage: http://projecthydra.org
58
132
  licenses: []
59
133
  post_install_message:
@@ -1,24 +0,0 @@
1
- # An EXAMPLE Basic Model for Assets that conform to Hydra commonMetadata cModel and have basic MODS metadata (currently "Article" is the MODS exemplar)
2
- class ModsAsset < ActiveFedora::Base
3
-
4
- # declares a rightsMetadata datastream with type Hydra::Datastream::RightsMetadata
5
- # basically, it is another expression of
6
- # has_metadata :name => "rightsMetadata", :type => Hydra::Datastream::RightsMetadata
7
- include Hydra::ModelMixins::CommonMetadata
8
-
9
- ## Convenience methods for manipulating the rights metadata datastream
10
- include Hydra::ModelMixins::RightsMetadata
11
-
12
- # declares a descMetadata datastream with type Hydra::Datastream::ModsArticle
13
- # basically, it is another expression of
14
- # has_metadata :name => "descMetadata", :type => Hydra::Datastream::ModsArticle
15
- include Hydra::ModelMixins::ModsObject
16
-
17
- # adds helpful methods for basic hydra objects
18
- include Hydra::ModelMethods
19
-
20
- # adds file_objects methods
21
- include ActiveFedora::FileManagement
22
-
23
-
24
- end