tiny_gid 0.1.2 → 0.1.3

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Changes +4 -0
  3. data/README.md +4 -0
  4. data/lib/tiny_gid.rb +7 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47d930f4fc7a4bf64f70469a37c47ef8260ea708b698b3316b5e8d5853e0a15b
4
- data.tar.gz: 96fca70d0822cb8f642c6037cc156d930d3312112e225fe2673eae68d62d1012
3
+ metadata.gz: 4f978825ea29d077b0e40f8fb2c8a2535094f7d95b53a14e71b9cee89b1ac8ce
4
+ data.tar.gz: f71a497d4330b31c776f85a04d0be17f4723a6b6129b61c2eacdf5af2e00ced9
5
5
  SHA512:
6
- metadata.gz: 3a53ce651ae1a455e5f2950c2cfac63b7e2b9a382bd1ff1bbc667df8e85b1e823a0f5c4393da8ef923561f9e5d955b328a520f295ad2446dd0e289a123d32f92
7
- data.tar.gz: 644f888231bcf5e2ab7b1b54ab1b69c9ff3e383cfc46eba4f9a0168a1d2b793e1a6c1f65264d3d67bad5a91c1c292a4360899967f069c7973236b19178bbb810
6
+ metadata.gz: 7122a84df61b0dc60f1e99553f6070cac43915ad0c194bca8d74b90c49fe240ba6eee494f9d17003edbb8e5c038ddb86a1e80bd233ee873a54d32aa2ba4d6128
7
+ data.tar.gz: 86643f2b16e82f14861b92eafc26170d4cd4e452cf53fd48f8fc772e8b5623bce4c93bab080fa9d301241835a0307883da819808f8a85b64099e8071a0942633
data/Changes CHANGED
@@ -1,3 +1,7 @@
1
+ v0.1.3 2026-12-05
2
+ --------------------
3
+ Add forced conversion methods, e.g., gid::Foo!(id), that accept a scalar ID or a global ID
4
+
1
5
  v0.1.2 2026-04-19
2
6
  --------------------
3
7
  Add #parse and #to_sc methods to TinyGID (were only class methods prior)
data/README.md CHANGED
@@ -91,6 +91,10 @@ To put that in 21st century speak: spaces will be replaced with `+` not `%20`.
91
91
 
92
92
  No support. Use GlobalID :)
93
93
 
94
+ ## See Also
95
+
96
+ [shopify-gid](https://github.com/estrattonbailey/shopify-gid) - JavaScript encoder/decoder for GIDs returned from the Shopify Storefront API
97
+
94
98
  ## Author
95
99
 
96
100
  Skye Shaw [skye.shaw -AT- gmail.com]
data/lib/tiny_gid.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require "uri"
4
4
 
5
5
  class TinyGID
6
- VERSION = "0.1.2"
6
+ VERSION = "0.1.3"
7
7
  FORMAT = "gid://%s/%s/%s"
8
8
  REGEX = %r{\Agid://([^/]+)/([^/]+)/([^/?]+)(?:\?(.*?))?\z}
9
9
 
@@ -14,6 +14,12 @@ class TinyGID
14
14
  id = arguments.shift
15
15
  raise ArgumentError, "gid::#{name} requires an ID" unless id
16
16
 
17
+ # gid::Foo!(id) accepts a scalar ID or a global ID. A global ID is returned as-is.
18
+ if name.end_with?("!")
19
+ return id if id.is_a?(String) && id =~ REGEX
20
+ name = name.to_s.chomp("!")
21
+ end
22
+
17
23
  params = (arguments[0] || {}).dup
18
24
  raise TypeError, "gid::#{name} params must be a Hash. Received: #{params.class}" unless params.is_a?(Hash)
19
25
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_gid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skye Shaw
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-19 00:00:00.000000000 Z
11
+ date: 2026-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec