dina 0.9.0.0 → 0.9.2.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: 27acdf30e09b690b73f8259fb85b62336c19af883559d1c37f29956fd1a65def
4
- data.tar.gz: 3407082f98d36a8ff78301e48a5aa28c45482b27ccfd25d579c887d7bb12d155
3
+ metadata.gz: 4d8c290f712923b2bafe35e05adfb3ceea63ee0bc6d5feff86bcbd1a1419c562
4
+ data.tar.gz: 406853667848946c07e023d41470bf625898e81d917d6fe3eb13408324224c56
5
5
  SHA512:
6
- metadata.gz: 548ddc0feac986f42f2f36ac2a1887639f67cf647215e8f0d0f27977886a92213bc6ca8912576c8abcb110e0b2fe37a3ab36f544f0b4c63b484e3cf864a6a187
7
- data.tar.gz: 6b51728d08aa817222e7d8ddd32085bede6abac6553a815aa4f80d7d4d846e16a0bc1d24912faf70b60b98dd218232b7ab038043971a8fd72c54926100592d0c
6
+ metadata.gz: 7240f2a9e0f637cbc35515ec956f8e39ed42fe0d4472b4397302a85a3835a23feecff76862c7174c40656dd29f51db4f31bc29a2d7ddc508eb2ff00554c89b9b
7
+ data.tar.gz: c48bd3f5d7032bdf40468998cafe4288b96b0934995be5e84aeafd1e342b8cac37f9903aac4dc5366d093aebef64ccfc0fc62adfa2d969f416b855750c07f8e0
@@ -53,16 +53,12 @@ module Dina
53
53
  Keycloak.auth_server_url = config.authorization_url
54
54
  Keycloak.realm = config.realm
55
55
 
56
- if ::File.zero?(config.token_store_file)
56
+ if ::File.zero?(config.token_store_file) || !token.key?(config.server_name.to_sym)
57
57
  write_token(data: empty_token)
58
58
  end
59
59
  end
60
60
 
61
- # Gets, sets, and renews a Bearer access token as required
62
- # and produces a Header string
63
- #
64
- # WARNING: this is not likely to be threadsafe unless we do away with @token
65
- # and load the token_store_file with every call to header
61
+ # Gets, sets, and renews a Bearer access token as required and produces a Header string
66
62
  #
67
63
  # @return [String] the Bearer token
68
64
  def header
@@ -9,7 +9,11 @@ module Dina
9
9
  attr_accessor :zipCode
10
10
  attr_accessor :country
11
11
 
12
- def initialize
12
+ def initialize(params = {})
13
+ params.each do |key, value|
14
+ setter = "#{key}="
15
+ send(setter, value) if respond_to?(setter.to_sym, false)
16
+ end
13
17
  end
14
18
 
15
19
  def to_hash
@@ -8,7 +8,11 @@ module Dina
8
8
  attr_accessor :country
9
9
  attr_accessor :recordedOn
10
10
 
11
- def initialize
11
+ def initialize(params = {})
12
+ params.each do |key, value|
13
+ setter = "#{key}="
14
+ send(setter, value) if respond_to?(setter.to_sym, false)
15
+ end
12
16
  end
13
17
 
14
18
  def to_hash
@@ -0,0 +1,26 @@
1
+ module Dina
2
+ class ProtocolData
3
+ attr_accessor :key
4
+ attr_accessor :vocabularyBased #boolean
5
+ attr_accessor :protocolDataElement #array
6
+
7
+ def initialize
8
+ @protocolDataElement = []
9
+ end
10
+
11
+ def add_data_element(data_element)
12
+ if !data_element.instance_of?(ProtocolDataElement)
13
+ raise PropertyValueInvalid, "Data Element must be a ProtocolDataElement."
14
+ end
15
+ @protocolDataElement << data_element.to_hash
16
+ end
17
+
18
+ # Produce a hash with symbolized keys
19
+ def to_hash
20
+ hash = {}
21
+ instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
22
+ hash.deep_symbolize_keys
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ module Dina
2
+ class ProtocolDataElement
3
+ attr_accessor :elementType #string
4
+ attr_accessor :value #string
5
+ attr_accessor :vocabularyBased #boolean
6
+ attr_accessor :unit #string
7
+
8
+ def initialize(params = {})
9
+ params.each do |key, value|
10
+ setter = "#{key}="
11
+ send(setter, value) if respond_to?(setter.to_sym, false)
12
+ end
13
+ end
14
+
15
+ def to_hash
16
+ hash = {}
17
+ instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
18
+ hash.deep_symbolize_keys
19
+ end
20
+
21
+ end
22
+ end
@@ -6,7 +6,11 @@ module Dina
6
6
  attr_accessor :remarks
7
7
  attr_accessor :assignedTo
8
8
 
9
- def initialize
9
+ def initialize(params = {})
10
+ params.each do |key, value|
11
+ setter = "#{key}="
12
+ send(setter, value) if respond_to?(setter.to_sym, false)
13
+ end
10
14
  end
11
15
 
12
16
  def to_hash
@@ -16,10 +16,10 @@ module Dina
16
16
  end
17
17
 
18
18
  def add_address(address)
19
- if !address.instance_of?(Hash)
20
- raise PropertyValueInvalid, "Address must be a Hash."
19
+ if !address.instance_of?(Address)
20
+ raise PropertyValueInvalid, "Address must be of type Address."
21
21
  end
22
- @address.merge!(address)
22
+ @address.merge!(address.to_hash)
23
23
  end
24
24
 
25
25
  def to_hash
@@ -5,7 +5,9 @@ module Dina
5
5
  property :id, type: :string, default: SecureRandom.uuid
6
6
  property :group, type: :string
7
7
  property :name, type: :string
8
+ property :protocolType, type: :string
8
9
  property :multilingualDescription, type: :multilingual_description
10
+ property :protocolData, type: :array
9
11
  property :createdBy, type: :string
10
12
  property :createdOn, type: :time
11
13
 
@@ -3,7 +3,6 @@ require_rel '../base_model'
3
3
  module Dina
4
4
  class Derivative < BaseModel
5
5
  property :id, type: :string, default: SecureRandom.uuid
6
- property :group, type: :string
7
6
  property :bucket, type: :string
8
7
  property :fileIdentifier, type: :string
9
8
  property :fileExtension, type: :string
@@ -13,10 +12,13 @@ module Dina
13
12
  property :acHashValue, type: :string
14
13
  property :derivativeType, type: :string
15
14
 
16
- belongs_to :ac_derived_from, shallow_path: true, class_name: "ObjectStore"
15
+ has_one :ac_derived_from, class_name: "ObjectStore"
17
16
 
18
- validates_presence_of :group, message: "group is required"
19
17
  validates_presence_of :bucket, message: "bucket is required"
18
+ validates_presence_of :dcFormat, message: "dcFormat is required"
19
+ validates_presence_of :dcType, message: "dcType is required"
20
+ validates_presence_of :fileIdentifier, message: "fileIdentifier is required"
21
+ validates_presence_of :fileExtension, message: "fileExtension is required"
20
22
 
21
23
  def self.endpoint_path
22
24
  "objectstore-api/"
@@ -29,9 +31,6 @@ module Dina
29
31
  private
30
32
 
31
33
  def on_before_save
32
- if self.group && self.bucket.nil?
33
- self.bucket = self.group.downcase
34
- end
35
34
  super
36
35
  end
37
36
 
data/lib/dina/version.rb CHANGED
@@ -3,7 +3,7 @@ module Dina
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 9
6
- PATCH = 0
6
+ PATCH = 2
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.9.0.0
4
+ version: 0.9.2.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: 2023-02-24 00:00:00.000000000 Z
11
+ date: 2023-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_api_client
@@ -156,6 +156,8 @@ files:
156
156
  - lib/dina/components/determination.rb
157
157
  - lib/dina/components/geographic_source.rb
158
158
  - lib/dina/components/georeference_assertion.rb
159
+ - lib/dina/components/protocol_data.rb
160
+ - lib/dina/components/protocol_data_element.rb
159
161
  - lib/dina/components/scheduled_action.rb
160
162
  - lib/dina/components/shipment.rb
161
163
  - lib/dina/exceptions.rb