uc3-dmp-id 0.0.12 → 0.0.14

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: c0a0a7c8a7c2ec3b7bfdc0051c323b85ba6f7bb14aa0bc1f77e499b7682b3814
4
- data.tar.gz: 9bb5fa376caa1d07bd243cebad4b5757771eb996a4723c200366c034fdf56b2c
3
+ metadata.gz: db1f76572c527c11eaf8e14afa51c095eab796c53c631d6fe1b78bca2c5f3395
4
+ data.tar.gz: 671c4b0a629837069b23286876b2cd871caab2f9df1bc011b91e68f68bf45bff
5
5
  SHA512:
6
- metadata.gz: 8b8ff1171c5127af8fedbfe85bf2c74b4a61f25dc4bab73e42fa1903bbe36c9a20adb0f9db2b1906c6542f7172496ea9173b05c047b20392577d5cc9341002db
7
- data.tar.gz: '079687ec9e07dddde7afcbcd9d1b6dc0b3606276f735e4040ca0183e378f1bc0c72017747d48dde140c32b922e7ce6825afc5b3961d6b93503ce4c2052226495'
6
+ metadata.gz: 76c00b9f95b7b5fefac06ba75696e6b5fc6b1ddb244093888b08899b79d2df98996a70c7c3026bcebcc3bf91030fced1172587dc1494419dad101cd30e1a87bf
7
+ data.tar.gz: 4664882d1dbf1ef2ba593b8ca4858829b4c05e767bb94e107a7db6b24370ca6739983b53b66eef56909bb7f713fdaeba05f8d71217ae181ad87ef43824d6d64d
@@ -60,21 +60,26 @@ module Uc3DmpId
60
60
  def by_pk(p_key:, s_key: Helper::DMP_LATEST_VERSION, client: nil, debug: false)
61
61
  raise Uc3DmpIdFinderError, MSG_MISSING_PK if p_key.nil?
62
62
 
63
- s_key = Helper::DMP_LATEST_VERSION if s_key.nil? || s_key.strip.empty?
63
+ s_key = Helper::DMP_LATEST_VERSION if s_key.nil? || s_key.to_s.strip.empty?
64
+
65
+ puts "PK: #{p_key}, SK: #{s_key}"
64
66
 
65
67
  client = client.nil? ? Uc3DmpDynamo::Client.new(debug: debug) : client
66
68
  resp = client.get_item(
67
69
  key: {
68
70
  PK: Helper.append_pk_prefix(p_key: p_key),
69
- SK: s_key.nil? || s_key.strip.empty? ? Helper::DMP_LATEST_VERSION : s_key
71
+ SK: s_key
70
72
  }
71
73
  )
72
74
  return resp unless resp.is_a?(Hash)
73
75
 
76
+ puts "FETCHED:"
77
+ puts resp
78
+
74
79
  dmp = resp['dmp'].nil? ? JSON.parse({ dmp: resp }.to_json) : resp
75
- return nil if resp['dmp']['PK'].nil?
80
+ return nil if dmp['dmp']['PK'].nil?
76
81
 
77
- _append_versions(p_key: resp['dmp']['PK'], dmp: dmp, client: client, debug: debug)
82
+ _append_versions(p_key: dmp['dmp']['PK'], dmp: dmp, client: client, debug: debug)
78
83
  end
79
84
 
80
85
  # Attempt to find the DMP item by the provenance system's identifier
@@ -98,7 +103,7 @@ module Uc3DmpId
98
103
  return resp unless resp.is_a?(Hash)
99
104
 
100
105
  dmp = resp['dmp'].nil? ? JSON.parse({ dmp: resp }.to_json) : resp
101
- return nil if resp['dmp']['PK'].nil?
106
+ return nil if dmp['dmp']['PK'].nil?
102
107
 
103
108
  # If we got a hit, fetch the DMP and return it.
104
109
  by_pk(p_key: dmp['dmp']['PK'], s_key: dmp['dmp']['SK'])
@@ -112,10 +117,16 @@ module Uc3DmpId
112
117
  def _append_versions(p_key:, dmp:, client: nil, debug: false)
113
118
  return dmp if p_key.nil? || !dmp.is_a?(Hash) || dmp['dmp'].nil?
114
119
 
120
+ puts "FETCHING VERSIONS"
121
+
115
122
  results = versions(p_key: p_key, client: client, debug: debug)
116
123
  return dmp unless results.length > 1
117
124
 
118
- versions = results.map do |version|
125
+ versions = results.map do |ver|
126
+
127
+ puts version
128
+
129
+ version = ver['dmp'].nil? ? JSON.parse({ dmp: ver }.to_json) : ver
119
130
  next if version.fetch('dmp', {})['modified'].nil?
120
131
 
121
132
  timestamp = version['dmp']['modified']
@@ -125,6 +136,10 @@ module Uc3DmpId
125
136
  }
126
137
  end
127
138
  dmp['dmp']['dmphub_versions'] = JSON.parse(versions.to_json)
139
+
140
+ puts "AFTER APPENDING VERSIONS:"
141
+ puts dmp
142
+
128
143
  dmp
129
144
  end
130
145
  # rubocop:enable Metrics/AbcSize
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.12'
4
+ VERSION = '0.0.14'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley