merritt-manifest 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +198 -0
- data/.idea/emacs.xml +6 -0
- data/.idea/encodings.xml +6 -0
- data/.idea/inspectionProfiles/Project_Default.xml +13 -0
- data/.idea/misc.xml +6 -0
- data/.idea/modules.xml +8 -0
- data/.idea/sbt.xml +6 -0
- data/.rubocop.yml +35 -0
- data/.ruby-version +1 -0
- data/.travis.yml +2 -0
- data/.yardopts +1 -0
- data/Gemfile +3 -0
- data/LICENSE.md +22 -0
- data/README.md +110 -0
- data/Rakefile +38 -0
- data/lib/merritt/manifest/data_one.rb +48 -0
- data/lib/merritt/manifest/fields.rb +119 -0
- data/lib/merritt/manifest/file.rb +33 -0
- data/lib/merritt/manifest/module_info.rb +12 -0
- data/lib/merritt/manifest/object.rb +32 -0
- data/lib/merritt/manifest.rb +128 -0
- data/lib/merritt/util.rb +19 -0
- data/lib/merritt.rb +4 -0
- data/merritt-manifest.gemspec +37 -0
- data/merritt-manifest.iml +37 -0
- data/spec/.rubocop.yml +10 -0
- data/spec/data/4blocks.checkm +8 -0
- data/spec/data/mrt-dataone-manifest.txt +32 -0
- data/spec/data/sampleBatchOfContainers.checkm +9 -0
- data/spec/data/sampleBatchOfFiles.checkm +9 -0
- data/spec/data/sampleBatchOfManifests.checkm +9 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/unit/merritt/manifest/data_one_spec.rb +122 -0
- data/spec/unit/merritt/manifest/fields_spec.rb +55 -0
- data/spec/unit/merritt/manifest/object_spec.rb +69 -0
- data/spec/unit/merritt/manifest_spec.rb +134 -0
- metadata +203 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7adb8f2c7f2796960082706d5bad61ff5f31698e
|
4
|
+
data.tar.gz: e56637f452b35cd1556a0e67a2d1806293ef314d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6a414f7f46daf7849113ae9d460a57020c026194a170155f80d558fd5ffa61c6651d13322cf9ff90ba9ae0d6950570f7fcf28a179164f95267d56f7929e204ea
|
7
|
+
data.tar.gz: b92a32eb1bd631f8d19b2c8c0f45aaae7b526a55751e779cc91b0995f720e7417eebf3b48cd25df0e093457ddbb18c3b30d2bc01934d40f29fba68242d2a2619
|
data/.gitignore
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
#### Misc
|
2
|
+
|
3
|
+
Gemfile.lock
|
4
|
+
.rubocop_todo.yml
|
5
|
+
|
6
|
+
#### joe made this: http://goel.io/joe
|
7
|
+
|
8
|
+
#### ruby ####
|
9
|
+
*.gem
|
10
|
+
*.rbc
|
11
|
+
/.config
|
12
|
+
/coverage/
|
13
|
+
/InstalledFiles
|
14
|
+
/pkg/
|
15
|
+
/spec/reports/
|
16
|
+
/spec/examples.txt
|
17
|
+
/test/tmp/
|
18
|
+
/test/version_tmp/
|
19
|
+
/tmp/
|
20
|
+
|
21
|
+
# Used by dotenv library to load environment variables.
|
22
|
+
# .env
|
23
|
+
|
24
|
+
## Specific to RubyMotion:
|
25
|
+
.dat*
|
26
|
+
.repl_history
|
27
|
+
build/
|
28
|
+
*.bridgesupport
|
29
|
+
build-iPhoneOS/
|
30
|
+
build-iPhoneSimulator/
|
31
|
+
|
32
|
+
## Specific to RubyMotion (use of CocoaPods):
|
33
|
+
#
|
34
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
35
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
36
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
37
|
+
#
|
38
|
+
# vendor/Pods/
|
39
|
+
|
40
|
+
## Documentation cache and generated files:
|
41
|
+
/.yardoc/
|
42
|
+
/_yardoc/
|
43
|
+
/doc/
|
44
|
+
/rdoc/
|
45
|
+
|
46
|
+
## Environment normalization:
|
47
|
+
/.bundle/
|
48
|
+
/vendor/bundle
|
49
|
+
/lib/bundler/man/
|
50
|
+
|
51
|
+
# for a library or gem, you might want to ignore these files since the code is
|
52
|
+
# intended to run in multiple environments; otherwise, check them in:
|
53
|
+
# Gemfile.lock
|
54
|
+
# .ruby-version
|
55
|
+
# .ruby-gemset
|
56
|
+
|
57
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
58
|
+
.rvmrc
|
59
|
+
|
60
|
+
#### rails ####
|
61
|
+
*.rbc
|
62
|
+
capybara-*.html
|
63
|
+
.rspec
|
64
|
+
/log
|
65
|
+
/tmp
|
66
|
+
/db/*.sqlite3
|
67
|
+
/db/*.sqlite3-journal
|
68
|
+
/public/system
|
69
|
+
/coverage/
|
70
|
+
/spec/tmp
|
71
|
+
**.orig
|
72
|
+
rerun.txt
|
73
|
+
pickle-email-*.html
|
74
|
+
|
75
|
+
# TODO Comment out this rule if you are OK with secrets being uploaded to the repo
|
76
|
+
config/initializers/secret_token.rb
|
77
|
+
|
78
|
+
# Only include if you have production secrets in this file, which is no longer a Rails default
|
79
|
+
# config/secrets.yml
|
80
|
+
|
81
|
+
# dotenv
|
82
|
+
# TODO Comment out this rule if environment variables can be committed
|
83
|
+
.env
|
84
|
+
|
85
|
+
## Environment normalization:
|
86
|
+
/.bundle
|
87
|
+
/vendor/bundle
|
88
|
+
|
89
|
+
# these should all be checked in to normalize the environment:
|
90
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
91
|
+
|
92
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
93
|
+
.rvmrc
|
94
|
+
|
95
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
96
|
+
/vendor/assets/bower_components
|
97
|
+
*.bowerrc
|
98
|
+
bower.json
|
99
|
+
|
100
|
+
# Ignore pow environment settings
|
101
|
+
.powenv
|
102
|
+
|
103
|
+
# Ignore Byebug command history file.
|
104
|
+
.byebug_history
|
105
|
+
|
106
|
+
#### emacs ####
|
107
|
+
# -*- mode: gitignore; -*-
|
108
|
+
*~
|
109
|
+
\#*\#
|
110
|
+
/.emacs.desktop
|
111
|
+
/.emacs.desktop.lock
|
112
|
+
*.elc
|
113
|
+
auto-save-list
|
114
|
+
tramp
|
115
|
+
.\#*
|
116
|
+
|
117
|
+
# Org-mode
|
118
|
+
.org-id-locations
|
119
|
+
*_archive
|
120
|
+
|
121
|
+
# flymake-mode
|
122
|
+
*_flymake.*
|
123
|
+
|
124
|
+
# eshell files
|
125
|
+
/eshell/history
|
126
|
+
/eshell/lastdir
|
127
|
+
|
128
|
+
# elpa packages
|
129
|
+
/elpa/
|
130
|
+
|
131
|
+
# reftex files
|
132
|
+
*.rel
|
133
|
+
|
134
|
+
# AUCTeX auto folder
|
135
|
+
/auto/
|
136
|
+
|
137
|
+
# cask packages
|
138
|
+
.cask/
|
139
|
+
dist/
|
140
|
+
|
141
|
+
# Flycheck
|
142
|
+
flycheck_*.el
|
143
|
+
|
144
|
+
# server auth directory
|
145
|
+
/server/
|
146
|
+
|
147
|
+
# projectiles files
|
148
|
+
.projectile
|
149
|
+
|
150
|
+
#### jetbrains ####
|
151
|
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
152
|
+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
153
|
+
|
154
|
+
# User-specific stuff:
|
155
|
+
.idea/workspace.xml
|
156
|
+
.idea/tasks.xml
|
157
|
+
.idea/dictionaries
|
158
|
+
.idea/vcs.xml
|
159
|
+
.idea/jsLibraryMappings.xml
|
160
|
+
|
161
|
+
# Sensitive or high-churn files:
|
162
|
+
.idea/dataSources.ids
|
163
|
+
.idea/dataSources.xml
|
164
|
+
.idea/dataSources.local.xml
|
165
|
+
.idea/sqlDataSources.xml
|
166
|
+
.idea/dynamic.xml
|
167
|
+
.idea/uiDesigner.xml
|
168
|
+
|
169
|
+
# Gradle:
|
170
|
+
.idea/gradle.xml
|
171
|
+
.idea/libraries
|
172
|
+
|
173
|
+
# Mongo Explorer plugin:
|
174
|
+
.idea/mongoSettings.xml
|
175
|
+
|
176
|
+
## File-based project format:
|
177
|
+
*.iws
|
178
|
+
|
179
|
+
## Plugin-specific files:
|
180
|
+
|
181
|
+
# IntelliJ
|
182
|
+
/out/
|
183
|
+
|
184
|
+
# mpeltonen/sbt-idea plugin
|
185
|
+
.idea_modules/
|
186
|
+
|
187
|
+
# JIRA plugin
|
188
|
+
atlassian-ide-plugin.xml
|
189
|
+
|
190
|
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
191
|
+
com_crashlytics_export_strings.xml
|
192
|
+
crashlytics.properties
|
193
|
+
crashlytics-build.properties
|
194
|
+
fabric.properties
|
195
|
+
|
196
|
+
# Raketasks
|
197
|
+
.rakeTasks
|
198
|
+
|
data/.idea/emacs.xml
ADDED
data/.idea/encodings.xml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
<component name="InspectionProjectProfileManager">
|
2
|
+
<profile version="1.0">
|
3
|
+
<option name="myName" value="Project Default" />
|
4
|
+
<inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
|
5
|
+
<inspection_tool class="RubyArgCount" enabled="false" level="ERROR" enabled_by_default="false" />
|
6
|
+
<inspection_tool class="RubyStringKeysInHashInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
7
|
+
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
8
|
+
<option name="processCode" value="true" />
|
9
|
+
<option name="processLiterals" value="true" />
|
10
|
+
<option name="processComments" value="true" />
|
11
|
+
</inspection_tool>
|
12
|
+
</profile>
|
13
|
+
</component>
|
data/.idea/misc.xml
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" default="false" project-jdk-name="ruby-2.2.5-p319" project-jdk-type="RUBY_SDK">
|
4
|
+
<output url="file://$PROJECT_DIR$/out" />
|
5
|
+
</component>
|
6
|
+
</project>
|
data/.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/merritt-manifest.iml" filepath="$PROJECT_DIR$/merritt-manifest.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
data/.idea/sbt.xml
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
AllCops:
|
2
|
+
# Suppress complaints about post-2.0 syntax
|
3
|
+
TargetRubyVersion: 2.2
|
4
|
+
|
5
|
+
# Disable line-length check; it's too easy for the cure to be worse than the disease
|
6
|
+
Metrics/LineLength:
|
7
|
+
Enabled: False
|
8
|
+
|
9
|
+
# Disable problematic module documentation check (see https://github.com/bbatsov/rubocop/issues/947)
|
10
|
+
Style/Documentation:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
# Allow one line around class body (Style/EmptyLines will still disallow two or more)
|
14
|
+
Style/EmptyLinesAroundClassBody:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
# Allow one line around module body (Style/EmptyLines will still disallow two or more)
|
18
|
+
Style/EmptyLinesAroundModuleBody:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
# Allow one line around block body (Style/EmptyLines will still disallow two or more)
|
22
|
+
Style/EmptyLinesAroundBlockBody:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
# Unclear why it's a good idea to give parameters semantically meaningless names
|
26
|
+
Style/SingleLineBlockParams:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
# Produces monsters
|
30
|
+
Style/MultilineOperationIndentation:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
# 👎 to cultural imperialism
|
34
|
+
Style/AsciiComments:
|
35
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.5
|
data/.travis.yml
ADDED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--markup markdown
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 The Regents of the University of California
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# Merritt::Manifest
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/dmolesUC3/merritt-manifest.svg)](https://travis-ci.org/dmolesUC3/merritt-manifest)
|
4
|
+
[![Inline docs](http://inch-ci.org/github/dmolesUC3/merritt-manifest.svg)](http://inch-ci.org/github/dmolesUC3/merritt-manifest)
|
5
|
+
|
6
|
+
A library for creating [Merritt](https://merritt.cdlib.org/) [text-based manifests](https://merritt.cdlib.org/help/manifest_guide#text_tips) (a specialization of the [Checkm](https://wiki.ucop.edu/display/Curation/Checkm) text-based manifest format).
|
7
|
+
|
8
|
+
See the [Merritt ingest service docs](https://confluence.ucop.edu/download/attachments/16744573/Merritt-ingest-service-latest.pdf)
|
9
|
+
for more information.
|
10
|
+
|
11
|
+
## Object support
|
12
|
+
|
13
|
+
Single-object manifests are supported via the `Merritt::Manifest::Object` class:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
obj_manifest = Merritt::Manifest::Object.new(
|
17
|
+
files: [
|
18
|
+
{
|
19
|
+
file_url: 'http://merritt.cdlib.org/samples/4blocks.jpg',
|
20
|
+
hash_algorithm: 'md5',
|
21
|
+
hash_value: '0b21c6d48e815dd537d42dc1cfac0111',
|
22
|
+
file_name: '4blocks.jpg'
|
23
|
+
},
|
24
|
+
{
|
25
|
+
file_url: 'http://merritt.cdlib.org/samples/4blocks.txt',
|
26
|
+
hash_algorithm: 'md5',
|
27
|
+
hash_value: 'ed04a855f89f31f8dc8e9bb946f5f159',
|
28
|
+
file_name: '4blocks.txt'
|
29
|
+
}
|
30
|
+
].map { |h| OpenStruct.new(h) }
|
31
|
+
)
|
32
|
+
|
33
|
+
puts obj_manifest.write_to_string
|
34
|
+
```
|
35
|
+
|
36
|
+
```text
|
37
|
+
#%checkm_0.7
|
38
|
+
#%profile | http://uc3.cdlib.org/registry/ingest/manifest/mrt-ingest-manifest
|
39
|
+
#%prefix | mrt: | http://merritt.cdlib.org/terms#
|
40
|
+
#%prefix | nfo: | http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#
|
41
|
+
#%fields | nfo:fileUrl | nfo:hashAlgorithm | nfo:hashValue | nfo:fileSize | nfo:fileLastModified | nfo:fileName | mrt:mimeType
|
42
|
+
http://merritt.cdlib.org/samples/4blocks.jpg | md5 | 0b21c6d48e815dd537d42dc1cfac0111 | | | 4blocks.jpg
|
43
|
+
http://merritt.cdlib.org/samples/4blocks.txt | md5 | ed04a855f89f31f8dc8e9bb946f5f159 | | | 4blocks.txt
|
44
|
+
#%eof
|
45
|
+
```
|
46
|
+
|
47
|
+
## Batch support
|
48
|
+
|
49
|
+
Batch manifests are not yet supported.
|
50
|
+
|
51
|
+
## DataONE Manifest support
|
52
|
+
|
53
|
+
DataONE manifests are supported via the `Merritt::Manifest::DataONE` class:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
dataone_manifest = Merritt::Manifest::DataONE.new(
|
57
|
+
files: {
|
58
|
+
'Laney_300394_Exempt_Determination_Letter.pdf' => 'application/pdf',
|
59
|
+
'Laney_IRBProposal.docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
60
|
+
'SensorSurvey_Printout.pdf' => 'application/pdf',
|
61
|
+
'clean_survey_data_no_ids.csv' => 'text/csv',
|
62
|
+
'research_coords.csv' => 'text/csv',
|
63
|
+
'survey/Q10/research_sites.R' => 'text/plain',
|
64
|
+
'survey/Q11-23/sensors_platforms.R' => 'text/plain',
|
65
|
+
'survey/Q24/limitsToExpansion.R' => 'text/plain',
|
66
|
+
'survey/Q25-32/data_metadata_management.R' => 'text/plain',
|
67
|
+
'survey/Q3-9/respondent_info.R' => 'text/plain',
|
68
|
+
'survey/Q33-37/networking.R' => 'text/plain',
|
69
|
+
'survey/Q38-42/publications.R' => 'text/plain',
|
70
|
+
'survey_data_prep.R' => 'text/plain'
|
71
|
+
}.map { |name, type| OpenStruct.new(name: name, type: type) }
|
72
|
+
)
|
73
|
+
|
74
|
+
puts dataone_manifest.write_to_string
|
75
|
+
```
|
76
|
+
|
77
|
+
```text
|
78
|
+
#%dataonem_0.1
|
79
|
+
#%profile | http://uc3.cdlib.org/registry/ingest/manifest/mrt-dataone-manifest
|
80
|
+
#%prefix | dom: | http://uc3.cdlib.org/ontology/dataonem
|
81
|
+
#%prefix | mrt: | http://uc3.cdlib.org/ontology/mom
|
82
|
+
#%fields | dom:scienceMetadataFile | dom:scienceMetadataFormat | dom:scienceDataFile | mrt:mimeType
|
83
|
+
mrt-datacite.xml | http://datacite.org/schema/kernel-3.1 | Laney_300394_Exempt_Determination_Letter.pdf | application/pdf
|
84
|
+
mrt-oaidc.xml | http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd | Laney_300394_Exempt_Determination_Letter.pdf | application/pdf
|
85
|
+
mrt-datacite.xml | http://datacite.org/schema/kernel-3.1 | Laney_IRBProposal.docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
86
|
+
mrt-oaidc.xml | http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd | Laney_IRBProposal.docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
87
|
+
mrt-datacite.xml | http://datacite.org/schema/kernel-3.1 | SensorSurvey_Printout.pdf | application/pdf
|
88
|
+
mrt-oaidc.xml | http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd | SensorSurvey_Printout.pdf | application/pdf
|
89
|
+
mrt-datacite.xml | http://datacite.org/schema/kernel-3.1 | clean_survey_data_no_ids.csv | text/csv
|
90
|
+
mrt-oaidc.xml | http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd | clean_survey_data_no_ids.csv | text/csv
|
91
|
+
mrt-datacite.xml | http://datacite.org/schema/kernel-3.1 | research_coords.csv | text/csv
|
92
|
+
mrt-oaidc.xml | http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd | research_coords.csv | text/csv
|
93
|
+
mrt-datacite.xml | http://datacite.org/schema/kernel-3.1 | survey/Q10/research_sites.R | text/plain
|
94
|
+
mrt-oaidc.xml | http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd | survey/Q10/research_sites.R | text/plain
|
95
|
+
mrt-datacite.xml | http://datacite.org/schema/kernel-3.1 | survey/Q11-23/sensors_platforms.R | text/plain
|
96
|
+
mrt-oaidc.xml | http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd | survey/Q11-23/sensors_platforms.R | text/plain
|
97
|
+
mrt-datacite.xml | http://datacite.org/schema/kernel-3.1 | survey/Q24/limitsToExpansion.R | text/plain
|
98
|
+
mrt-oaidc.xml | http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd | survey/Q24/limitsToExpansion.R | text/plain
|
99
|
+
mrt-datacite.xml | http://datacite.org/schema/kernel-3.1 | survey/Q25-32/data_metadata_management.R | text/plain
|
100
|
+
mrt-oaidc.xml | http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd | survey/Q25-32/data_metadata_management.R | text/plain
|
101
|
+
mrt-datacite.xml | http://datacite.org/schema/kernel-3.1 | survey/Q3-9/respondent_info.R | text/plain
|
102
|
+
mrt-oaidc.xml | http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd | survey/Q3-9/respondent_info.R | text/plain
|
103
|
+
mrt-datacite.xml | http://datacite.org/schema/kernel-3.1 | survey/Q33-37/networking.R | text/plain
|
104
|
+
mrt-oaidc.xml | http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd | survey/Q33-37/networking.R | text/plain
|
105
|
+
mrt-datacite.xml | http://datacite.org/schema/kernel-3.1 | survey/Q38-42/publications.R | text/plain
|
106
|
+
mrt-oaidc.xml | http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd | survey/Q38-42/publications.R | text/plain
|
107
|
+
mrt-datacite.xml | http://datacite.org/schema/kernel-3.1 | survey_data_prep.R | text/plain
|
108
|
+
mrt-oaidc.xml | http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd | survey_data_prep.R | text/plain
|
109
|
+
#%eof
|
110
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# ------------------------------------------------------------
|
2
|
+
# RSpec
|
3
|
+
|
4
|
+
require 'rspec/core'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
|
7
|
+
namespace :spec do
|
8
|
+
desc 'Run all unit tests'
|
9
|
+
RSpec::Core::RakeTask.new(:unit) do |task|
|
10
|
+
task.rspec_opts = %w[--color --format documentation --order default]
|
11
|
+
task.pattern = 'unit/**/*_spec.rb'
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Run all tests'
|
17
|
+
task spec: %w[spec:unit]
|
18
|
+
|
19
|
+
# ------------------------------------------------------------
|
20
|
+
# Coverage
|
21
|
+
|
22
|
+
desc 'Run all unit tests with coverage'
|
23
|
+
task :coverage do
|
24
|
+
ENV['COVERAGE'] = 'true'
|
25
|
+
Rake::Task['spec:unit'].execute
|
26
|
+
end
|
27
|
+
|
28
|
+
# ------------------------------------------------------------
|
29
|
+
# RuboCop
|
30
|
+
|
31
|
+
require 'rubocop/rake_task'
|
32
|
+
RuboCop::RakeTask.new
|
33
|
+
|
34
|
+
# ------------------------------------------------------------
|
35
|
+
# Defaults
|
36
|
+
|
37
|
+
desc 'Run unit tests, check test coverage, run acceptance tests, check code style'
|
38
|
+
task default: %i[coverage rubocop]
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Merritt
|
2
|
+
class Manifest
|
3
|
+
# A specialization of {Manifest} for DataONE.
|
4
|
+
class DataONE < Manifest
|
5
|
+
|
6
|
+
# Creates a new {Manifest::DataONE}
|
7
|
+
# @param files [Array<Manifest::File>] an array of data files to be converted to entries.
|
8
|
+
# (Note that these not be actual {Manifest::File} objects so long as they respond to
|
9
|
+
# `#name` and `#type`)
|
10
|
+
def initialize(files:)
|
11
|
+
super(
|
12
|
+
conformance: 'dataonem_0.1',
|
13
|
+
profile: 'http://uc3.cdlib.org/registry/ingest/manifest/mrt-dataone-manifest',
|
14
|
+
prefixes: {
|
15
|
+
dom: 'http://uc3.cdlib.org/ontology/dataonem',
|
16
|
+
mrt: 'http://uc3.cdlib.org/ontology/mom'
|
17
|
+
},
|
18
|
+
fields: [METADATA_FILE, METADATA_FORMAT, DATA_FILE, MIME_TYPE],
|
19
|
+
entries: to_entries(files)
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
METADATA_FILE = 'dom:scienceMetadataFile'.freeze
|
26
|
+
METADATA_FORMAT = 'dom:scienceMetadataFormat'.freeze
|
27
|
+
DATA_FILE = 'dom:scienceDataFile'.freeze
|
28
|
+
MIME_TYPE = 'mrt:mimeType'.freeze
|
29
|
+
|
30
|
+
METADATA_FILES = {
|
31
|
+
'mrt-datacite.xml' => 'http://datacite.org/schema/kernel-3.1',
|
32
|
+
'mrt-oaidc.xml' => 'http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd'
|
33
|
+
}.freeze
|
34
|
+
|
35
|
+
def to_entries(files)
|
36
|
+
rows = files.product(METADATA_FILES.to_a).map(&:flatten)
|
37
|
+
rows.map do |file, md_name, md_url|
|
38
|
+
{
|
39
|
+
METADATA_FILE => md_name,
|
40
|
+
METADATA_FORMAT => md_url,
|
41
|
+
DATA_FILE => file.name,
|
42
|
+
MIME_TYPE => file.type
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'typesafe_enum'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module Merritt
|
5
|
+
class Manifest
|
6
|
+
|
7
|
+
# Mixin for field enumerations
|
8
|
+
module Field
|
9
|
+
# Gets the reader method for this field
|
10
|
+
def reader
|
11
|
+
@reader ||= key.downcase
|
12
|
+
end
|
13
|
+
|
14
|
+
# Reads the value of this field from the specified object, if available
|
15
|
+
def value_from(obj)
|
16
|
+
return unless obj.respond_to?(reader)
|
17
|
+
obj.send(reader)
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String] the fieldname
|
21
|
+
def field_name
|
22
|
+
value
|
23
|
+
end
|
24
|
+
|
25
|
+
# The prefix for this field
|
26
|
+
def prefix
|
27
|
+
@prefix ||= begin
|
28
|
+
prefix, name = value.split(':')
|
29
|
+
prefix if name # if we didn't find a name, then there's no ':' and hence no prefix
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Implemented to inject {ClassMethods} into field enumerations that include this module
|
34
|
+
def self.included(base)
|
35
|
+
base.extend(ClassMethods)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Class methods for field enumerations
|
39
|
+
module ClassMethods
|
40
|
+
# Gets all prefixes in these fields, and their URLs
|
41
|
+
# @return [Hash<Symbol, String>] all prefixes used by these fields, as a map from symbol to URL string
|
42
|
+
def prefixes
|
43
|
+
@prefixes ||= begin
|
44
|
+
all_prefixes = to_a.map(&:prefix).uniq.sort.freeze
|
45
|
+
all_prefixes.map { |p| [p, url_for(p)] }.to_h.freeze
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# A list of all fields
|
50
|
+
# @return [String] a list of all fields, as (prefix-qualified) names
|
51
|
+
def fields
|
52
|
+
@fields ||= to_a.map(&:value).freeze
|
53
|
+
end
|
54
|
+
|
55
|
+
# Gets the string for the specified prefix
|
56
|
+
# @param prefix [String, Symbol] the prefix
|
57
|
+
# @return [String] the URL string for the prefix
|
58
|
+
def url_for(prefix)
|
59
|
+
# noinspection RubyCaseWithoutElseBlockInspection
|
60
|
+
case prefix.to_sym
|
61
|
+
when :mrt
|
62
|
+
'http://merritt.cdlib.org/terms#'
|
63
|
+
when :nfo
|
64
|
+
'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Holder module for field enumerations
|
71
|
+
module Fields
|
72
|
+
# Enumeration of fields for object manifests
|
73
|
+
class Object < TypesafeEnum::Base
|
74
|
+
include Field
|
75
|
+
# @!parse extend Merritt::Manifest::Field::ClassMethods
|
76
|
+
|
77
|
+
# Field for `nfo:fileUrl`. Parses string URLs as URI objects.
|
78
|
+
new(:FILE_URL, 'nfo:fileUrl') do
|
79
|
+
def value_from(obj)
|
80
|
+
value = super(obj)
|
81
|
+
raise ArgumentError, "No :#{reader} method provided for #{obj}" unless value
|
82
|
+
Merritt::Util.to_uri(value)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# field for `nfo:hashAlgorithm`
|
87
|
+
new :HASH_ALGORITHM, 'nfo:hashAlgorithm'
|
88
|
+
|
89
|
+
# field for `nfo:hashValue`
|
90
|
+
new :HASH_VALUE, 'nfo:hashValue'
|
91
|
+
|
92
|
+
# field for `nfo:fileSize`. Parses string values as integers.
|
93
|
+
new :FILE_SIZE, 'nfo:fileSize' do
|
94
|
+
def value_from(obj)
|
95
|
+
value = super(obj)
|
96
|
+
return unless value
|
97
|
+
value.to_i
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# field for `nfo:fileLastModified`
|
102
|
+
new :FILE_LAST_MODIFIED, 'nfo:fileLastModified'
|
103
|
+
|
104
|
+
# field for `nfo:fileName`. If no file name is provided, parses it from {FILE_URL}.
|
105
|
+
new :FILE_NAME, 'nfo:fileName' do
|
106
|
+
def value_from(obj)
|
107
|
+
value = super(obj)
|
108
|
+
return value if value
|
109
|
+
file_url = FILE_URL.value_from(obj)
|
110
|
+
URI(file_url).path.split('/').last
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# field for `mrt:mimeType`
|
115
|
+
new :MIME_TYPE, 'mrt:mimeType'
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|