scooby_snacks 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/Gemfile +6 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +54 -0
  6. data/Rakefile +2 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +8 -0
  9. data/examples/config/metadata.yml +283 -0
  10. data/examples/config/metadata/shared.yml +0 -0
  11. data/examples/example_config_1/README.md +7 -0
  12. data/examples/example_config_1/metadata.yml +96 -0
  13. data/examples/example_config_1/shared_schema.yml +93 -0
  14. data/examples/example_config_2/README.md +10 -0
  15. data/examples/example_config_2/metadata.yml +20 -0
  16. data/examples/example_config_2/metadata/local/classes.yml +25 -0
  17. data/examples/example_config_2/metadata/local/namespaces.yml +10 -0
  18. data/examples/example_config_2/metadata/local/properties.yml +61 -0
  19. data/examples/example_config_2/metadata/local/work_types.yml +25 -0
  20. data/examples/example_config_2/metadata/shared/geospatial_properties.yml +17 -0
  21. data/examples/example_config_2/metadata/shared/uc/classes.yml +32 -0
  22. data/examples/example_config_2/metadata/shared/uc/properties.yml +133 -0
  23. data/lib/generators/scooby_snacks/install/templates/metadata.yml +251 -0
  24. data/lib/scooby_snacks.rb +11 -0
  25. data/lib/scooby_snacks/blacklight_configuration.rb +68 -0
  26. data/lib/scooby_snacks/field.rb +174 -0
  27. data/lib/scooby_snacks/initialize.rb +4 -0
  28. data/lib/scooby_snacks/metadata_schema.rb +170 -0
  29. data/lib/scooby_snacks/presenter_behavior.rb +10 -0
  30. data/lib/scooby_snacks/solr_behavior.rb +71 -0
  31. data/lib/scooby_snacks/version.rb +3 -0
  32. data/lib/scooby_snacks/work_form_behavior.rb +36 -0
  33. data/lib/scooby_snacks/work_model_behavior.rb +35 -0
  34. data/scooby_snacks.gemspec +35 -0
  35. metadata +108 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b87091a22b0b5120938e906df166f14b6ae4de4a
4
+ data.tar.gz: 766c375f977bf1e44159f07d9727bb35f488040b
5
+ SHA512:
6
+ metadata.gz: 513ac55096f13424f39d50afe1b2a584298a506339d2f7af26e1d38c92c761c98e9262f91219e74473d4cddf1d64ca97fa775845c56ed9bab83955af9cde3ccd
7
+ data.tar.gz: 45fe49a08de19ca5d10c6fda5f55b379c9415719f59b0aed45ba746e1ee48642b98c080525686ebafc69adc440a18a0e517ea68a3a64a17fafa60efa44fef244
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in scooby_snacks.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Ned Henry
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # ScoobySnacks
2
+
3
+ This gem allows administrators of a Hyrax application to define their metadata schema in a human readable configuration file (or files). The Hyrax application is configured automatically with the metadata properties defined in the configuration file when the application loads. This makes it easy to update the metadata schema details in one place, and implementing changes only requires restarting the application.
4
+ Hopefully this approach will also make it easier to share metadata schema between institutions, and to write Samvera code that is independent of the details of a specific schema and is therefore more portable between institutions.
5
+
6
+ This project is currently designed on Hyrax 2.4.
7
+
8
+ The documentation for this gem is currently outdated. Some major updates to both the gem and the documentation are expected in Spring 2019.
9
+
10
+ ## Metadata Schema Configuration File & The M3 Project
11
+ The central goal of this gem is to define the metadata schema in a human readable configuration file. This includes all the attributes of each metadata property ("meta-metadata properties"). It is difficult to create a univerally functional and intuitive specification/format for this configuration file.
12
+ The M3 project is working to address this issue by creating a shared metadata schema specification in collaboration with several institutions. We plan to use the resulting specification in future versions of ScoobySnacks.
13
+ ScoobySnacks currently uses its own type of YML metadata schema configuration file whose specification/format is not very well documented (although it is fairly intuitive). Thie schema meets UCSC's immediate needs, but it may require extension for other instituions application specific needs.
14
+
15
+ ## The Name 'ScoobySnacks'
16
+
17
+ The name ScoobySnacks reflects the fact that this gem addresses a similar need to the ['dog-biscuits'](https://github.com/ULCC/dog_biscuits/wiki) gem, but takes a different approach. We plan to explore the possibility of merging the gems in the future, retaining the best aspects of each.
18
+
19
+ ## Installation
20
+
21
+ * First, install the gem by adding this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem 'scooby_snacks'
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ * Create a file called `config/initializers/metadata.rb` with the following contents:
32
+ ```ruby
33
+ ScoobySnacks::METADATA_SCHEMA = ScoobySnacks::MetadataSchema.new
34
+ ```
35
+
36
+ * In `app/controllers/catalog_controller.rb`,
37
+ * replace all `config.add_facet_field` lines related to your metadata schema with `ScoobySnacks::BlacklightConfiguration.add_facet_fields(config)`
38
+ * replace all `config.add_index_field` lines related to your metadata schema with
39
+ `ScoobySnacks::BlacklightConfiguration.add_search_result_display_fields(config)`
40
+ * replace all `config.add_show_field` lines related to your metadata schema with `ScoobySnacks::BlacklightConfiguration.add_show_fields(config)`
41
+ * replace all `config.add_search_field` lines related to your metadata schema with `ScoobySnacks::BlacklightConfiguration.add_search_fields(config)`
42
+ * replace all `config.add_sort_field` lines related to your metadata schema with `ScoobySnacks::BlacklightConfiguration.add_sort_fields(config)`
43
+
44
+ * In `app/models/solr_document.rb`, under the line `include Hyrax::SolrDocumentBehavior`, add the following:
45
+ ```ruby
46
+ include ScoobySnacks::SolrDocumentBehavior
47
+ ```
48
+
49
+ * The following three modifications need to be done for each of the work types you have defined in your application. Replace `WORK_TYPE` with the name of your work type, in lower case.
50
+ * In `app/forms/hyrax/WORK_TYPE_form.rb`, under the line `class {WORK_TYPE}Form < Hyrax::Forms::WorkForm`, include the following: `include ScoobySnacks::WorkFormBehavior`
51
+ * In `app/models/WORK_TYPE.rb`, comment out the line `include Hyrax::BasicMetadata` and add the folling underneath it: `include ScoobySnacks::WorkModelBehavior`
52
+
53
+ * In `app/presenters/WORK_TYPE_show_presenter.rb` (or wherever you define your custom presenter classes), include the following: `include ScoobySnacks::PresenterBehavior`
54
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "scooby_snacks"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,283 @@
1
+ #-------------------
2
+ # Other Schema Files
3
+ #-------------------
4
+ # This section specifies other configuration files that contain
5
+ # metadata information. Each other metadata file may contain
6
+ # any information that would be valid in this file. Schema information
7
+ # from all files is merged together.
8
+ # When possible, information from all files is combined. For example,
9
+ # if a property is defined in one file, it cannot be un-defined in
10
+ # another file, though more options can be added.
11
+ # Some options associated with properties can be defined in one file
12
+ # and overwritten by another. Options like this include 'required'
13
+ # and 'multiple'.
14
+ # Other options must be defined only once per property
15
+ # and cannot be overwritten. These include "predicate" and "definition".
16
+
17
+
18
+
19
+
20
+
21
+ #-------------------
22
+ # Property Settings
23
+ #-------------------
24
+ # This section defines every metadata property that can be used
25
+ # in the system. Individual work types may override some settings
26
+ # defined here. Predicates for each property should be defined
27
+ # here, and cannot be overridden once defined.
28
+
29
+ properties:
30
+
31
+ default:
32
+ definition: "This property has not yet been documented."
33
+ usage_note: "This is the default usage note for a metadata property. If you are seeing this in an active application, you need to define a usage note for your property."
34
+ usage_warning:
35
+ required: false
36
+ multiple: true
37
+ primary: false
38
+ hidden: false
39
+ work_title: false
40
+ input: scalar
41
+ range: RDF:Literal
42
+
43
+ title:
44
+ definition: "The title of the resource."
45
+ predicate: "DC:title"
46
+ label: "Title"
47
+ range: "rdfs:Literal"
48
+ required: true
49
+ primary: true
50
+ work_title: true
51
+
52
+ title_alternative:
53
+ definition: "An alternative title for the resource."
54
+ predicate: "DC:alternative"
55
+ range: "rdfs:Literal"
56
+ creator:
57
+ definition: "A person or organization responsible for creating the resource."
58
+ predicate: "DC:creator"
59
+ range: "Agent"
60
+ # vocabularies: "NAF, ULAN, Local"
61
+ primary: true
62
+ required: true
63
+ facet: true
64
+
65
+ contributor:
66
+ definition: "A person or organization responsible for making contributions to the resource."
67
+ predicate: "DC:contributor"
68
+ range: "Agent"
69
+ # vocabularies: "NAF, ULAN, Local"
70
+ facet: true
71
+
72
+ publisher:
73
+ definition: "An entity responsible for making the resource available."
74
+ predicate: "DC:publisher"
75
+ range: "Agent"
76
+ facet: true
77
+
78
+ description:
79
+ definition: "A summary or account of the resource."
80
+ predicate: "DC:description"
81
+ range: "rdfs:Literal"
82
+ primary: true
83
+
84
+ description_abstract:
85
+ definition: "A summary of the resource."
86
+ predicate: "DC:description"
87
+ range: "rdfs:Literal"
88
+
89
+ description_contents:
90
+ definition: "A list of subunits of the resource."
91
+ predicate: "DC:tableOfContents"
92
+ range: "rdfs:Literal"
93
+
94
+ scale:
95
+ definition: "Ratio of the dimensions of a form contained or embodied in a resource to the dimensions of the entity it represents, e.g., for images or cartographic resources."
96
+ predicate: "Bibframe:cartographicScale"
97
+ range: "rdfs:Literal"
98
+
99
+ subject:
100
+ definition: "The topic of the resource."
101
+ predicate: "DC:subject"
102
+ range: "skos:Concept"
103
+ # vocabularies: LCSH, NAF, ULAN, GNIS, AAT, Local
104
+ facet: true
105
+ primary: true
106
+
107
+ genre_form:
108
+ definition: "The genre, form, and/or physical characteristics of the resource being described. The material or physical carrier of the resource. Does not capture aboutness."
109
+ predicate: "DC:medium"
110
+ range: "skos:Concept"
111
+ # vocabularies: AAT
112
+ facet: true
113
+
114
+ coordinates:
115
+ definition: Spatial characteristics of the resource.
116
+ predicate: "DC:spatial"
117
+ range: Geospatial
118
+
119
+ date_created:
120
+ definition: "Date of creation of the resource."
121
+ predicate: "DC:created"
122
+ range: "edm:TimeSpan"
123
+ label: "Date Created"
124
+ primary: true
125
+ required: true
126
+
127
+ date_published:
128
+ definition: "Date of formal issuance (e.g., publication) of the resource."
129
+ predicate: "DC:issued"
130
+ range: "edm:TimeSpan"
131
+ label: "Date Published"
132
+
133
+ language:
134
+ definition: "A language of the resource."
135
+ predicate: "DC:language"
136
+ range: skos:concept
137
+
138
+ dcmi_type:
139
+ definition: "General nature or type of the resource (e.g., image, text, etc.). Does not capture aboutness."
140
+ predicate: "DC:type"
141
+ range: "skos:concept"
142
+ # vocabularies: DCMI
143
+ facet: true
144
+ # display_type: true
145
+
146
+ source:
147
+ definition: "Use to record and previous publication information, e.g., the place of publication and publisher name for a physical resource."
148
+ predicate: "DC:source"
149
+
150
+ physical_extent:
151
+ definition: "Physical dimensions of the source resource."
152
+ predicate: "DC:extent"
153
+
154
+ box_folder:
155
+ definition: "Location in the holding agency where the item is shelved or stored."
156
+ predicate: "BF2:physicalLocation"
157
+
158
+ accession_number:
159
+ definition: "An archival accession number for the resource."
160
+ predicate: "DC:identifier"
161
+ range: "rdfs:Literal"
162
+ # multiple: false
163
+
164
+ call_number:
165
+ definition: "A call number identifier for the resource."
166
+ predicate: "Bibframe:classification"
167
+ # multiple: false
168
+
169
+ donor_provenance:
170
+ definition: "A statement of any changes in ownership and custody of the resource since its creation that are significant for its authenticity, integrity, and interpretation."
171
+ predicate: "DC:provenance"
172
+ range: "rdf:Object"
173
+
174
+ rights_holder:
175
+ definition: "A person or organization owning or managing rights over the resource."
176
+ predicate: "DC:rightsHolder"
177
+ range: "rdf:Object"
178
+
179
+ rights_copyright_statement:
180
+ definition: "Information about rights held in and over the resource."
181
+ predicate: "DC:rights"
182
+ primary: true
183
+ required: true
184
+
185
+ rights_status:
186
+ definition: "Information about who can access the resource or an indication of its security status."
187
+ predicate: "DC:accessRights"
188
+ primary: true
189
+ required: true
190
+ facet: true
191
+
192
+ rights_license:
193
+ definition: "An associated license for the object (i.e. Creative Commons license, software licenses, etc.)."
194
+ predicate: "DC:license"
195
+
196
+ "collection_series":
197
+ definition: "A related resource in which the described resource is physically or logically included."
198
+ predicate: "DC:isPartOf"
199
+ facet: true
200
+
201
+ related_resource:
202
+ definition: "A resource related to this resource in a publicly visible way"
203
+ predicate: "DC:relation"
204
+ range: RelatedResource
205
+
206
+
207
+ #-------------------
208
+ # Class Settings
209
+ #-------------------
210
+ # This sections defines classes of nested objects defined in
211
+ # the system that are not PCDM works. These may be used as the objects
212
+ # of predicates, and may have their own predicates applied.
213
+ # Here, we define which properties are available to each Class.
214
+
215
+ classes:
216
+ Agent:
217
+ parent: "ActiveTripes::Resource"
218
+ rdf_label: "::RDF::Vocab::FOAF.Agent"
219
+ properties:
220
+ local_label:
221
+ definition: "If set, this is a local label for this agent to be indexed and displayed instead of any label fetched from remote authority"
222
+ predicate: 'skos:altLabel'
223
+ # Timespan:
224
+ # parent: "ActiveTripes::Resource"
225
+ # rdf_label: "::RDF::Vocab::FOAF.Agent"
226
+ # properties:
227
+ # label:
228
+ # definition: "A name or label for this timespan"
229
+ # predicate: "skos:prefLabel"
230
+ # begin:
231
+ # definition: "The time when a time period began or commenced."
232
+ # predicate: "edm:begin"
233
+ # end:
234
+ # definition: "The time when a time period ended."
235
+ # predicate: "edm:end"
236
+ # Link:
237
+ # properties:
238
+ # "label":
239
+ # definition: "The title of this resource to be displayed publicly"
240
+ # predicate: "skos:prefLabel"
241
+ # "linked_resource_type":
242
+ # definition: "The human-readable type of linked resource (e.g. finding aid)."
243
+ # predicate: "ucsd:relatedType"
244
+ # url:
245
+ # definition: "The address of the resource to link to"
246
+ # predicate: "schema:url"
247
+ # range: "xsd:anyURI"
248
+
249
+ #-------------------
250
+ # Work Type Settings
251
+ #-------------------
252
+ # Here we define metadata settings based on work type.
253
+ # This section specifies which properties (defined above)
254
+ # may be applied to each work type, and may specify display
255
+ # settings such as "required" or "hidden".
256
+ #
257
+ # In the future, this may be extended to actually define
258
+ # the work types for the application here.
259
+
260
+
261
+ work_types:
262
+ work:
263
+ properties:
264
+ title:
265
+ description:
266
+ required: true
267
+ creator:
268
+ contributor:
269
+ physical_extent:
270
+ # rights_license:
271
+ lecture:
272
+ course:
273
+ gdao_work:
274
+
275
+ #-------------------
276
+ # RDF Namespaces
277
+ #-------------------
278
+ # Here we can define additional namespaces for rdf predicates.
279
+ # The most common namespaces are predefined by the system, but
280
+ # this allows us to define more.
281
+
282
+ namespaces:
283
+ edm: "http://www.europeana.eu/schemas/edm/"
File without changes
@@ -0,0 +1,7 @@
1
+ # Simple Configuration Example
2
+
3
+ This example is an example of a simple metadata schema definition. A shared core metadata schema is used a few local customizations. Two simple work types are defined. No classes are defined outside of the PCDM.
4
+
5
+ # DISCLAIMER: NOT AN ACTUAL SCHEMA
6
+
7
+ This is an example of how one might specify a metadata schema using ScoobySnacks. It does not reflect any schema that UCSC has ever used or planned to use. Our developer made this up to demonstrate how the schema configuration files might work.
@@ -0,0 +1,96 @@
1
+ #-------------------
2
+ # Other Schema Files
3
+ #-------------------
4
+ # This section specifies other configuration files that contain
5
+ # metadata information. Files are loaded in order, and the
6
+ # directives in this file are loaded last.
7
+ # File paths are specified relative to the application's 'config' directory.
8
+ # Schema information from all files are merged together. Some options
9
+ # may be overridden in files loaded later.
10
+ # Other options must be defined only once per property
11
+ # and cannot be overwritten. These include "predicate" and "definition".
12
+
13
+ schema_files:
14
+ - shared_shema.yml
15
+
16
+
17
+
18
+ #-------------------
19
+ # Property Settings
20
+ #-------------------
21
+ # This section defines every metadata property that can be used
22
+ # in the system. Individual work types may override some settings
23
+ # defined here. Predicates for each property should be defined
24
+ # here, and cannot be overridden once defined.
25
+
26
+ properties:
27
+
28
+ call_number:
29
+ label: "Internal Idenfication Number"
30
+ usage_note: "Use this for both call numbers and GQQQWYKID numbers."
31
+
32
+ scale:
33
+ label: "Scale"
34
+ definition: "Ratio of the dimensions of a form contained or embodied in a resource to the dimensions of the entity it represents, e.g., for images or cartographic resources."
35
+ usage_note: "Use this for scales of maps, aerial photos, and/or scanned documents. "
36
+
37
+ predicate: "Bibframe:cartographicScale"
38
+ range: "rdfs:Literal"
39
+
40
+ date_published:
41
+ definition: "Date of formal issuance (e.g., publication) of the resource."
42
+ predicate: "DC:issued"
43
+ range: "edm:TimeSpan"
44
+ label: "Date Published"
45
+
46
+ date_created:
47
+ required: false
48
+
49
+ source:
50
+ label: "Provenance / Source"
51
+
52
+ #-------------------
53
+ # Work Type Settings
54
+ #-------------------
55
+ # Here we define metadata settings based on work type.
56
+ # This section specifies which properties (defined above)
57
+ # may be applied to each work type, and may specify display
58
+ # settings such as "required" or "hidden".
59
+ #
60
+ # In the future, this may be extended to actually define
61
+ # the work types for the application here.
62
+
63
+
64
+ work_types:
65
+ generic_work:
66
+ properties:
67
+ title:
68
+ description:
69
+ primary: true
70
+ required: true
71
+ creator:
72
+ primary: true
73
+ required: true
74
+ contributor:
75
+ primary: true
76
+ rights_license:
77
+ primary: true
78
+ magazine:
79
+ properties:
80
+ title:
81
+ description:
82
+ primary: true
83
+ required: true
84
+ creator:
85
+ primary: true
86
+ required: true
87
+ publisher:
88
+ primary: true
89
+ date_published:
90
+ primary: true
91
+ scale:
92
+ primary: true
93
+ contributor:
94
+ primary: true
95
+ rights_license:
96
+ primary: true