globalid 0.5.2 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/global_id/fixture_set.rb +13 -0
- data/lib/global_id/railtie.rb +5 -0
- data/lib/global_id/uri/gid.rb +4 -7
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5a7361595eea95f395b66f4a79123ad35e61b7008d256646bea775291fa9f41
|
4
|
+
data.tar.gz: a9ece75bb440f6b49b8ad623b976bc05f4f3da2151104d045d1b7305c4a8d9b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8290a4a79953bb92053c2f52ae847c557e7f5d4f0528124c7f1217ee4a34b5c7d42290a2584d729e0c5011c05cd1df4c9c073be49bde7d4fa13597f44a52513f
|
7
|
+
data.tar.gz: 2d9e7c573f7223406733b8be7ce1d6d764cca584bcfbb0a3f2ffb8d6f71f82970ceacf827e9c8a251975c0681b5d7d8293c1e158927dbf38f362e1337fd027ce
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GlobalID
|
4
|
+
module FixtureSet
|
5
|
+
def signed_global_id(fixture_set_name, label, column_type: :integer, **options)
|
6
|
+
identifier = identify(label, column_type)
|
7
|
+
model_name = default_fixture_model_name(fixture_set_name)
|
8
|
+
uri = URI::GID.build([GlobalID.app, model_name, identifier, {}])
|
9
|
+
|
10
|
+
SignedGlobalID.new(uri, **options)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/global_id/railtie.rb
CHANGED
@@ -37,6 +37,11 @@ class GlobalID
|
|
37
37
|
require 'global_id/identification'
|
38
38
|
send :include, GlobalID::Identification
|
39
39
|
end
|
40
|
+
|
41
|
+
ActiveSupport.on_load(:active_record_fixture_set) do
|
42
|
+
require 'global_id/fixture_set'
|
43
|
+
send :extend, GlobalID::FixtureSet
|
44
|
+
end
|
40
45
|
end
|
41
46
|
end
|
42
47
|
end
|
data/lib/global_id/uri/gid.rb
CHANGED
@@ -123,9 +123,6 @@ module URI
|
|
123
123
|
private
|
124
124
|
COMPONENT = [ :scheme, :app, :model_name, :model_id, :params ].freeze
|
125
125
|
|
126
|
-
# Extracts model_name and model_id from the URI path.
|
127
|
-
PATH_REGEXP = %r(\A/([^/]+)/?([^/]+)?\z)
|
128
|
-
|
129
126
|
def check_host(host)
|
130
127
|
validate_component(host)
|
131
128
|
super
|
@@ -145,11 +142,11 @@ module URI
|
|
145
142
|
end
|
146
143
|
|
147
144
|
def set_model_components(path, validate = false)
|
148
|
-
_, model_name, model_id = path.
|
149
|
-
model_id = CGI.unescape(model_id) if model_id
|
150
|
-
|
145
|
+
_, model_name, model_id = path.split('/', 3)
|
151
146
|
validate_component(model_name) && validate_model_id(model_id, model_name) if validate
|
152
147
|
|
148
|
+
model_id = CGI.unescape(model_id) if model_id
|
149
|
+
|
153
150
|
@model_name = model_name
|
154
151
|
@model_id = model_id
|
155
152
|
end
|
@@ -162,7 +159,7 @@ module URI
|
|
162
159
|
end
|
163
160
|
|
164
161
|
def validate_model_id(model_id, model_name)
|
165
|
-
return model_id unless model_id.blank?
|
162
|
+
return model_id unless model_id.blank? || model_id.include?('/')
|
166
163
|
|
167
164
|
raise MissingModelIdError, "Unable to create a Global ID for " \
|
168
165
|
"#{model_name} without a model id."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: globalid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- MIT-LICENSE
|
48
48
|
- README.md
|
49
49
|
- lib/global_id.rb
|
50
|
+
- lib/global_id/fixture_set.rb
|
50
51
|
- lib/global_id/global_id.rb
|
51
52
|
- lib/global_id/identification.rb
|
52
53
|
- lib/global_id/locator.rb
|
@@ -59,7 +60,7 @@ homepage: http://www.rubyonrails.org
|
|
59
60
|
licenses:
|
60
61
|
- MIT
|
61
62
|
metadata: {}
|
62
|
-
post_install_message:
|
63
|
+
post_install_message:
|
63
64
|
rdoc_options: []
|
64
65
|
require_paths:
|
65
66
|
- lib
|
@@ -74,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
75
|
- !ruby/object:Gem::Version
|
75
76
|
version: '0'
|
76
77
|
requirements: []
|
77
|
-
rubygems_version: 3.
|
78
|
-
signing_key:
|
78
|
+
rubygems_version: 3.5.0.dev
|
79
|
+
signing_key:
|
79
80
|
specification_version: 4
|
80
81
|
summary: 'Refer to any model with a URI: gid://app/class/id'
|
81
82
|
test_files: []
|