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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/tiny_gid.rb +13 -9
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a33939d63b7efe92195e8ff5065083e03061920f0bcafc0b853c43d371c5bf6
4
- data.tar.gz: a6245c347ca86b527a67480c888939d57a4070e64d4668c540cf5c09ad971a0f
3
+ metadata.gz: bbfe56b82c1febf13d59f7af4f34d6b6dd990fda2778589017aea0cf3014974c
4
+ data.tar.gz: 32b4292c06d7f134b97130b32b23fb0ffb39c15bcaaea450c48b20cb6e2e65a3
5
5
  SHA512:
6
- metadata.gz: 7d57726cc44177123d78a1f7be65ecbcd5dc941c2a58c3238c889a49e8b388c2800fe734011d6c5e3f05f0b99c367f86e664ffaa1b8e54196528697c06a83254
7
- data.tar.gz: 2bb181b90609740663d80cf2a30fc5c3ed80e542ce50d9322272823122cdb86e57d123ea17021b3fbcf3df5a2245621e825d9a8358da86a88b41340a68b7ba25
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 with be replaced with `+` not `%20`.
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.1"
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 a app to scope to" unless name
40
+ raise ArgumentError, "block provided without an app name to scope to" unless name
41
41
 
42
42
  begin
43
- og = @app
44
- @app = name
45
-
43
+ Thread.current[:__tiny_gid_app__] = name
46
44
  yield self
47
45
  ensure
48
- @app = og
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
- return @app if @app
58
- return Rails.application.name if defined?(Rails) && Rails.respond_to?(:application)
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?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_gid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skye Shaw