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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +54 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/examples/config/metadata.yml +283 -0
- data/examples/config/metadata/shared.yml +0 -0
- data/examples/example_config_1/README.md +7 -0
- data/examples/example_config_1/metadata.yml +96 -0
- data/examples/example_config_1/shared_schema.yml +93 -0
- data/examples/example_config_2/README.md +10 -0
- data/examples/example_config_2/metadata.yml +20 -0
- data/examples/example_config_2/metadata/local/classes.yml +25 -0
- data/examples/example_config_2/metadata/local/namespaces.yml +10 -0
- data/examples/example_config_2/metadata/local/properties.yml +61 -0
- data/examples/example_config_2/metadata/local/work_types.yml +25 -0
- data/examples/example_config_2/metadata/shared/geospatial_properties.yml +17 -0
- data/examples/example_config_2/metadata/shared/uc/classes.yml +32 -0
- data/examples/example_config_2/metadata/shared/uc/properties.yml +133 -0
- data/lib/generators/scooby_snacks/install/templates/metadata.yml +251 -0
- data/lib/scooby_snacks.rb +11 -0
- data/lib/scooby_snacks/blacklight_configuration.rb +68 -0
- data/lib/scooby_snacks/field.rb +174 -0
- data/lib/scooby_snacks/initialize.rb +4 -0
- data/lib/scooby_snacks/metadata_schema.rb +170 -0
- data/lib/scooby_snacks/presenter_behavior.rb +10 -0
- data/lib/scooby_snacks/solr_behavior.rb +71 -0
- data/lib/scooby_snacks/version.rb +3 -0
- data/lib/scooby_snacks/work_form_behavior.rb +36 -0
- data/lib/scooby_snacks/work_model_behavior.rb +35 -0
- data/scooby_snacks.gemspec +35 -0
- metadata +108 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module ScoobySnacks::WorkFormBehavior
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
included do
|
|
4
|
+
|
|
5
|
+
self.terms = []
|
|
6
|
+
ScoobySnacks::METADATA_SCHEMA.fields.keys.each do |field_name|
|
|
7
|
+
self.terms << field_name.to_sym
|
|
8
|
+
# delegate field_name.to_sym, to: :solr_document
|
|
9
|
+
delegate field_name.to_sym, to: :model
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
self.required_fields = ScoobySnacks::METADATA_SCHEMA.required_field_names.map{|name| name.to_sym}
|
|
13
|
+
|
|
14
|
+
def schema
|
|
15
|
+
ScoobySnacks::METADATA_SCHEMA
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def primary_terms
|
|
19
|
+
@primary_terms ||= (schema.primary_display_field_names + schema.editor_primary_display_field_names).uniq.map{|name| name.to_sym}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def secondary_terms
|
|
23
|
+
@secondary_terms ||= (schema.all_field_names - schema.primary_display_field_names - schema.editor_primary_display_field_names).map{|name| name.to_sym}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.build_permitted_params
|
|
27
|
+
permitted = super
|
|
28
|
+
ScoobySnacks::METADATA_SCHEMA.controlled_field_names.each do |field_name|
|
|
29
|
+
permitted << {"#{field_name}_attributes".to_sym => [:id, :_destroy]}
|
|
30
|
+
end
|
|
31
|
+
return params
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module ScoobySnacks::WorkModelBehavior
|
|
2
|
+
# A model mixin to define metadata
|
|
3
|
+
# properties and options based on
|
|
4
|
+
# the schema configuration files
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
|
|
7
|
+
included do
|
|
8
|
+
|
|
9
|
+
id_blank = proc { |attributes| attributes[:id].blank? }
|
|
10
|
+
schema = ScoobySnacks::METADATA_SCHEMA
|
|
11
|
+
schema.fields.values.each do |field|
|
|
12
|
+
# Define the property and its indexing
|
|
13
|
+
# unless it is already defined (e.g. in hyrax core)
|
|
14
|
+
unless respond_to? field.name.to_sym
|
|
15
|
+
property field.name.to_sym, {predicate: field.predicate, multiple: field.multiple?} do |index|
|
|
16
|
+
index.as :stored_searchable
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end #end fields loop
|
|
20
|
+
|
|
21
|
+
schema.controlled_field_names.each do |field_name|
|
|
22
|
+
accepts_nested_attributes_for field_name.to_sym, reject_if: id_blank, allow_destroy: true
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# used by Hyrax, I think
|
|
26
|
+
# (taken from Hyrax::BasicMetadata)
|
|
27
|
+
# I'm not sure whether/how the scholarsphere stuff is used
|
|
28
|
+
property :label, predicate: ActiveFedora::RDF::Fcrepo::Model.downloadFilename, multiple: false
|
|
29
|
+
property :relative_path, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#relativePath'), multiple: false
|
|
30
|
+
property :import_url, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#importUrl'), multiple: false
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "scooby_snacks/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "scooby_snacks"
|
|
8
|
+
spec.version = ScoobySnacks::VERSION
|
|
9
|
+
spec.authors = ["UCSC Library Digital Initiatives Department, Ned Henry"]
|
|
10
|
+
spec.email = ["ethenry@ucsc.edu"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{A helper gem to define metadata schema in configuration files in Hyrax (Samvera) applications.}
|
|
13
|
+
spec.description = %q{A helper gem to define metadata schema in configuration files in Hyrax (Samvera) applications.}
|
|
14
|
+
spec.homepage = "http://UCSCLibrary.github.org"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
|
+
if spec.respond_to?(:metadata)
|
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
21
|
+
else
|
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
23
|
+
"public gem pushes."
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
|
28
|
+
end
|
|
29
|
+
spec.bindir = "exe"
|
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
31
|
+
spec.require_paths = ["lib"]
|
|
32
|
+
|
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
35
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: scooby_snacks
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: '0.3'
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- UCSC Library Digital Initiatives Department, Ned Henry
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-04-22 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.15'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.15'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
description: A helper gem to define metadata schema in configuration files in Hyrax
|
|
42
|
+
(Samvera) applications.
|
|
43
|
+
email:
|
|
44
|
+
- ethenry@ucsc.edu
|
|
45
|
+
executables: []
|
|
46
|
+
extensions: []
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- ".gitignore"
|
|
50
|
+
- Gemfile
|
|
51
|
+
- LICENSE.txt
|
|
52
|
+
- README.md
|
|
53
|
+
- Rakefile
|
|
54
|
+
- bin/console
|
|
55
|
+
- bin/setup
|
|
56
|
+
- examples/config/metadata.yml
|
|
57
|
+
- examples/config/metadata/shared.yml
|
|
58
|
+
- examples/example_config_1/README.md
|
|
59
|
+
- examples/example_config_1/metadata.yml
|
|
60
|
+
- examples/example_config_1/shared_schema.yml
|
|
61
|
+
- examples/example_config_2/README.md
|
|
62
|
+
- examples/example_config_2/metadata.yml
|
|
63
|
+
- examples/example_config_2/metadata/local/classes.yml
|
|
64
|
+
- examples/example_config_2/metadata/local/namespaces.yml
|
|
65
|
+
- examples/example_config_2/metadata/local/properties.yml
|
|
66
|
+
- examples/example_config_2/metadata/local/work_types.yml
|
|
67
|
+
- examples/example_config_2/metadata/shared/geospatial_properties.yml
|
|
68
|
+
- examples/example_config_2/metadata/shared/uc/classes.yml
|
|
69
|
+
- examples/example_config_2/metadata/shared/uc/properties.yml
|
|
70
|
+
- lib/generators/scooby_snacks/install/templates/metadata.yml
|
|
71
|
+
- lib/scooby_snacks.rb
|
|
72
|
+
- lib/scooby_snacks/blacklight_configuration.rb
|
|
73
|
+
- lib/scooby_snacks/field.rb
|
|
74
|
+
- lib/scooby_snacks/initialize.rb
|
|
75
|
+
- lib/scooby_snacks/metadata_schema.rb
|
|
76
|
+
- lib/scooby_snacks/presenter_behavior.rb
|
|
77
|
+
- lib/scooby_snacks/solr_behavior.rb
|
|
78
|
+
- lib/scooby_snacks/version.rb
|
|
79
|
+
- lib/scooby_snacks/work_form_behavior.rb
|
|
80
|
+
- lib/scooby_snacks/work_model_behavior.rb
|
|
81
|
+
- scooby_snacks.gemspec
|
|
82
|
+
homepage: http://UCSCLibrary.github.org
|
|
83
|
+
licenses:
|
|
84
|
+
- MIT
|
|
85
|
+
metadata:
|
|
86
|
+
allowed_push_host: https://rubygems.org
|
|
87
|
+
post_install_message:
|
|
88
|
+
rdoc_options: []
|
|
89
|
+
require_paths:
|
|
90
|
+
- lib
|
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
|
+
requirements:
|
|
98
|
+
- - ">="
|
|
99
|
+
- !ruby/object:Gem::Version
|
|
100
|
+
version: '0'
|
|
101
|
+
requirements: []
|
|
102
|
+
rubyforge_project:
|
|
103
|
+
rubygems_version: 2.6.14
|
|
104
|
+
signing_key:
|
|
105
|
+
specification_version: 4
|
|
106
|
+
summary: A helper gem to define metadata schema in configuration files in Hyrax (Samvera)
|
|
107
|
+
applications.
|
|
108
|
+
test_files: []
|