stash-wrapper 0.1.11.1 → 0.1.12
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 +5 -5
- data/.gitignore +89 -10
- data/.rakeTasks +7 -0
- data/.rubocop.yml +6 -20
- data/.ruby-version +1 -1
- data/CHANGES.md +8 -0
- data/LICENSE.md +1 -1
- data/README.md +2 -2
- data/Rakefile +2 -2
- data/example.rb +2 -1
- data/lib/stash/wrapper.rb +2 -2
- data/lib/stash/wrapper/descriptive_node.rb +2 -2
- data/lib/stash/wrapper/embargo.rb +23 -13
- data/lib/stash/wrapper/embargo_type.rb +1 -1
- data/lib/stash/wrapper/identifier.rb +6 -2
- data/lib/stash/wrapper/identifier_type.rb +5 -0
- data/lib/stash/wrapper/inventory.rb +2 -2
- data/lib/stash/wrapper/license.rb +2 -2
- data/lib/stash/wrapper/module_info.rb +4 -4
- data/lib/stash/wrapper/size.rb +8 -2
- data/lib/stash/wrapper/stash_administrative.rb +30 -10
- data/lib/stash/wrapper/stash_wrapper.rb +8 -4
- data/lib/stash/wrapper/version.rb +15 -4
- data/spec/.rubocop.yml +1 -4
- data/spec/data/wrapper/mrtoai-wrapper-old-schema-location.xml +73 -0
- data/spec/data/wrapper/mrtoai-wrapper.xml +33 -33
- data/spec/data/wrapper/stash_wrapper.xsd +2 -2
- data/spec/data/wrapper/wrapper-1.xml +4 -7
- data/spec/data/wrapper/wrapper-2.xml +2 -2
- data/spec/rspec_custom_matchers.rb +61 -38
- data/spec/unit/stash/wrapper/identifier_spec.rb +22 -0
- data/spec/unit/stash/wrapper/inventory_spec.rb +1 -1
- data/spec/unit/stash/wrapper/stash_administrative_spec.rb +68 -26
- data/spec/unit/stash/wrapper/stash_wrapper_spec.rb +57 -37
- data/spec/unit/stash/wrapper/version_spec.rb +9 -0
- data/stash-wrapper.gemspec +35 -29
- metadata +76 -27
- data/data/kernel3_to_oaidc.xsl +0 -220
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 8c2df6f3332aaa9d993dfda573f17d9127ac1e902c1f8705ea65a8ba72864208
|
|
4
|
+
data.tar.gz: 6cf310390b1a80e396e51a12de63107142881c6059731f812030919399eca940
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 915f637e7a4940cd413f852b951c83ef9a3628fec9f39c9a0eaf1f6254ca481bde66bb53c1cdc3282d5885744b4400f1568886748f4191fdf80ca1483aeff25b
|
|
7
|
+
data.tar.gz: 8f37b259d343d835cfd684852430160b029911a8a8ba8565d316575cdfe1345625cc709377b5e25fce21a21e659896b5de0eb13dc2a73aae23ae840032024e15
|
data/.gitignore
CHANGED
|
@@ -27,20 +27,99 @@ db/*.sqlite3
|
|
|
27
27
|
|
|
28
28
|
/log/
|
|
29
29
|
|
|
30
|
-
#
|
|
30
|
+
# Mac OS
|
|
31
|
+
|
|
32
|
+
.DS_Store
|
|
33
|
+
#### joe made this: http://goel.io/joe
|
|
34
|
+
|
|
35
|
+
#####=== JetBrains ===#####
|
|
36
|
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
|
37
|
+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
|
38
|
+
|
|
39
|
+
# User-specific stuff:
|
|
40
|
+
.idea/workspace.xml
|
|
41
|
+
.idea/tasks.xml
|
|
42
|
+
|
|
43
|
+
# Sensitive or high-churn files:
|
|
44
|
+
.idea/dataSources/
|
|
45
|
+
.idea/dataSources.ids
|
|
46
|
+
.idea/dataSources.xml
|
|
47
|
+
.idea/dataSources.local.xml
|
|
48
|
+
.idea/sqlDataSources.xml
|
|
49
|
+
.idea/dynamic.xml
|
|
50
|
+
.idea/uiDesigner.xml
|
|
31
51
|
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
# Gradle:
|
|
53
|
+
.idea/gradle.xml
|
|
54
|
+
.idea/libraries
|
|
55
|
+
|
|
56
|
+
# Mongo Explorer plugin:
|
|
57
|
+
.idea/mongoSettings.xml
|
|
58
|
+
|
|
59
|
+
## File-based project format:
|
|
34
60
|
*.iws
|
|
35
|
-
*.ids
|
|
36
|
-
.rakeTasks
|
|
37
61
|
|
|
38
|
-
|
|
62
|
+
## Plugin-specific files:
|
|
63
|
+
|
|
64
|
+
# IntelliJ
|
|
65
|
+
/out/
|
|
66
|
+
|
|
67
|
+
# mpeltonen/sbt-idea plugin
|
|
68
|
+
.idea_modules/
|
|
69
|
+
|
|
70
|
+
# JIRA plugin
|
|
71
|
+
atlassian-ide-plugin.xml
|
|
39
72
|
|
|
73
|
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
|
74
|
+
com_crashlytics_export_strings.xml
|
|
75
|
+
crashlytics.properties
|
|
76
|
+
crashlytics-build.properties
|
|
77
|
+
fabric.properties
|
|
78
|
+
|
|
79
|
+
#####=== Emacs ===#####
|
|
80
|
+
# -*- mode: gitignore; -*-
|
|
40
81
|
*~
|
|
41
|
-
|
|
42
|
-
|
|
82
|
+
\#*\#
|
|
83
|
+
/.emacs.desktop
|
|
84
|
+
/.emacs.desktop.lock
|
|
85
|
+
*.elc
|
|
86
|
+
auto-save-list
|
|
87
|
+
tramp
|
|
88
|
+
.\#*
|
|
43
89
|
|
|
44
|
-
#
|
|
90
|
+
# Org-mode
|
|
91
|
+
.org-id-locations
|
|
92
|
+
*_archive
|
|
93
|
+
|
|
94
|
+
# flymake-mode
|
|
95
|
+
*_flymake.*
|
|
96
|
+
|
|
97
|
+
# eshell files
|
|
98
|
+
/eshell/history
|
|
99
|
+
/eshell/lastdir
|
|
100
|
+
|
|
101
|
+
# elpa packages
|
|
102
|
+
/elpa/
|
|
103
|
+
|
|
104
|
+
# reftex files
|
|
105
|
+
*.rel
|
|
106
|
+
|
|
107
|
+
# AUCTeX auto folder
|
|
108
|
+
/auto/
|
|
109
|
+
|
|
110
|
+
# cask packages
|
|
111
|
+
.cask/
|
|
112
|
+
dist/
|
|
113
|
+
|
|
114
|
+
# Flycheck
|
|
115
|
+
flycheck_*.el
|
|
116
|
+
|
|
117
|
+
# server auth directory
|
|
118
|
+
/server/
|
|
119
|
+
|
|
120
|
+
# projectiles files
|
|
121
|
+
.projectile
|
|
122
|
+
|
|
123
|
+
# directory configuration
|
|
124
|
+
.dir-locals.el
|
|
45
125
|
|
|
46
|
-
.DS_Store
|
data/.rakeTasks
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
|
3
|
+
You are allowed to:
|
|
4
|
+
1. Remove rake task
|
|
5
|
+
2. Add existing rake tasks
|
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Run all unit tests with coverage" fullCmd="coverage" taksId="coverage" /><RakeTask description="Run unit tests, check test coverage, check code style" fullCmd="default" taksId="default" /><RakeTask description="Run RuboCop" fullCmd="rubocop" taksId="rubocop" /><RakeGroup description="" fullCmd="" taksId="rubocop"><RakeTask description="Auto-correct RuboCop offenses" fullCmd="rubocop:auto_correct" taksId="auto_correct" /></RakeGroup><RakeTask description="Run all tests" fullCmd="spec" taksId="spec" /><RakeGroup description="" fullCmd="" taksId="spec"><RakeTask description="Run all unit tests" fullCmd="spec:unit" taksId="unit" /><RakeTask description="" fullCmd="spec:all" taksId="all" /></RakeGroup><RakeTask description="" fullCmd="debug_load_path" taksId="debug_load_path" /></RakeGroup></Settings>
|
data/.rubocop.yml
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
inherit_from: ../.rubocop.yml
|
|
2
|
+
|
|
3
|
+
# Disable various checks for sample code
|
|
2
4
|
Style/ClassAndModuleChildren:
|
|
3
5
|
Exclude:
|
|
4
6
|
- 'example.rb'
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# Disable problematic module documentation check (see https://github.com/bbatsov/rubocop/issues/947)
|
|
11
|
-
Style/Documentation:
|
|
12
|
-
Enabled: false
|
|
13
|
-
|
|
14
|
-
# Allow one line around class body (Style/EmptyLines will still disallow two or more)
|
|
15
|
-
Style/EmptyLinesAroundClassBody:
|
|
16
|
-
Enabled: false
|
|
17
|
-
|
|
18
|
-
# Allow one line around module body (Style/EmptyLines will still disallow two or more)
|
|
19
|
-
Style/EmptyLinesAroundModuleBody:
|
|
20
|
-
Enabled: false
|
|
21
|
-
|
|
22
|
-
# Allow one line around block body (Style/EmptyLines will still disallow two or more)
|
|
23
|
-
Style/EmptyLinesAroundBlockBody:
|
|
24
|
-
Enabled: false
|
|
8
|
+
Style/MixinUsage:
|
|
9
|
+
Exclude:
|
|
10
|
+
- 'example.rb'
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.4.1
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# 0.1.12 (14 November 2018)
|
|
2
|
+
|
|
3
|
+
- Change stash-wrapper namespace URI to https://dash.ucop.edu/stash_wrapper/ and schema location to
|
|
4
|
+
https://dash.ucop.edu/stash_wrapper/stash_wrapper.xsd (formerly both URLs were http://dash.cdlib.org/)
|
|
5
|
+
- Update to Ruby 2.4.1
|
|
6
|
+
- Update to Rubocop 0.57.2
|
|
7
|
+
- Update dependencies
|
|
8
|
+
|
|
1
9
|
# 0.1.11.1 (5 August 2016)
|
|
2
10
|
|
|
3
11
|
- In `License::CC_BY`, use "Creative Commons Attribution 4.0 International (CC BY 4.0)"
|
data/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2018 The Regents of the University of California
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://github.com/CDLUC3/stash-wrapper/releases)
|
|
7
7
|
|
|
8
8
|
Gem for working with the [Stash](https://github.com/CDLUC3/stash)
|
|
9
|
-
[XML wrapper format](https://dash.
|
|
9
|
+
[XML wrapper format](https://dash.ucop.edu/stash_wrapper/stash_wrapper.xsd).
|
|
10
10
|
|
|
11
11
|
The `StashWrapper` object graph mostly mirrors the `stash_wrapper` schema, though some
|
|
12
12
|
simpler elements have been collapsed into object attributes. Also, some classes and
|
|
@@ -126,7 +126,7 @@ to be nonsensical.
|
|
|
126
126
|
### Single file to standard output
|
|
127
127
|
```
|
|
128
128
|
% gen_stash_wrapper_sample
|
|
129
|
-
<st:stash_wrapper xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='
|
|
129
|
+
<st:stash_wrapper xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='https://dash.ucop.edu/stash_wrapper/ https://dash.ucop.edu/stash_wrapper/stash_wrapper.xsd' xmlns:st='https://dash.ucop.edu/stash_wrapper/'>
|
|
130
130
|
<st:identifier type='DOI'>10.21585/def1000001</st:identifier>
|
|
131
131
|
<st:stash_administrative>
|
|
132
132
|
<st:version>
|
data/Rakefile
CHANGED
|
@@ -8,7 +8,7 @@ namespace :spec do
|
|
|
8
8
|
|
|
9
9
|
desc 'Run all unit tests'
|
|
10
10
|
RSpec::Core::RakeTask.new(:unit) do |task|
|
|
11
|
-
task.rspec_opts = %w
|
|
11
|
+
task.rspec_opts = %w[--color --format documentation --order default]
|
|
12
12
|
task.pattern = 'unit/**/*_spec.rb'
|
|
13
13
|
end
|
|
14
14
|
|
|
@@ -44,4 +44,4 @@ end
|
|
|
44
44
|
# Defaults
|
|
45
45
|
|
|
46
46
|
desc 'Run unit tests, check test coverage, check code style'
|
|
47
|
-
task default: [
|
|
47
|
+
task default: %i[coverage rubocop]
|
data/example.rb
CHANGED
|
@@ -35,7 +35,8 @@ inventory = Inventory.new(
|
|
|
35
35
|
StashFile.new(
|
|
36
36
|
pathname: 'HSRC_MasterSampleII.sas7bdat', size_bytes: 123_456, mime_type: 'application/x-sas-data'
|
|
37
37
|
)
|
|
38
|
-
]
|
|
38
|
+
]
|
|
39
|
+
)
|
|
39
40
|
|
|
40
41
|
datacite_file = 'spec/data/wrapper/wrapper-2-payload.xml'
|
|
41
42
|
datacite_root = REXML::Document.new(File.read(datacite_file)).root
|
data/lib/stash/wrapper.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Stash
|
|
2
|
-
# Code relating to the {https://dash.
|
|
2
|
+
# Code relating to the {https://dash.ucop.edu/stash_wrapper/ Stash wrapper format}
|
|
3
3
|
module Wrapper
|
|
4
|
-
Dir.glob(File.expand_path('
|
|
4
|
+
Dir.glob(File.expand_path('wrapper/*.rb', __dir__), &method(:require))
|
|
5
5
|
end
|
|
6
6
|
end
|
|
@@ -8,9 +8,9 @@ module Stash
|
|
|
8
8
|
|
|
9
9
|
# See `XML::Mapping::SingleAttributeNode#initialize`
|
|
10
10
|
def initialize(*args)
|
|
11
|
-
path, *
|
|
11
|
+
path, *myargs = super(*args)
|
|
12
12
|
@path = ::XML::XXPath.new(path)
|
|
13
|
-
|
|
13
|
+
myargs # rubocop:disable Lint/Void
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
# Extracts the children of this element as an array.
|
|
@@ -18,14 +18,9 @@ module Stash
|
|
|
18
18
|
# @param period [String] The embargo period
|
|
19
19
|
# @param start_date [Date] The embargo start date
|
|
20
20
|
# @param end_date [Date] The embargo end date
|
|
21
|
-
def initialize(type:, period:, start_date:, end_date:)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
fail ArgumentError, "Specified start date does not appear to be a date: #{start_date || 'nil'}" unless start_date && start_date.respond_to?(:iso8601)
|
|
25
|
-
fail ArgumentError, "Specified end date does not appear to be a date: #{end_date || 'nil'}" unless end_date && end_date.respond_to?(:iso8601)
|
|
26
|
-
|
|
27
|
-
self.type = type
|
|
28
|
-
self.period = period.to_s
|
|
21
|
+
def initialize(type:, period:, start_date:, end_date:)
|
|
22
|
+
self.type = valid_type(type)
|
|
23
|
+
self.period = valid_period(period)
|
|
29
24
|
self.start_date, self.end_date = valid_range(start_date, end_date)
|
|
30
25
|
end
|
|
31
26
|
|
|
@@ -38,12 +33,27 @@ module Stash
|
|
|
38
33
|
|
|
39
34
|
private
|
|
40
35
|
|
|
36
|
+
def valid_type(type)
|
|
37
|
+
return type if type.is_a?(EmbargoType)
|
|
38
|
+
raise ArgumentError, "Specified type does not appear to be an EmbargoType: #{type || 'nil'}"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def valid_period(period)
|
|
42
|
+
period_str = period.to_s
|
|
43
|
+
return period_str unless period_str.strip.empty?
|
|
44
|
+
raise ArgumentError, "Specified embargo period does not appear to be a non-empty string: #{period.inspect}"
|
|
45
|
+
end
|
|
46
|
+
|
|
41
47
|
def valid_range(start_date, end_date)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
sd = valid_date(start_date)
|
|
49
|
+
ed = valid_date(end_date)
|
|
50
|
+
raise RangeError, "start_date #{sd} must be <= end_date #{ed}" if sd > ed
|
|
51
|
+
[sd.to_date, ed.to_date]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def valid_date(date)
|
|
55
|
+
return date if date && date.respond_to?(:iso8601)
|
|
56
|
+
raise ArgumentError, "Specified date does not appear to be a date: #{date || 'nil'}"
|
|
47
57
|
end
|
|
48
58
|
end
|
|
49
59
|
end
|
|
@@ -12,11 +12,15 @@ module Stash
|
|
|
12
12
|
|
|
13
13
|
# Creates a new {Identifier}
|
|
14
14
|
def initialize(type:, value:)
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
raise ArgumentError, "Identifier type does not appear to be an IdentifierType: #{type || 'nil'}" unless type.is_a?(IdentifierType)
|
|
16
|
+
raise ArgumentError, "Identifier value does not appear to be a non-empty string: #{value.inspect}" if value.to_s.strip.empty?
|
|
17
17
|
self.type = type
|
|
18
18
|
self.value = value
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
def formatted
|
|
22
|
+
type.format(value)
|
|
23
|
+
end
|
|
20
24
|
end
|
|
21
25
|
|
|
22
26
|
end
|
|
@@ -21,9 +21,9 @@ module Stash
|
|
|
21
21
|
private
|
|
22
22
|
|
|
23
23
|
def valid_file_array(files)
|
|
24
|
-
|
|
24
|
+
raise ArgumentError, "specified file list does not appear to be an array of StashFiles: #{files.inspect}" unless files.is_a?(Array)
|
|
25
25
|
files.each_with_index do |f, i|
|
|
26
|
-
|
|
26
|
+
raise ArgumentError, "files[#{i}] does not appear to be a StashFile: #{f.inspect}" unless f.is_a?(StashFile)
|
|
27
27
|
end
|
|
28
28
|
files
|
|
29
29
|
end
|
|
@@ -15,8 +15,8 @@ module Stash
|
|
|
15
15
|
# @param uri [URI, String] The license URI
|
|
16
16
|
# @raise [URI::InvalidURIError] if `uri` is a string that is not a valid URI
|
|
17
17
|
def initialize(name:, uri:)
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
raise ArgumentError, "License name does not appear to be a non-empty string: #{name.inspect}" if name.to_s.strip.empty?
|
|
19
|
+
raise ArgumentError, 'No uri provided' unless uri
|
|
20
20
|
self.name = name
|
|
21
21
|
self.uri = ::XML::MappingExtensions.to_uri(uri)
|
|
22
22
|
end
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
module Stash
|
|
2
|
-
# Code relating to the {https://dash.
|
|
2
|
+
# Code relating to the {https://dash.ucop.edu/stash_wrapper/ Stash wrapper format}
|
|
3
3
|
module Wrapper
|
|
4
4
|
# The name of this gem
|
|
5
|
-
NAME = 'stash-wrapper'
|
|
5
|
+
NAME = 'stash-wrapper'.freeze
|
|
6
6
|
|
|
7
7
|
# The version of this gem
|
|
8
|
-
VERSION = '0.1.
|
|
8
|
+
VERSION = '0.1.12'.freeze
|
|
9
9
|
|
|
10
10
|
# The copyright notice for this gem
|
|
11
|
-
COPYRIGHT = 'Copyright (c) 2016 The Regents of the University of California'
|
|
11
|
+
COPYRIGHT = 'Copyright (c) 2016 The Regents of the University of California'.freeze
|
|
12
12
|
end
|
|
13
13
|
end
|
data/lib/stash/wrapper/size.rb
CHANGED
|
@@ -14,10 +14,16 @@ module Stash
|
|
|
14
14
|
# Creates a new {Size}
|
|
15
15
|
# @param bytes [Integer] the size in bytes
|
|
16
16
|
def initialize(bytes:)
|
|
17
|
-
|
|
18
|
-
self.size = bytes
|
|
17
|
+
self.size = valid_size(bytes)
|
|
19
18
|
self.unit = SizeUnit::BYTE
|
|
20
19
|
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def valid_size(bytes)
|
|
24
|
+
return bytes if bytes && bytes.respond_to?(:to_i) && bytes == bytes.to_i
|
|
25
|
+
raise ArgumentError, "specified file size does not appear to be an integer byte count: #{bytes || 'nil'}"
|
|
26
|
+
end
|
|
21
27
|
end
|
|
22
28
|
|
|
23
29
|
end
|
|
@@ -22,17 +22,37 @@ module Stash
|
|
|
22
22
|
# is supplied, it will default to an embargo of type {EmbargoType::NONE}
|
|
23
23
|
# with the current date as start and end.
|
|
24
24
|
# @param inventory [Inventory, nil] the (optional) file inventory
|
|
25
|
-
def initialize(version:, license:, embargo: nil, inventory: nil)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
self.version = version
|
|
32
|
-
self.license = license
|
|
33
|
-
self.embargo = embargo || Embargo.none
|
|
34
|
-
self.inventory = inventory
|
|
25
|
+
def initialize(version:, license:, embargo: nil, inventory: nil)
|
|
26
|
+
self.version = valid_version(version)
|
|
27
|
+
self.license = valid_license(license)
|
|
28
|
+
self.embargo = valid_embargo(embargo)
|
|
29
|
+
self.inventory = valid_inventory_or_nil(inventory)
|
|
35
30
|
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def valid_version(version)
|
|
35
|
+
return version if version.is_a?(Version)
|
|
36
|
+
raise ArgumentError, "version does not appear to be a Version object: #{version || 'nil'}"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def valid_license(license)
|
|
40
|
+
return license if license.is_a?(License)
|
|
41
|
+
raise ArgumentError, "license does not appear to be a License object: #{license || 'nil'}"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def valid_embargo(embargo)
|
|
45
|
+
return Embargo.none unless embargo
|
|
46
|
+
return embargo if embargo.is_a?(Embargo)
|
|
47
|
+
raise ArgumentError, "embargo does not appear to be an Embargo object: #{embargo.inspect}"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def valid_inventory_or_nil(inventory)
|
|
51
|
+
return unless inventory
|
|
52
|
+
return inventory if inventory.is_a?(Inventory)
|
|
53
|
+
raise ArgumentError, "inventory does not appear to be an Inventory object: #{inventory || 'nil'}"
|
|
54
|
+
end
|
|
55
|
+
|
|
36
56
|
end
|
|
37
57
|
end
|
|
38
58
|
end
|