ur 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/ur/version.rb +1 -1
- data/lib/ur/weblink.rb +9 -7
- data/lib/ur.rb +12 -10
- data/ur.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b856342339ad2804ef44731304ee8ecc7801bf090ce019d00751bb8b491df4ff
|
4
|
+
data.tar.gz: 75095d90b5e6e4ebff5020fff905a2b52348be06aa2495b8dfe79c730f6e8cc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5934007c613d667498a52cc36238b9d7ff378381945a4d1fceaeb87f4be73cf93af4336701a4a076aea8c1e47de377ada03071a6e0cb52ebf30764bcfd1d1dd5
|
7
|
+
data.tar.gz: b6a86b4deac6c7d452aaa46bd828d4695ef954bf085a94d0d86bcbf290e4dcc9759a31eb7b726471f09c8999981a3e455349e07be062411762e3899de6c344a2
|
data/CHANGELOG.md
CHANGED
data/lib/ur/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
UR_VERSION = "0.2.
|
1
|
+
UR_VERSION = "0.2.4".freeze
|
data/lib/ur/weblink.rb
CHANGED
@@ -20,6 +20,14 @@ module Ur
|
|
20
20
|
class NoContextError < Error
|
21
21
|
end
|
22
22
|
|
23
|
+
ATTR_CHAR = /[a-zA-Z0-9!#\$&+\-.^_`|~]/.freeze # defined in https://tools.ietf.org/html/rfc5987#section-3.2.1
|
24
|
+
PTOKEN = %r([a-zA-Z0-9!#\$%&'()*+\-./:<=>?@\[\]^_`{|}~]).freeze
|
25
|
+
QUOTED_STRING = /"([^"]*)"/.freeze
|
26
|
+
|
27
|
+
# attributes: semicolon, some attr_chars, an optional asterisk, equals, and a quoted
|
28
|
+
# string or series of unquoted ptokens
|
29
|
+
ATTRIBUTE_PAIR = /\s*;\s*(#{ATTR_CHAR.source}+\*?)\s*=\s*(?:#{QUOTED_STRING.source}|(#{PTOKEN.source}+))\s*/.freeze
|
30
|
+
|
23
31
|
# parses an array of Web Links from the value an HTTP Link header, as described in
|
24
32
|
# https://tools.ietf.org/html/rfc5988#section-5
|
25
33
|
#
|
@@ -29,10 +37,6 @@ module Ur
|
|
29
37
|
|
30
38
|
return links unless link_value
|
31
39
|
|
32
|
-
attr_char = /[a-zA-Z0-9!#\$&+\-.^_`|~]/ # defined in https://tools.ietf.org/html/rfc5987#section-3.2.1
|
33
|
-
ptoken = %r([a-zA-Z0-9!#\$%&'()*+\-./:<=>?@\[\]^_`{|}~])
|
34
|
-
quoted_string = /"([^"]*)"/
|
35
|
-
|
36
40
|
ss = StringScanner.new(link_value)
|
37
41
|
parse_fail = proc do
|
38
42
|
raise ParseError, "Unable to parse link value: #{link_value} " +
|
@@ -44,9 +48,7 @@ module Ur
|
|
44
48
|
ss.scan(/\s*<([^>]+)>/) || parse_fail.call
|
45
49
|
target_uri = ss[1]
|
46
50
|
attributes = {}
|
47
|
-
|
48
|
-
# string or series of unquoted ptokens
|
49
|
-
while ss.scan(/\s*;\s*(#{attr_char.source}+\*?)\s*=\s*(?:#{quoted_string.source}|(#{ptoken.source}+))\s*/)
|
51
|
+
while ss.scan(ATTRIBUTE_PAIR)
|
50
52
|
attributes[ss[1]] = ss[2] || ss[3]
|
51
53
|
end
|
52
54
|
links << new(target_uri, attributes, context_uri)
|
data/lib/ur.rb
CHANGED
@@ -31,16 +31,16 @@ module Ur
|
|
31
31
|
autoload :ContentType, 'ur/content_type'
|
32
32
|
|
33
33
|
class << self
|
34
|
-
def new(instance = {}, schemas: Set[], **options)
|
34
|
+
def new(instance = {}, schemas: Set[], mutable: true, **options)
|
35
35
|
unless instance.respond_to?(:to_hash)
|
36
|
-
raise(TypeError, "
|
36
|
+
raise(TypeError, "Epected Ur instance content to be a Hash. Got: #{instance.pretty_inspect.chomp}")
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
instance = instance.merge({'request' => {}}) if !instance['request']
|
40
|
+
instance = instance.merge({'response' => {}}) if !instance['response']
|
41
|
+
instance = instance.merge({'metadata' => {}}) if !instance['metadata']
|
42
|
+
|
43
|
+
JSI::SchemaSet[schema, *schemas].new_jsi(instance, mutable: mutable, **options)
|
44
44
|
end
|
45
45
|
|
46
46
|
def from_rack_request(request_env, **options)
|
@@ -76,9 +76,11 @@ module Ur
|
|
76
76
|
end
|
77
77
|
end.compact.inject({}, &:update)
|
78
78
|
|
79
|
-
env["rack.input"]
|
80
|
-
|
81
|
-
|
79
|
+
if env["rack.input"]
|
80
|
+
env["rack.input"].rewind
|
81
|
+
ur.request.body = env["rack.input"].read
|
82
|
+
env["rack.input"].rewind
|
83
|
+
end
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
data/ur.gemspec
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ur
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsi
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.8.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.8.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: addressable
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|