linzer 0.7.6 → 0.7.7
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/CHANGELOG.md +15 -0
- data/LICENSE.txt +1 -1
- data/lib/linzer/message/adapter/abstract.rb +0 -2
- data/lib/linzer/message/adapter/generic/request.rb +58 -0
- data/lib/linzer/message/adapter/generic/response.rb +41 -0
- data/lib/linzer/message/adapter/http_gem/request.rb +1 -5
- data/lib/linzer/message/adapter/http_gem/response.rb +4 -3
- data/lib/linzer/message/adapter/net_http/request.rb +3 -42
- data/lib/linzer/message/adapter/net_http/response.rb +1 -26
- data/lib/linzer/message/adapter.rb +2 -0
- data/lib/linzer/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcae916cefddaddfc6fd6b58ab110eceda2225e5b525c984fa20eba378d80262
|
4
|
+
data.tar.gz: 896938aeafbca006f944a950bd0151df60f960ee7541ee98fe6aff2ffee9754f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89b1873e0664d7048142c9a16fd5414f3f568eeb01a3396d194398efa59e9e1bd40596096a433be17fa6635be9850cb641cd48b79d8ac99efe21d128c822337f
|
7
|
+
data.tar.gz: 61a79c4ef12ae7fbf74da3c0d99786caaa010255d099bb7c73319308a86895a4b5d531254f4bd3a7f78fb15aec1cc96f01bb02f83fa45313bae0c8910ca45b1b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.7.7] - 2025-07-08
|
4
|
+
|
5
|
+
(No changes since the last beta release, this new stable release just
|
6
|
+
bundles all the features/changes introduced during 0.7.7.beta1 release)
|
7
|
+
|
8
|
+
- Introduce generic adapters for typical requests and responses.
|
9
|
+
This allows adapter classes to stop inheriting functionality from totally
|
10
|
+
unrelated implementations by relying on a saner hierarchy class.
|
11
|
+
|
12
|
+
## [0.7.7.beta1] - 2025-07-07
|
13
|
+
|
14
|
+
- Introduce generic adapters for typical requests and responses.
|
15
|
+
This allows adapter classes to stop inheriting functionality from totally
|
16
|
+
unrelated implementations by relying on a saner hierarchy class.
|
17
|
+
|
3
18
|
## [0.7.6] - 2025-07-03
|
4
19
|
|
5
20
|
- Fix a bug in the `Linzer::Message::Adapter::HTTPGem::Response` class where
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2024 Miguel Landaeta <miguel@miguel.cc>
|
3
|
+
Copyright (c) 2024-2025 Miguel Landaeta <miguel@miguel.cc>
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cgi"
|
4
|
+
|
5
|
+
module Linzer
|
6
|
+
class Message
|
7
|
+
module Adapter
|
8
|
+
module Generic
|
9
|
+
class Request < Abstract
|
10
|
+
def initialize(operation, **options)
|
11
|
+
@operation = operation
|
12
|
+
freeze
|
13
|
+
end
|
14
|
+
|
15
|
+
def header(name)
|
16
|
+
@operation[name]
|
17
|
+
end
|
18
|
+
|
19
|
+
def attach!(signature)
|
20
|
+
signature.to_h.each { |h, v| @operation[h] = v }
|
21
|
+
@operation
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def derived(name)
|
27
|
+
unimplemented_method = 'Derived field "@method" lookup is not implemented!'
|
28
|
+
case name.value
|
29
|
+
when "@method" then raise Error, unimplemented_method
|
30
|
+
when "@target-uri" then @operation.uri.to_s
|
31
|
+
when "@authority" then @operation.uri.authority.downcase
|
32
|
+
when "@scheme" then @operation.uri.scheme.downcase
|
33
|
+
when "@request-target" then @operation.uri.request_uri
|
34
|
+
when "@path" then @operation.uri.path
|
35
|
+
when "@query" then "?%s" % String(@operation.uri.query)
|
36
|
+
when "@query-param" then query_param(name)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def query_param(name)
|
41
|
+
param_name = name.parameters["name"]
|
42
|
+
return nil if !param_name
|
43
|
+
decoded_param_name = URI.decode_uri_component(param_name)
|
44
|
+
params = CGI.parse(@operation.uri.query)
|
45
|
+
URI.encode_uri_component(params[decoded_param_name]&.first)
|
46
|
+
end
|
47
|
+
|
48
|
+
def field(name)
|
49
|
+
has_tr = name.parameters["tr"]
|
50
|
+
return nil if has_tr # HTTP requests don't have trailer fields
|
51
|
+
value = @operation[name.value.to_s]
|
52
|
+
value.dup&.strip
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Linzer
|
4
|
+
class Message
|
5
|
+
module Adapter
|
6
|
+
module Generic
|
7
|
+
class Response < Abstract
|
8
|
+
def initialize(operation, **options)
|
9
|
+
@operation = operation
|
10
|
+
attached_request = options[:attached_request]
|
11
|
+
@attached_request = attached_request ? Message.new(attached_request) : nil
|
12
|
+
validate_attached_request @attached_request if @attached_request
|
13
|
+
freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
def header(name)
|
17
|
+
@operation[name]
|
18
|
+
end
|
19
|
+
|
20
|
+
def attach!(signature)
|
21
|
+
signature.to_h.each { |h, v| @operation[h] = v }
|
22
|
+
@operation
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def derived(name)
|
28
|
+
raise Linzer::Error, "Sub-classes are required to implement this method!"
|
29
|
+
end
|
30
|
+
|
31
|
+
def field(name)
|
32
|
+
has_tr = name.parameters["tr"]
|
33
|
+
return nil if has_tr # is there a library actually supporting trailers?
|
34
|
+
value = @operation[name.value.to_s]
|
35
|
+
value.dup&.strip
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,14 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# HTTP message adapter for HTTP::Response class from http ruby gem.
|
4
4
|
# https://github.com/httprb/http
|
5
|
-
#
|
5
|
+
#
|
6
|
+
# It's not loaded automatically to avoid making http gem a dependency.
|
6
7
|
#
|
7
8
|
module Linzer
|
8
9
|
class Message
|
9
10
|
module Adapter
|
10
11
|
module HTTPGem
|
11
|
-
class Response <
|
12
|
+
class Response < Generic::Response
|
12
13
|
private
|
13
14
|
|
14
15
|
def derived(name)
|
@@ -1,54 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "cgi"
|
4
|
-
|
5
3
|
module Linzer
|
6
4
|
class Message
|
7
5
|
module Adapter
|
8
6
|
module NetHTTP
|
9
|
-
class Request <
|
10
|
-
def initialize(operation, **options)
|
11
|
-
@operation = operation
|
12
|
-
freeze
|
13
|
-
end
|
14
|
-
|
15
|
-
def header(name)
|
16
|
-
@operation[name]
|
17
|
-
end
|
18
|
-
|
19
|
-
def attach!(signature)
|
20
|
-
signature.to_h.each { |h, v| @operation[h] = v }
|
21
|
-
@operation
|
22
|
-
end
|
23
|
-
|
7
|
+
class Request < Generic::Request
|
24
8
|
private
|
25
9
|
|
26
10
|
def derived(name)
|
27
|
-
|
28
|
-
|
29
|
-
when "@target-uri" then @operation.uri.to_s
|
30
|
-
when "@authority" then @operation.uri.authority.downcase
|
31
|
-
when "@scheme" then @operation.uri.scheme.downcase
|
32
|
-
when "@request-target" then @operation.uri.request_uri
|
33
|
-
when "@path" then @operation.uri.path
|
34
|
-
when "@query" then "?%s" % String(@operation.uri.query)
|
35
|
-
when "@query-param" then query_param(name)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def query_param(name)
|
40
|
-
param_name = name.parameters["name"]
|
41
|
-
return nil if !param_name
|
42
|
-
decoded_param_name = URI.decode_uri_component(param_name)
|
43
|
-
params = CGI.parse(@operation.uri.query)
|
44
|
-
URI.encode_uri_component(params[decoded_param_name]&.first)
|
45
|
-
end
|
46
|
-
|
47
|
-
def field(name)
|
48
|
-
has_tr = name.parameters["tr"]
|
49
|
-
return nil if has_tr # HTTP requests don't have trailer fields
|
50
|
-
value = @operation[name.value.to_s]
|
51
|
-
value.dup&.strip
|
11
|
+
return @operation.method if name.value == "@method"
|
12
|
+
super
|
52
13
|
end
|
53
14
|
end
|
54
15
|
end
|
@@ -4,24 +4,7 @@ module Linzer
|
|
4
4
|
class Message
|
5
5
|
module Adapter
|
6
6
|
module NetHTTP
|
7
|
-
class Response <
|
8
|
-
def initialize(operation, **options)
|
9
|
-
@operation = operation
|
10
|
-
attached_request = options[:attached_request]
|
11
|
-
@attached_request = attached_request ? Message.new(attached_request) : nil
|
12
|
-
validate_attached_request @attached_request if @attached_request
|
13
|
-
freeze
|
14
|
-
end
|
15
|
-
|
16
|
-
def header(name)
|
17
|
-
@operation[name]
|
18
|
-
end
|
19
|
-
|
20
|
-
def attach!(signature)
|
21
|
-
signature.to_h.each { |h, v| @operation[h] = v }
|
22
|
-
@operation
|
23
|
-
end
|
24
|
-
|
7
|
+
class Response < Generic::Response
|
25
8
|
private
|
26
9
|
|
27
10
|
def derived(name)
|
@@ -29,14 +12,6 @@ module Linzer
|
|
29
12
|
when "@status" then @operation.code.to_i
|
30
13
|
end
|
31
14
|
end
|
32
|
-
|
33
|
-
# XXX: this implementation is incomplete, e.g.: ;bs parameter is not supported yet
|
34
|
-
def field(name)
|
35
|
-
has_tr = name.parameters["tr"]
|
36
|
-
return nil if has_tr # Net::HTTP doesn't support trailers
|
37
|
-
value = @operation[name.value.to_s]
|
38
|
-
value.dup&.strip
|
39
|
-
end
|
40
15
|
end
|
41
16
|
end
|
42
17
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "adapter/abstract"
|
4
|
+
require_relative "adapter/generic/request"
|
5
|
+
require_relative "adapter/generic/response"
|
4
6
|
require_relative "adapter/rack/common"
|
5
7
|
require_relative "adapter/rack/request"
|
6
8
|
require_relative "adapter/rack/response"
|
data/lib/linzer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Landaeta
|
@@ -203,6 +203,8 @@ files:
|
|
203
203
|
- lib/linzer/message.rb
|
204
204
|
- lib/linzer/message/adapter.rb
|
205
205
|
- lib/linzer/message/adapter/abstract.rb
|
206
|
+
- lib/linzer/message/adapter/generic/request.rb
|
207
|
+
- lib/linzer/message/adapter/generic/response.rb
|
206
208
|
- lib/linzer/message/adapter/http_gem/request.rb
|
207
209
|
- lib/linzer/message/adapter/http_gem/response.rb
|
208
210
|
- lib/linzer/message/adapter/net_http/request.rb
|