dina 0.5.1.0 → 0.5.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52ee6aa08c01721d7d2b925a616f1800c303a7d5801ac7080ec3c2d2a270a04d
4
- data.tar.gz: 0a2f3e2e2bf4d9cc8ddd4b3534fd8309dae734c02299cac986e36abaa15431cb
3
+ metadata.gz: f73e6c200e682c91492c0f50854dc73a9fac3537a65eb12a5fe1d974b72adf09
4
+ data.tar.gz: 4fa9641b7ff96f95c88b30b1e6857aa9e02dc6ae8639efd84aa034a0908fa182
5
5
  SHA512:
6
- metadata.gz: 7a9352df0039a613fa279753da7f2464e572110887024be28bd486368ca2ee5d0afebc0bcffc535b30ce7779b997e8fc3f2b74e739a10d12b752a55d2c673608
7
- data.tar.gz: 6f3560ea41463b841cf01affddc47165d90383c7c303f5f110bfcc96702a8f7b4ee8dbd1a7d8310ab7facc8086042a4de5eba2a1c0381a018c2a999a4a3295c2
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
@@ -24,7 +24,8 @@ module Dina
24
24
  end
25
25
 
26
26
  def initialize(params = {})
27
- params[:id] = SecureRandom.uuid if !params[:id]
27
+ symbolized_params = params.transform_keys(&:to_sym)
28
+ params["id"] = SecureRandom.uuid if !symbolized_params[:id]
28
29
  super
29
30
  end
30
31
 
@@ -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
@@ -20,7 +20,7 @@ module Dina
20
20
  property :acHashValue, type: :string
21
21
  property :xmpRightsUsageTerms, type: :string, default: "Government of Canada Usage Term"
22
22
  property :xmpRightsWebStatement, type: :string, default: "https://open.canada.ca/en/open-government-licence-canada"
23
- property :dcRights, type: :string, default: "© Her Majesty The Queen in Right of Canada, as represented by the Minister of Agriculture and Agri-Food | © Sa Majesté la Reine du chef du Canada, représentée par le ministre de l’Agriculture et de l’Agroalimentaire"
23
+ property :dcRights, type: :string, default: "© His Majesty The King in Right of Canada, as represented by the Minister of Agriculture and Agri-Food | © Sa Majesté le Roi du chef du Canada, représentée par le ministre de l’Agriculture et de l’Agroalimentaire"
24
24
  property :xmpRightsOwner, type: :string, default: "Government of Canada"
25
25
  property :publiclyReleasable, type: :boolean, default: true
26
26
  property :notPubliclyReleasableReason, 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 = 1
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.1.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