ons-firestore 1.2.0 → 1.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: b1409410ed2eeda669760d9de820c52475fdc0430dc2ca073830587102d8cb23
4
- data.tar.gz: 956e2ad87753f9a8e13dca996ad3d1f3be3362689e993ac077c7d5865b34e413
3
+ metadata.gz: 4e6104269a49789359ba927ce1673d9e25b19afdd48caab6ae01f6ca4d99b757
4
+ data.tar.gz: 573ed986f15a3007c20d5196c67f590d34c260f68b0a3ff2314621eddf1e8a21
5
5
  SHA512:
6
- metadata.gz: b9f264f04c6e0f64ef1befda1294236a2153aa64f4862d63c0d4addfca5ac0931a4358c37f707a7786388616849a29e56970523bcd831938087f58add0eb5409
7
- data.tar.gz: 11e1f4f2512587bc54de61647cae2e007f1cbac20b0cbd7f50bddb32a19b265de464ce2e1e90bbd1eddf5dd0d620d406aede404052f2df8b1629deabe6fe9694
6
+ metadata.gz: 01cce206bdc4f36f909304aef53704b0d51e6f6ba7dcb77af2d6f90d8adb4773dcf38c11893555da99c2f2fa2aad7cb3001fb012c409d6a4f053a51d9efe8712
7
+ data.tar.gz: 6e85af05d6baa2d6b364c743cda54c2027dd717af567baafb0f3df1350fa70817b9ee011b50eb44a05cfee6a892a08356e22730634894b0b679b65de5886ce03
@@ -44,6 +44,24 @@ class Firestore
44
44
  @client.col(collection_name).doc(document_name)
45
45
  end
46
46
 
47
+ # Reads the +updated+ key within a Firestore document.
48
+ #
49
+ # @param collection_name [String] the name of the Firestore collection containing the document
50
+ # @param document_name [String] the name of the Firestore document
51
+ # @return [Object] document updated timestamp
52
+ # @raise [ArgumentError] if collection_name or document_name are nil
53
+ # @raise [FirestoreError] if the +updated+ key isn't present within the Firestore document
54
+ def document_updated(collection_name, document_name)
55
+ raise ArgumentError.new('collection_name cannot be nil') if collection_name.nil?
56
+ raise ArgumentError.new('document_name cannot be nil') if document_name.nil?
57
+
58
+ document = @client.col(collection_name).doc(document_name)
59
+ snapshot = document.get
60
+ raise FirestoreError, 'updated key is missing' if snapshot.updated.nil?
61
+
62
+ snapshot[:updated]
63
+ end
64
+
47
65
  # Reads the +data+ key within a Firestore document.
48
66
  #
49
67
  # @param collection_name [String] the name of the Firestore collection containing the document
@@ -57,7 +75,7 @@ class Firestore
57
75
 
58
76
  document = @client.col(collection_name).doc(document_name)
59
77
  snapshot = document.get
60
- raise FirestoreError('data key is missing') if snapshot.data.nil?
78
+ raise FirestoreError, 'data key is missing' if snapshot.data.nil?
61
79
 
62
80
  snapshot[:data]
63
81
  end
@@ -92,7 +110,7 @@ class Firestore
92
110
  begin
93
111
  document.set({ data: hash_data, updated: Time.now.strftime(DATE_TIME_FORMAT) })
94
112
  rescue StandardError => e
95
- raise FirestoreError("Failed to save Firestore document #{document_name} in collection #{collection_name}: #{e.message}")
113
+ raise FirestoreError, "Failed to save Firestore document #{document_name} in collection #{collection_name}: #{e.message}"
96
114
  end
97
115
  end
98
116
  end
@@ -3,7 +3,7 @@
3
3
  module ONSFirestore
4
4
  module Version
5
5
  MAJOR = 1
6
- MINOR = 2
6
+ MINOR = 3
7
7
  TINY = 0
8
8
  end
9
9
  VERSION = [Version::MAJOR, Version::MINOR, Version::TINY].compact * '.'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ons-firestore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Topley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-06 00:00:00.000000000 Z
11
+ date: 2023-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-firestore
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  requirements: []
102
- rubygems_version: 3.3.3
102
+ rubygems_version: 3.3.15
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Opinionated Google Firestore abstraction.