dina 0.5.2.0 → 0.5.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38d9beaf0e0b3193f1fb555df9915df0ec6de3dbeae45c066c536e0a2509ede5
4
- data.tar.gz: '0963571341f6fc59cef4c7b8403f271eac7cf275e123bee258fdefd4beb6051f'
3
+ metadata.gz: f73e6c200e682c91492c0f50854dc73a9fac3537a65eb12a5fe1d974b72adf09
4
+ data.tar.gz: 4fa9641b7ff96f95c88b30b1e6857aa9e02dc6ae8639efd84aa034a0908fa182
5
5
  SHA512:
6
- metadata.gz: da34d372945da32fb37edeb09b6fa796e1a48bc832d098973c2386a2dc8870d92c8663b6b21c580b6f94fa0b0b5ca30f1cfc30a5af8f36e26741ad65a2c82754
7
- data.tar.gz: b7aa54b8030c827919f270eed92f8dff3f2f23078d6c32d7dd180a22b37ff082da22ade4a850a2a5fb8a3afd87c6e6b5e96559b831fd91244591abad630aaab3
6
+ metadata.gz: 394bac789e4e01efe38447edb8042ae9f6dd3510b1a97aa06f6545f07a9133466a2afbcae3fc0e9d90fa053b8ba0f3c651b46dabb7f7dd702566870d9e5e1787
7
+ data.tar.gz: fc3d1f5e15028d8724ff1a37bc6816f28cbe639e79c67e9d75dd8d7dfa9e70f9d017c14cb31c79184f8f0a135d23750548ad98e1127d00fd2ea1d45fff8b97a1
@@ -1,17 +1,28 @@
1
1
  module Dina
2
2
  class AgentRole
3
- attr_accessor :agent #A known UUID for a Person
4
- attr_accessor :roles #an array of roles: Owner, Borrower, Prepared By
3
+ attr_accessor :agent #An array of known UUIDs for a Person
4
+ attr_accessor :roles #An array of roles: Owner, Borrower, Prepared By
5
5
  attr_accessor :date
6
6
  attr_accessor :remarks
7
7
 
8
8
  def initialize
9
+ @agent = []
10
+ @roles = []
11
+ end
12
+
13
+ def add_agent(id)
14
+ raise PropertyValueInvalid, "Agent must be a UUID." if !id.is_uuid?
15
+ @agent << id
16
+ end
17
+
18
+ def add_role(role)
19
+ @roles << role
9
20
  end
10
21
 
11
22
  def to_hash
12
23
  hash = {}
13
24
  instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
14
- hash
25
+ hash.deep_symbolize_keys
15
26
  end
16
27
 
17
28
  end
@@ -9,7 +9,7 @@ module Dina
9
9
  attr_accessor :determinationRemarks
10
10
  attr_accessor :typeStatus
11
11
  attr_accessor :typeStatusEvidence
12
- attr_accessor :determiner #A known UUID for a Person
12
+ attr_accessor :determiner #An array of known UUIDs for Person
13
13
  attr_accessor :determinedOn
14
14
  attr_accessor :qualifier
15
15
  attr_accessor :scientificNameSource
@@ -18,13 +18,53 @@ module Dina
18
18
  attr_accessor :isFiledAs #boolean
19
19
  attr_accessor :managedAttributes #array
20
20
 
21
+ attr_accessor :classification
22
+ attr_accessor :ranks
23
+
21
24
  def initialize
25
+ @scientificNameDetails = {}
26
+ @determiner = []
27
+ end
28
+
29
+ # Add a materialized classification string to scientificNameDetails
30
+ # Path should use pipes, "|" as separators
31
+ #
32
+ # @param path [String] the classification
33
+ def classification=(path)
34
+ if !path.instance_of?(String)
35
+ raise PropertyValueInvalid, "Classification must be a string with individual items separated by pipes."
36
+ end
37
+ @classification = path
38
+ scientificNameDetails.merge!({ classificationPath: path })
39
+ end
40
+
41
+ # Add a materialized ranks string to scientificNameDetails
42
+ # Ranks should use pipes, "|" as separators
43
+ #
44
+ # @param ranks [String] the ranks
45
+ def ranks=(ranks)
46
+ if !ranks.instance_of?(String)
47
+ raise PropertyValueInvalid, "Ranks must be a string with individual items separated by pipes."
48
+ end
49
+ @ranks = ranks
50
+ scientificNameDetails.merge!({ classificationRanks: ranks })
51
+ end
52
+
53
+ # Add a determiner as UUID to the array of determiner
54
+ #
55
+ # @param id [String] a UUID for a determiner
56
+ def add_determiner(id)
57
+ raise PropertyValueInvalid, "Determiner must be a UUID." if !id.is_uuid?
58
+ @determiner << id
22
59
  end
23
60
 
61
+ # Produce a hash with symbolized keys
24
62
  def to_hash
25
63
  hash = {}
64
+ remove_instance_variable(:@classification) if @classification
65
+ remove_instance_variable(:@ranks) if @ranks
26
66
  instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
27
- hash
67
+ hash.deep_symbolize_keys
28
68
  end
29
69
 
30
70
  end
@@ -9,17 +9,27 @@ module Dina
9
9
  attr_accessor :dwcGeoreferenceProtocol
10
10
  attr_accessor :dwcGeoreferenceSources
11
11
  attr_accessor :dwcGeoreferenceRemarks
12
- attr_accessor :dwcGeodeticDatum #A known UUID for a Person
12
+ attr_accessor :dwcGeodeticDatum
13
13
  attr_accessor :isPrimary
14
14
  attr_accessor :dwcGeoreferenceVerificationStatus
15
+ attr_accessor :createdOn
15
16
 
16
17
  def initialize
18
+ @georeferencedBy = []
19
+ end
20
+
21
+ # Add a georeferencedBy as UUID to the array
22
+ #
23
+ # @param id [String] a UUID for a georeferencedBy
24
+ def add_georeferencedBy(id)
25
+ raise PropertyValueInvalid, "georeferencedBy must be a UUID." if !id.is_uuid?
26
+ @georeferencedBy << id
17
27
  end
18
28
 
19
29
  def to_hash
20
30
  hash = {}
21
31
  instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
22
- hash
32
+ hash.deep_symbolize_keys
23
33
  end
24
34
 
25
35
  end
@@ -12,12 +12,20 @@ module Dina
12
12
  attr_accessor :address # with properties receiverName, companyName, addressLine1, addressLine2, city, provinceState, zipCode, country
13
13
 
14
14
  def initialize
15
+ @address = {}
16
+ end
17
+
18
+ def add_address(address)
19
+ if !address.instance_of?(Hash)
20
+ raise PropertyValueInvalid, "Address must be a Hash."
21
+ end
22
+ @address.merge!(address)
15
23
  end
16
24
 
17
25
  def to_hash
18
26
  hash = {}
19
27
  instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
20
- hash
28
+ hash.deep_symbolize_keys
21
29
  end
22
30
 
23
31
  end
@@ -10,6 +10,9 @@ module Dina
10
10
 
11
11
  belongs_to :person, shallow_path: true, class_name: "Person"
12
12
 
13
+ validates_presence_of :namespace, message: "namespace is required"
14
+ validates_presence_of :value, message: "value is required"
15
+
13
16
  def self.endpoint_path
14
17
  "agent-api/"
15
18
  end
@@ -30,7 +30,7 @@ module Dina
30
30
  property :dwcMaximumDepthInMeters, type: :float
31
31
  property :substrate, type: :string
32
32
  property :remarks, type: :string
33
- property :publiclyReleasable, type: :boolean
33
+ property :publiclyReleasable, type: :boolean, default: true
34
34
  property :notPubliclyReleasableReason, type: :string, default: nil
35
35
  property :tags, type: :array, default: []
36
36
  property :geographicPlaceNameSource, type: :string
@@ -29,7 +29,7 @@ module Dina
29
29
  property :materialSampleChildren, type: :array
30
30
  property :associations, type: :array, default: []
31
31
  property :tags, type: :array, default: []
32
- property :publiclyReleasable, type: :boolean
32
+ property :publiclyReleasable, type: :boolean, default: true
33
33
  property :notPubliclyReleasableReason, type: :string
34
34
  property :hostOrganism, type: :object, default: { name: nil, remarks: nil }
35
35
  property :scheduledActions, type: :object
@@ -6,7 +6,7 @@ module Dina
6
6
  property :createdBy, type: :string
7
7
  property :createdOn, type: :time
8
8
  property :group, type: :string
9
- property :dcFormat, type: :string
9
+ property :dcFormat, type: :string, default: "image/jpeg"
10
10
  property :dcType, type: :string
11
11
  property :acSubtype, type: :string
12
12
  property :fileIdentifier, type: :string
@@ -34,6 +34,10 @@ module Dina
34
34
  has_many :derivatives, class_name: "Derivative"
35
35
 
36
36
  validates_presence_of :group, message: "group is required"
37
+ validates_presence_of :dcFormat, message: "dcFormat is required"
38
+ validates_presence_of :dcType, message: "dcType is required"
39
+ validates_presence_of :xmpRightsUsageTerms, message: "xmpRightsUsageTerms is required"
40
+ validates_presence_of :dcRights, message: "dcRights is required"
37
41
 
38
42
  attr_accessor :accepted_types
39
43
 
@@ -16,8 +16,8 @@ module Dina
16
16
  property :dueDate, type: :time
17
17
  property :remarks, type: :string
18
18
  property :managedAttributes, type: :object
19
- property :agentRoles, type: :array
20
- property :shipment, type: :object
19
+ property :agentRoles, type: :array # Each of type Dina::AgentRole
20
+ property :shipment, type: :object # Of type Dina::Shipment
21
21
  property :createdBy, type: :string
22
22
  property :createdOn, type: :time
23
23
 
@@ -26,6 +26,7 @@ module Dina
26
26
  has_many :involved_agents, class_name: "Person"
27
27
 
28
28
  validates_presence_of :group, message: "group is required"
29
+ validates_presence_of :materialDirection, message: "materialDirection is required"
29
30
 
30
31
  attr_accessor :accepted_directions
31
32
 
@@ -1,30 +1,34 @@
1
1
  # encoding: utf-8
2
2
  class String
3
3
  def is_orcid?
4
- ::Dina::Identifier.is_orcid_regex.match?(self) &&
4
+ ::Dina::PersistentIdentifier.is_orcid_regex.match?(self) &&
5
5
  ::Dina::Identifier.orcid_valid_checksum(self)
6
6
  end
7
7
 
8
8
  def is_wiki_id?
9
- ::Dina::Identifier.is_wiki_regex.match?(self)
9
+ ::Dina::PersistentIdentifier.is_wiki_regex.match?(self)
10
10
  end
11
11
 
12
12
  def is_doi?
13
- ::Dina::Identifier.is_doi_regex.match?(self)
13
+ ::Dina::PersistentIdentifier.is_doi_regex.match?(self)
14
+ end
15
+
16
+ def is_uuid?
17
+ ::Dina::PersistentIdentifier.is_uuid_regex.match?(self)
14
18
  end
15
19
 
16
20
  def orcid_from_url
17
- ::Dina::Identifier.extract_orcid_regex.match(self)[0] rescue nil
21
+ ::Dina::PersistentIdentifier.extract_orcid_regex.match(self)[0] rescue nil
18
22
  end
19
23
 
20
24
  def wiki_from_url
21
- ::Dina::Identifier.extract_wiki_regex.match(self)[0] rescue nil
25
+ ::Dina::PersistentIdentifier.extract_wiki_regex.match(self)[0] rescue nil
22
26
  end
23
27
 
24
28
  end
25
29
 
26
30
  module Dina
27
- class Identifier
31
+ class PersistentIdentifier
28
32
 
29
33
  class << self
30
34
  def is_orcid_regex
@@ -39,6 +43,10 @@ module Dina
39
43
  /^10.\d{4,9}\/[-._;()\/:<>A-Z0-9]+$/i
40
44
  end
41
45
 
46
+ def is_uuid_regex
47
+ /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
48
+ end
49
+
42
50
  def orcid_valid_checksum(orcid_string)
43
51
  parts = orcid_string.scan(/[0-9X]/)
44
52
  mod = parts[0..14].map(&:to_i)
data/lib/dina/version.rb CHANGED
@@ -3,7 +3,7 @@ module Dina
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 5
6
- PATCH = 2
6
+ PATCH = 3
7
7
  BUILD = 0
8
8
 
9
9
  def self.version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2.0
4
+ version: 0.5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David P. Shorthouse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-08 00:00:00.000000000 Z
11
+ date: 2022-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_api_client