mods_display 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +17 -4
- data/lib/mods_display/html.rb +2 -0
- data/lib/mods_display/version.rb +1 -1
- data/spec/fields/abstract_spec.rb +1 -1
- data/spec/fields/access_condition_spec.rb +3 -3
- data/spec/fields/audience_spec.rb +1 -1
- data/spec/fields/cartographics_spec.rb +1 -1
- data/spec/fields/collection_spec.rb +1 -1
- data/spec/fields/contact_spec.rb +1 -1
- data/spec/fields/contents_spec.rb +1 -1
- data/spec/fields/description_spec.rb +1 -1
- data/spec/fields/format_spec.rb +1 -1
- data/spec/fields/genre_spec.rb +1 -1
- data/spec/fields/identifier_spec.rb +1 -1
- data/spec/fields/imprint_spec.rb +2 -2
- data/spec/fields/language_spec.rb +1 -1
- data/spec/fields/location_spec.rb +1 -1
- data/spec/fields/name_spec.rb +1 -1
- data/spec/fields/note_spec.rb +1 -1
- data/spec/fields/related_item_spec.rb +1 -1
- data/spec/fields/resource_type_spec.rb +1 -1
- data/spec/fields/sub_title_spec.rb +1 -1
- data/spec/fields/title_spec.rb +1 -1
- data/spec/integration/html_spec.rb +17 -0
- metadata +13 -27
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8ec2c58c34a3f05225a077459d6cc226cd587a0a
|
4
|
+
data.tar.gz: c0e3f4e6e7533f5b25c0eb735f0bd0f5cfd9ea47
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 567d5eed25681658bf0cd94141d83b846d99b9d6698e20462f52a83a52f833c4e757fdb2da218c1c0decec854bc9b2651d044397685847e8547127afca49d8bb
|
7
|
+
data.tar.gz: f3e05076e40607b5ca914401feb0acce6aacf80ba43361bfbdb05aa535d4372fae6832910c0f805be6b422141d310c17e3e57dba4062afba21c980c3a9a8447e
|
data/README.md
CHANGED
@@ -144,15 +144,28 @@ Once installed, the class that included the `ControllerExtension` (`MyController
|
|
144
144
|
The basic render call will return the top-level ModsDisplay::HTML class object. Any String method (e.g. #html_safe) you call on this top-level object will be sent down to the #to_html method which will return the HTML for all the metadata in the MODS document.
|
145
145
|
|
146
146
|
render_mods_display(@model).to_html
|
147
|
-
|
148
|
-
You can abstract the main title by calling #title on the top-level HTML method
|
147
|
+
|
148
|
+
You can abstract the main (first) title by calling #title on the top-level HTML method
|
149
149
|
|
150
150
|
render_mods_display(@model).title
|
151
|
-
|
152
|
-
When getting JUST the main title out of the metadata, it will be useful to get the rest of the metadata without the main title. You can accomplish this by calling #body on the top-level HTML object.
|
151
|
+
|
152
|
+
When getting JUST the main (first) title out of the metadata, it will be useful to get the rest of the metadata without the main title. You can accomplish this by calling #body on the top-level HTML object.
|
153
153
|
|
154
154
|
render_mods_display(@model).body
|
155
155
|
|
156
|
+
## Advanced Usage
|
157
|
+
|
158
|
+
You can also access the array of ModsDisplay::Values objects for a given class directly by calling the name of the class. The class names are not always intuitive for public consumption so you may want to check the code the particular method to call.
|
159
|
+
|
160
|
+
render_mods_display(@model).abstract
|
161
|
+
=> [#<ModsDisplay::Values @label="Abstract", @values=["Hey. I'm an abstract."]>]
|
162
|
+
|
163
|
+
Given that this semantics that we're concerned with here are more about titles and data construction rather than XML it may be required that you find something by the label. A common example of this is the imprint class. The imprint class can retun other publication data that is not the imprint statement. You'll want to select (using your favorite enumerable method) the element in the array that is an imprint.
|
164
|
+
|
165
|
+
imprint = render_mods_display(@model).imprint.find do |data|
|
166
|
+
data.label == "Imprint"
|
167
|
+
end.values
|
168
|
+
|
156
169
|
## Contributing
|
157
170
|
|
158
171
|
1. Fork it
|
data/lib/mods_display/html.rb
CHANGED
@@ -44,6 +44,8 @@ class ModsDisplay::HTML
|
|
44
44
|
def method_missing(method_name, *args, &block)
|
45
45
|
if self.to_s.respond_to?(method_name)
|
46
46
|
self.to_html.send(method_name, *args, &block)
|
47
|
+
elsif mods_display_fields.include?(method_name)
|
48
|
+
mods_field(@xml, method_name).fields
|
47
49
|
else
|
48
50
|
super
|
49
51
|
end
|
data/lib/mods_display/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_abstract(mods_record)
|
4
|
-
ModsDisplay::Abstract.new(mods_record, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::Abstract.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::Abstract do
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_access_condition(mods_record)
|
4
|
-
ModsDisplay::AccessCondition.new(mods_record, ModsDisplay::Configuration::AccessCondition.new,
|
4
|
+
ModsDisplay::AccessCondition.new(mods_record, ModsDisplay::Configuration::AccessCondition.new, double("controller"))
|
5
5
|
end
|
6
6
|
def mods_display_versioned_access_condition(mods_record, version)
|
7
|
-
ModsDisplay::AccessCondition.new(mods_record, ModsDisplay::Configuration::AccessCondition.new{cc_license_version version},
|
7
|
+
ModsDisplay::AccessCondition.new(mods_record, ModsDisplay::Configuration::AccessCondition.new{cc_license_version version}, double("controller"))
|
8
8
|
end
|
9
9
|
def mods_display_non_ignore_access_condition(mods_record)
|
10
|
-
ModsDisplay::AccessCondition.new(mods_record, ModsDisplay::Configuration::AccessCondition.new{display!},
|
10
|
+
ModsDisplay::AccessCondition.new(mods_record, ModsDisplay::Configuration::AccessCondition.new{display!}, double("controller"))
|
11
11
|
end
|
12
12
|
|
13
13
|
describe ModsDisplay::AccessCondition do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_audience(mods_record)
|
4
|
-
ModsDisplay::Audience.new(mods_record, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::Audience.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::Contents do
|
@@ -3,7 +3,7 @@ require "fixtures/cartographics_fixtures"
|
|
3
3
|
include CartographicsFixtures
|
4
4
|
|
5
5
|
def mods_display_cartographics(mods)
|
6
|
-
ModsDisplay::Cartographics.new(mods, ModsDisplay::Configuration::Base.new,
|
6
|
+
ModsDisplay::Cartographics.new(mods, ModsDisplay::Configuration::Base.new, double("controller"))
|
7
7
|
end
|
8
8
|
|
9
9
|
describe ModsDisplay::Cartographics do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_collection(mods_record)
|
4
|
-
ModsDisplay::Collection.new(mods_record, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::Collection.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::Collection do
|
data/spec/fields/contact_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_contact(mods_record)
|
4
|
-
ModsDisplay::Contact.new(mods_record, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::Contact.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::Contact do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_contents(mods_record)
|
4
|
-
ModsDisplay::Contents.new(mods_record, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::Contents.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::Contents do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_description(mods)
|
4
|
-
ModsDisplay::Description.new(mods, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::Description.new(mods, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::Description do
|
data/spec/fields/format_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
def mods_display_format(mods)
|
3
|
-
ModsDisplay::Format.new(mods, ModsDisplay::Configuration::Base.new,
|
3
|
+
ModsDisplay::Format.new(mods, ModsDisplay::Configuration::Base.new, double("controller"))
|
4
4
|
end
|
5
5
|
|
6
6
|
describe ModsDisplay::Format do
|
data/spec/fields/genre_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_genre(mods_record)
|
4
|
-
ModsDisplay::Genre.new(mods_record, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::Genre.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::Abstract do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_id(mods_record)
|
4
|
-
ModsDisplay::Identifier.new(mods_record, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::Identifier.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::Note do
|
data/spec/fields/imprint_spec.rb
CHANGED
@@ -4,10 +4,10 @@ require "fixtures/imprint_fixtures"
|
|
4
4
|
include ImprintFixtures
|
5
5
|
|
6
6
|
def mods_display_imprint(mods_record)
|
7
|
-
ModsDisplay::Imprint.new(mods_record, ModsDisplay::Configuration::Imprint.new,
|
7
|
+
ModsDisplay::Imprint.new(mods_record, ModsDisplay::Configuration::Imprint.new, double("controller"))
|
8
8
|
end
|
9
9
|
def mods_display_format_date_imprint(mods_record)
|
10
|
-
ModsDisplay::Imprint.new(mods_record, ModsDisplay::Configuration::Imprint.new{full_date_format "(%Y) %B, %d"; short_date_format "%B (%Y)"},
|
10
|
+
ModsDisplay::Imprint.new(mods_record, ModsDisplay::Configuration::Imprint.new{full_date_format "(%Y) %B, %d"; short_date_format "%B (%Y)"}, double("controller"))
|
11
11
|
end
|
12
12
|
|
13
13
|
describe ModsDisplay::Imprint do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_language(mods_record)
|
4
|
-
ModsDisplay::Language.new(mods_record, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::Language.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::Language do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_location(mods_record)
|
4
|
-
ModsDisplay::Location.new(mods_record, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::Location.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::Note do
|
data/spec/fields/name_spec.rb
CHANGED
@@ -10,7 +10,7 @@ def mods_display_name_link(mods_record)
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def mods_display_name(mods_record)
|
13
|
-
ModsDisplay::Name.new(mods_record, ModsDisplay::Configuration::Base.new,
|
13
|
+
ModsDisplay::Name.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
14
14
|
end
|
15
15
|
|
16
16
|
describe ModsDisplay::Language do
|
data/spec/fields/note_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_note(mods_record)
|
4
|
-
ModsDisplay::Note.new(mods_record, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::Note.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::Note do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_item(mods_record)
|
4
|
-
ModsDisplay::RelatedItem.new(mods_record, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::RelatedItem.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::RelatedItem do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_resource_type(mods_record)
|
4
|
-
ModsDisplay::ResourceType.new(mods_record, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::ResourceType.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::ResourceType do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_sub_title(mods_record)
|
4
|
-
ModsDisplay::SubTitle.new(mods_record, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::SubTitle.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::SubTitle do
|
data/spec/fields/title_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
def mods_display_title(mods_record)
|
4
|
-
ModsDisplay::Title.new(mods_record, ModsDisplay::Configuration::Base.new,
|
4
|
+
ModsDisplay::Title.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::Title do
|
@@ -9,6 +9,7 @@ end
|
|
9
9
|
describe "HTML Output" do
|
10
10
|
before(:all) do
|
11
11
|
@multiple_titles = html_from_mods("<mods><titleInfo><title>Main Title</title></titleInfo><titleInfo type='alternative'><title>Alternate Title</title></titleInfo></mods>")
|
12
|
+
@abstract = html_from_mods("<mods><abstract>Hey. I'm an abstract.</abstract></mods>")
|
12
13
|
end
|
13
14
|
|
14
15
|
describe "titles" do
|
@@ -24,4 +25,20 @@ describe "HTML Output" do
|
|
24
25
|
@multiple_titles.body.should include("<dd>Alternate Title</dd>")
|
25
26
|
end
|
26
27
|
end
|
28
|
+
describe "individual fields" do
|
29
|
+
it "should return ModsDispaly::Values for the specefied field" do
|
30
|
+
fields = @abstract.abstract
|
31
|
+
fields.each do |field|
|
32
|
+
field.should be_a ModsDisplay::Values
|
33
|
+
end
|
34
|
+
fields.length.should eq 1
|
35
|
+
fields.first.values.should eq ["Hey. I'm an abstract."]
|
36
|
+
end
|
37
|
+
it "should return a blank array if no data is available for a specific field" do
|
38
|
+
@abstract.genre.should eq []
|
39
|
+
end
|
40
|
+
it "should not return a field that doesn't exist (and isn't a string)" do
|
41
|
+
-> {@abstract.not_a_real_field}.should raise_error NoMethodError
|
42
|
+
end
|
43
|
+
end
|
27
44
|
end
|
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mods_display
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jessie Keck
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: stanford-mods
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: MODS Display is a gem to centralize the display logic of MODS medadata.
|
@@ -146,33 +139,26 @@ files:
|
|
146
139
|
- spec/spec_helper.rb
|
147
140
|
homepage: ''
|
148
141
|
licenses: []
|
142
|
+
metadata: {}
|
149
143
|
post_install_message:
|
150
144
|
rdoc_options: []
|
151
145
|
require_paths:
|
152
146
|
- lib
|
153
147
|
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
-
none: false
|
155
148
|
requirements:
|
156
|
-
- -
|
149
|
+
- - '>='
|
157
150
|
- !ruby/object:Gem::Version
|
158
151
|
version: '0'
|
159
|
-
segments:
|
160
|
-
- 0
|
161
|
-
hash: 841363986478259673
|
162
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
-
none: false
|
164
153
|
requirements:
|
165
|
-
- -
|
154
|
+
- - '>='
|
166
155
|
- !ruby/object:Gem::Version
|
167
156
|
version: '0'
|
168
|
-
segments:
|
169
|
-
- 0
|
170
|
-
hash: 841363986478259673
|
171
157
|
requirements: []
|
172
158
|
rubyforge_project:
|
173
|
-
rubygems_version:
|
159
|
+
rubygems_version: 2.0.3
|
174
160
|
signing_key:
|
175
|
-
specification_version:
|
161
|
+
specification_version: 4
|
176
162
|
summary: The MODS Display gem allows implementers to configure a customized display
|
177
163
|
of MODS metadata. This display implements the specifications defined at Stanford
|
178
164
|
for how to display MODS.
|