tiny_gid 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +1 -1
- data/lib/tiny_gid.rb +13 -9
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bbfe56b82c1febf13d59f7af4f34d6b6dd990fda2778589017aea0cf3014974c
|
|
4
|
+
data.tar.gz: 32b4292c06d7f134b97130b32b23fb0ffb39c15bcaaea450c48b20cb6e2e65a3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 601f57d44f7c1faacdd86d7a07fbe10bf0edf39dd3e303cc457a859168512e0bc2bb35ab426e27254dc5917b974d2791e918229b0ff3c294d5825c14363f0421
|
|
7
|
+
data.tar.gz: bd62bc67c7182fdbaa0a51703e28ae2af914199e0938c904d7a39e0e5ae0b1ad446b5dc37171d00c4d8fda89c2310c1b8443c9bb9f324f793a786718fa8dd18d
|
data/README.md
CHANGED
|
@@ -69,7 +69,7 @@ Don't yah think?
|
|
|
69
69
|
|
|
70
70
|
Using application/x-www-form-urlencoded encoding to match GlobalID. Should probably support URL encoding too.
|
|
71
71
|
|
|
72
|
-
To put that in 21st century speak: spaces
|
|
72
|
+
To put that in 21st century speak: spaces will be replaced with `+` not `%20`.
|
|
73
73
|
|
|
74
74
|
## Signed Global IDs
|
|
75
75
|
|
data/lib/tiny_gid.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require "uri"
|
|
4
4
|
|
|
5
5
|
module TinyGID
|
|
6
|
-
VERSION = "0.0.
|
|
6
|
+
VERSION = "0.0.2"
|
|
7
7
|
FORMAT = "gid://%s/%s/%s"
|
|
8
8
|
|
|
9
9
|
module MethodMissing # :nodoc:
|
|
@@ -17,7 +17,7 @@ module TinyGID
|
|
|
17
17
|
raise TypeError, "gid::#{name} params must be a Hash. Received: #{params.class}" unless params.is_a?(Hash)
|
|
18
18
|
|
|
19
19
|
app = params.delete(:__app__) || TinyGID.app
|
|
20
|
-
raise "gid::#{name} cannot be generated: missing app" unless app
|
|
20
|
+
raise "gid::#{name} cannot be generated: missing app name" unless app
|
|
21
21
|
|
|
22
22
|
gid = sprintf(FORMAT, app, name, URI.encode_www_form_component(id))
|
|
23
23
|
return gid unless params.any?
|
|
@@ -37,15 +37,13 @@ module TinyGID
|
|
|
37
37
|
|
|
38
38
|
def app(name = nil)
|
|
39
39
|
if block_given?
|
|
40
|
-
raise ArgumentError, "block provided without
|
|
40
|
+
raise ArgumentError, "block provided without an app name to scope to" unless name
|
|
41
41
|
|
|
42
42
|
begin
|
|
43
|
-
|
|
44
|
-
@app = name
|
|
45
|
-
|
|
43
|
+
Thread.current[:__tiny_gid_app__] = name
|
|
46
44
|
yield self
|
|
47
45
|
ensure
|
|
48
|
-
|
|
46
|
+
Thread.current[:__tiny_gid_app__] = nil
|
|
49
47
|
end
|
|
50
48
|
|
|
51
49
|
return
|
|
@@ -54,8 +52,14 @@ module TinyGID
|
|
|
54
52
|
# No block but given a name, just set it :|
|
|
55
53
|
@app = name if name
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
case
|
|
56
|
+
when Thread.current[:__tiny_gid_app__]
|
|
57
|
+
Thread.current[:__tiny_gid_app__]
|
|
58
|
+
when @app
|
|
59
|
+
@app
|
|
60
|
+
when defined?(Rails) && Rails.respond_to?(:application)
|
|
61
|
+
Rails.application.name
|
|
62
|
+
end
|
|
59
63
|
end
|
|
60
64
|
|
|
61
65
|
# Necessary?
|