mods_display 0.0.1.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +26 -0
- data/README.md +136 -0
- data/Rakefile +5 -0
- data/lib/mods_display.rb +30 -0
- data/lib/mods_display/configuration.rb +73 -0
- data/lib/mods_display/configuration/base.rb +23 -0
- data/lib/mods_display/configuration/subject.rb +11 -0
- data/lib/mods_display/controller_extension.rb +32 -0
- data/lib/mods_display/fields/abstract.rb +32 -0
- data/lib/mods_display/fields/audience.rb +7 -0
- data/lib/mods_display/fields/cartographics.rb +21 -0
- data/lib/mods_display/fields/collection.rb +21 -0
- data/lib/mods_display/fields/contents.rb +7 -0
- data/lib/mods_display/fields/description.rb +30 -0
- data/lib/mods_display/fields/field.rb +89 -0
- data/lib/mods_display/fields/format.rb +34 -0
- data/lib/mods_display/fields/identifier.rb +60 -0
- data/lib/mods_display/fields/imprint.rb +68 -0
- data/lib/mods_display/fields/language.rb +33 -0
- data/lib/mods_display/fields/location.rb +25 -0
- data/lib/mods_display/fields/name.rb +97 -0
- data/lib/mods_display/fields/note.rb +49 -0
- data/lib/mods_display/fields/related_item.rb +24 -0
- data/lib/mods_display/fields/related_location.rb +14 -0
- data/lib/mods_display/fields/subject.rb +103 -0
- data/lib/mods_display/fields/title.rb +49 -0
- data/lib/mods_display/fields/values.rb +11 -0
- data/lib/mods_display/html.rb +87 -0
- data/lib/mods_display/model_extension.rb +20 -0
- data/lib/mods_display/version.rb +3 -0
- data/mods_display.gemspec +24 -0
- data/spec/configuration/base_spec.rb +29 -0
- data/spec/fields/abstract_spec.rb +21 -0
- data/spec/fields/audience_spec.rb +21 -0
- data/spec/fields/cartographics_spec.rb +39 -0
- data/spec/fields/collection_spec.rb +31 -0
- data/spec/fields/contents_spec.rb +21 -0
- data/spec/fields/description_spec.rb +37 -0
- data/spec/fields/format_spec.rb +35 -0
- data/spec/fields/identifier_spec.rb +49 -0
- data/spec/fields/imprint_spec.rb +78 -0
- data/spec/fields/language_spec.rb +55 -0
- data/spec/fields/location_spec.rb +25 -0
- data/spec/fields/name_spec.rb +88 -0
- data/spec/fields/note_spec.rb +53 -0
- data/spec/fields/related_item_spec.rb +37 -0
- data/spec/fields/related_location_spec.rb +31 -0
- data/spec/fields/subject_spec.rb +89 -0
- data/spec/fields/title_spec.rb +47 -0
- data/spec/fixtures/cartographics_fixtures.rb +52 -0
- data/spec/fixtures/imprint_fixtures.rb +89 -0
- data/spec/fixtures/name_fixtures.rb +3 -0
- data/spec/fixtures/subjects_fixtures.rb +70 -0
- data/spec/integration/configuration_spec.rb +37 -0
- data/spec/integration/installation_spec.rb +26 -0
- data/spec/spec_helper.rb +35 -0
- metadata +182 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
class TestConfigController
|
4
|
+
include ModsDisplay::ControllerExtension
|
5
|
+
|
6
|
+
configure_mods_display do
|
7
|
+
title do
|
8
|
+
label_class 'label-class'
|
9
|
+
value_class 'value-class'
|
10
|
+
link :link_to_title, "%value%"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def link_to_title(title)
|
15
|
+
"/path/to/title?#{title}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "Configuration" do
|
20
|
+
before(:all) do
|
21
|
+
xml = "<mods><titleInfo><title>The Title of this Item</title></titleInfo></mods>"
|
22
|
+
model = TestModel.new
|
23
|
+
model.modsxml = xml
|
24
|
+
controller = TestConfigController.new
|
25
|
+
@html = controller.render_mods_display(model)
|
26
|
+
end
|
27
|
+
it "should apply the label class" do
|
28
|
+
@html.should match(/<dt class='label-class' title=/)
|
29
|
+
end
|
30
|
+
it "should apply the value class" do
|
31
|
+
@html.scan(/<dd class='value-class'>/).length.should == 1
|
32
|
+
end
|
33
|
+
it "should apply the link" do
|
34
|
+
@html.scan(/<a href='\/path\/to\/title\?The Title of this Item'>The Title of this Item<\a>/)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Installation" do
|
4
|
+
before(:all) do
|
5
|
+
@pieces_of_data = 1
|
6
|
+
title_xml = "<mods><titleInfo><title>The Title of this Item</title></titleInfo></mods>"
|
7
|
+
model = TestModel.new
|
8
|
+
model.modsxml = title_xml
|
9
|
+
controller = TestController.new
|
10
|
+
@html = controller.render_mods_display(model)
|
11
|
+
end
|
12
|
+
it "should return a single <dl>" do
|
13
|
+
@html.scan(/<dl>/).length.should == 1
|
14
|
+
@html.scan(/<\/dl>/).length.should == 1
|
15
|
+
end
|
16
|
+
it "should return a dt/dd pair for each piece of metadata in the mods" do
|
17
|
+
@html.scan(/<dt/).length.should == @pieces_of_data
|
18
|
+
@html.scan(/<dd>/).length.should == @pieces_of_data
|
19
|
+
end
|
20
|
+
it "should return a proper label" do
|
21
|
+
@html.scan(/<dt title='Title'>Title:<\/dt>/).length.should == 1
|
22
|
+
end
|
23
|
+
it "should return a proper value" do
|
24
|
+
@html.scan(/<dd>The Title of this Item<\/dd>/).length.should == 1
|
25
|
+
end
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require "mods_display"
|
2
|
+
require "stanford-mods"
|
3
|
+
|
4
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
5
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
6
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
7
|
+
# loaded once.
|
8
|
+
#
|
9
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
12
|
+
config.run_all_when_everything_filtered = true
|
13
|
+
config.filter_run :focus
|
14
|
+
|
15
|
+
# Run specs in random order to surface order dependencies. If you find an
|
16
|
+
# order dependency and want to debug it, you can fix the order by providing
|
17
|
+
# the seed, which is printed after each run.
|
18
|
+
# --seed 1234
|
19
|
+
config.order = 'random'
|
20
|
+
end
|
21
|
+
class TestModel
|
22
|
+
attr_accessor :modsxml
|
23
|
+
include ModsDisplay::ModelExtension
|
24
|
+
mods_xml_source do |doc|
|
25
|
+
doc.modsxml
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class TestController
|
30
|
+
include ModsDisplay::ControllerExtension
|
31
|
+
|
32
|
+
def link_method(val)
|
33
|
+
"http://library.stanford.edu?#{val}"
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mods_display
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.beta1
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jessie Keck
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: stanford-mods
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: MODS Display is a gem to centralize the display logic of MODS medadata.
|
63
|
+
email:
|
64
|
+
- jessie.keck@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- .travis.yml
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- lib/mods_display.rb
|
76
|
+
- lib/mods_display/configuration.rb
|
77
|
+
- lib/mods_display/configuration/base.rb
|
78
|
+
- lib/mods_display/configuration/subject.rb
|
79
|
+
- lib/mods_display/controller_extension.rb
|
80
|
+
- lib/mods_display/fields/abstract.rb
|
81
|
+
- lib/mods_display/fields/audience.rb
|
82
|
+
- lib/mods_display/fields/cartographics.rb
|
83
|
+
- lib/mods_display/fields/collection.rb
|
84
|
+
- lib/mods_display/fields/contents.rb
|
85
|
+
- lib/mods_display/fields/description.rb
|
86
|
+
- lib/mods_display/fields/field.rb
|
87
|
+
- lib/mods_display/fields/format.rb
|
88
|
+
- lib/mods_display/fields/identifier.rb
|
89
|
+
- lib/mods_display/fields/imprint.rb
|
90
|
+
- lib/mods_display/fields/language.rb
|
91
|
+
- lib/mods_display/fields/location.rb
|
92
|
+
- lib/mods_display/fields/name.rb
|
93
|
+
- lib/mods_display/fields/note.rb
|
94
|
+
- lib/mods_display/fields/related_item.rb
|
95
|
+
- lib/mods_display/fields/related_location.rb
|
96
|
+
- lib/mods_display/fields/subject.rb
|
97
|
+
- lib/mods_display/fields/title.rb
|
98
|
+
- lib/mods_display/fields/values.rb
|
99
|
+
- lib/mods_display/html.rb
|
100
|
+
- lib/mods_display/model_extension.rb
|
101
|
+
- lib/mods_display/version.rb
|
102
|
+
- mods_display.gemspec
|
103
|
+
- spec/configuration/base_spec.rb
|
104
|
+
- spec/fields/abstract_spec.rb
|
105
|
+
- spec/fields/audience_spec.rb
|
106
|
+
- spec/fields/cartographics_spec.rb
|
107
|
+
- spec/fields/collection_spec.rb
|
108
|
+
- spec/fields/contents_spec.rb
|
109
|
+
- spec/fields/description_spec.rb
|
110
|
+
- spec/fields/format_spec.rb
|
111
|
+
- spec/fields/identifier_spec.rb
|
112
|
+
- spec/fields/imprint_spec.rb
|
113
|
+
- spec/fields/language_spec.rb
|
114
|
+
- spec/fields/location_spec.rb
|
115
|
+
- spec/fields/name_spec.rb
|
116
|
+
- spec/fields/note_spec.rb
|
117
|
+
- spec/fields/related_item_spec.rb
|
118
|
+
- spec/fields/related_location_spec.rb
|
119
|
+
- spec/fields/subject_spec.rb
|
120
|
+
- spec/fields/title_spec.rb
|
121
|
+
- spec/fixtures/cartographics_fixtures.rb
|
122
|
+
- spec/fixtures/imprint_fixtures.rb
|
123
|
+
- spec/fixtures/name_fixtures.rb
|
124
|
+
- spec/fixtures/subjects_fixtures.rb
|
125
|
+
- spec/integration/configuration_spec.rb
|
126
|
+
- spec/integration/installation_spec.rb
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
homepage: ''
|
129
|
+
licenses: []
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ! '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
segments:
|
141
|
+
- 0
|
142
|
+
hash: 342028846867464473
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ! '>'
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: 1.3.1
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 1.8.24
|
152
|
+
signing_key:
|
153
|
+
specification_version: 3
|
154
|
+
summary: The MODS Display gem allows implementers to configure a customized display
|
155
|
+
of MODS metadata. This display implements the specifications defined at Stanford
|
156
|
+
for how to display MODS.
|
157
|
+
test_files:
|
158
|
+
- spec/configuration/base_spec.rb
|
159
|
+
- spec/fields/abstract_spec.rb
|
160
|
+
- spec/fields/audience_spec.rb
|
161
|
+
- spec/fields/cartographics_spec.rb
|
162
|
+
- spec/fields/collection_spec.rb
|
163
|
+
- spec/fields/contents_spec.rb
|
164
|
+
- spec/fields/description_spec.rb
|
165
|
+
- spec/fields/format_spec.rb
|
166
|
+
- spec/fields/identifier_spec.rb
|
167
|
+
- spec/fields/imprint_spec.rb
|
168
|
+
- spec/fields/language_spec.rb
|
169
|
+
- spec/fields/location_spec.rb
|
170
|
+
- spec/fields/name_spec.rb
|
171
|
+
- spec/fields/note_spec.rb
|
172
|
+
- spec/fields/related_item_spec.rb
|
173
|
+
- spec/fields/related_location_spec.rb
|
174
|
+
- spec/fields/subject_spec.rb
|
175
|
+
- spec/fields/title_spec.rb
|
176
|
+
- spec/fixtures/cartographics_fixtures.rb
|
177
|
+
- spec/fixtures/imprint_fixtures.rb
|
178
|
+
- spec/fixtures/name_fixtures.rb
|
179
|
+
- spec/fixtures/subjects_fixtures.rb
|
180
|
+
- spec/integration/configuration_spec.rb
|
181
|
+
- spec/integration/installation_spec.rb
|
182
|
+
- spec/spec_helper.rb
|