ur 0.1.0 → 0.1.1
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 +3 -0
- data/LICENSE.md +169 -0
- data/README.md +5 -3
- data/lib/ur.rb +8 -8
- data/lib/ur/content_type.rb +2 -0
- data/lib/ur/faraday.rb +2 -0
- data/lib/ur/faraday/yield_ur.rb +6 -2
- data/lib/ur/metadata.rb +5 -0
- data/lib/ur/middleware.rb +15 -2
- data/lib/ur/request.rb +2 -0
- data/lib/ur/request_and_response.rb +10 -1
- data/lib/ur/response.rb +2 -0
- data/lib/ur/sub_ur.rb +2 -0
- data/lib/ur/version.rb +1 -1
- data/resources/icons/LGPL-3.0.png +0 -0
- data/resources/ur.schema.yml +8 -3
- data/test/ur_rack_test.rb +0 -4
- data/test/ur_test.rb +2 -2
- data/ur.gemspec +7 -16
- metadata +23 -17
- data/LICENSE.txt +0 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 20d9f65430cb5e9571314e578ec2c6ec838e694eef3970d02005e4f1589db0d0
|
|
4
|
+
data.tar.gz: e3bcf5550424177a7036ca7eafe91d32ed73c4b7a2c855dfbabd36d7606bebbd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fbd253924bb53b4f78a368c97b51ec643694faa7770b5b1d1931791deb14f5d5bdbedff7d19197f478da540105c52ebea6b4eb3397cfa799c50f13c985b980a7
|
|
7
|
+
data.tar.gz: e5a7adeeefbb79feeb23cde88fe441ba6bab2520dd37485ad456d2f62c66d5e7eb0638d6b9da7156eaf28a0344a822dce9dd5bdfec11059e0c7ba8d13883fcc8
|
data/CHANGELOG.md
CHANGED
data/LICENSE.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Copright © [Ethan](https://github.com/notEthan/)
|
|
2
|
+
|
|
3
|
+
[<img align="right" src="https://github.com/notEthan/ur/raw/master/resources/icons/LGPL-3.0.png">](https://www.gnu.org/licenses/lgpl-3.0.html)
|
|
4
|
+
|
|
5
|
+
Ur is Open Source Software licensed under the terms of the [GNU Affero General Public License version 3](https://www.gnu.org/licenses/lgpl-3.0.html).
|
|
6
|
+
|
|
7
|
+
GNU Lesser General Public License
|
|
8
|
+
=================================
|
|
9
|
+
|
|
10
|
+
_Version 3, 29 June 2007_
|
|
11
|
+
_Copyright © 2007 Free Software Foundation, Inc. <<https://fsf.org/>>_
|
|
12
|
+
|
|
13
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
14
|
+
of this license document, but changing it is not allowed.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
This version of the GNU Lesser General Public License incorporates
|
|
18
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
19
|
+
License, supplemented by the additional permissions listed below.
|
|
20
|
+
|
|
21
|
+
### 0. Additional Definitions
|
|
22
|
+
|
|
23
|
+
As used herein, “this License” refers to version 3 of the GNU Lesser
|
|
24
|
+
General Public License, and the “GNU GPL” refers to version 3 of the GNU
|
|
25
|
+
General Public License.
|
|
26
|
+
|
|
27
|
+
“The Library” refers to a covered work governed by this License,
|
|
28
|
+
other than an Application or a Combined Work as defined below.
|
|
29
|
+
|
|
30
|
+
An “Application” is any work that makes use of an interface provided
|
|
31
|
+
by the Library, but which is not otherwise based on the Library.
|
|
32
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
33
|
+
of using an interface provided by the Library.
|
|
34
|
+
|
|
35
|
+
A “Combined Work” is a work produced by combining or linking an
|
|
36
|
+
Application with the Library. The particular version of the Library
|
|
37
|
+
with which the Combined Work was made is also called the “Linked
|
|
38
|
+
Version”.
|
|
39
|
+
|
|
40
|
+
The “Minimal Corresponding Source” for a Combined Work means the
|
|
41
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
42
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
43
|
+
based on the Application, and not on the Linked Version.
|
|
44
|
+
|
|
45
|
+
The “Corresponding Application Code” for a Combined Work means the
|
|
46
|
+
object code and/or source code for the Application, including any data
|
|
47
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
48
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
49
|
+
|
|
50
|
+
### 1. Exception to Section 3 of the GNU GPL
|
|
51
|
+
|
|
52
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
53
|
+
without being bound by section 3 of the GNU GPL.
|
|
54
|
+
|
|
55
|
+
### 2. Conveying Modified Versions
|
|
56
|
+
|
|
57
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
58
|
+
facility refers to a function or data to be supplied by an Application
|
|
59
|
+
that uses the facility (other than as an argument passed when the
|
|
60
|
+
facility is invoked), then you may convey a copy of the modified
|
|
61
|
+
version:
|
|
62
|
+
|
|
63
|
+
* **a)** under this License, provided that you make a good faith effort to
|
|
64
|
+
ensure that, in the event an Application does not supply the
|
|
65
|
+
function or data, the facility still operates, and performs
|
|
66
|
+
whatever part of its purpose remains meaningful, or
|
|
67
|
+
|
|
68
|
+
* **b)** under the GNU GPL, with none of the additional permissions of
|
|
69
|
+
this License applicable to that copy.
|
|
70
|
+
|
|
71
|
+
### 3. Object Code Incorporating Material from Library Header Files
|
|
72
|
+
|
|
73
|
+
The object code form of an Application may incorporate material from
|
|
74
|
+
a header file that is part of the Library. You may convey such object
|
|
75
|
+
code under terms of your choice, provided that, if the incorporated
|
|
76
|
+
material is not limited to numerical parameters, data structure
|
|
77
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
78
|
+
(ten or fewer lines in length), you do both of the following:
|
|
79
|
+
|
|
80
|
+
* **a)** Give prominent notice with each copy of the object code that the
|
|
81
|
+
Library is used in it and that the Library and its use are
|
|
82
|
+
covered by this License.
|
|
83
|
+
* **b)** Accompany the object code with a copy of the GNU GPL and this license
|
|
84
|
+
document.
|
|
85
|
+
|
|
86
|
+
### 4. Combined Works
|
|
87
|
+
|
|
88
|
+
You may convey a Combined Work under terms of your choice that,
|
|
89
|
+
taken together, effectively do not restrict modification of the
|
|
90
|
+
portions of the Library contained in the Combined Work and reverse
|
|
91
|
+
engineering for debugging such modifications, if you also do each of
|
|
92
|
+
the following:
|
|
93
|
+
|
|
94
|
+
* **a)** Give prominent notice with each copy of the Combined Work that
|
|
95
|
+
the Library is used in it and that the Library and its use are
|
|
96
|
+
covered by this License.
|
|
97
|
+
|
|
98
|
+
* **b)** Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
99
|
+
document.
|
|
100
|
+
|
|
101
|
+
* **c)** For a Combined Work that displays copyright notices during
|
|
102
|
+
execution, include the copyright notice for the Library among
|
|
103
|
+
these notices, as well as a reference directing the user to the
|
|
104
|
+
copies of the GNU GPL and this license document.
|
|
105
|
+
|
|
106
|
+
* **d)** Do one of the following:
|
|
107
|
+
- **0)** Convey the Minimal Corresponding Source under the terms of this
|
|
108
|
+
License, and the Corresponding Application Code in a form
|
|
109
|
+
suitable for, and under terms that permit, the user to
|
|
110
|
+
recombine or relink the Application with a modified version of
|
|
111
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
112
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
113
|
+
Corresponding Source.
|
|
114
|
+
- **1)** Use a suitable shared library mechanism for linking with the
|
|
115
|
+
Library. A suitable mechanism is one that **(a)** uses at run time
|
|
116
|
+
a copy of the Library already present on the user's computer
|
|
117
|
+
system, and **(b)** will operate properly with a modified version
|
|
118
|
+
of the Library that is interface-compatible with the Linked
|
|
119
|
+
Version.
|
|
120
|
+
|
|
121
|
+
* **e)** Provide Installation Information, but only if you would otherwise
|
|
122
|
+
be required to provide such information under section 6 of the
|
|
123
|
+
GNU GPL, and only to the extent that such information is
|
|
124
|
+
necessary to install and execute a modified version of the
|
|
125
|
+
Combined Work produced by recombining or relinking the
|
|
126
|
+
Application with a modified version of the Linked Version. (If
|
|
127
|
+
you use option **4d0**, the Installation Information must accompany
|
|
128
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
129
|
+
Code. If you use option **4d1**, you must provide the Installation
|
|
130
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
131
|
+
for conveying Corresponding Source.)
|
|
132
|
+
|
|
133
|
+
### 5. Combined Libraries
|
|
134
|
+
|
|
135
|
+
You may place library facilities that are a work based on the
|
|
136
|
+
Library side by side in a single library together with other library
|
|
137
|
+
facilities that are not Applications and are not covered by this
|
|
138
|
+
License, and convey such a combined library under terms of your
|
|
139
|
+
choice, if you do both of the following:
|
|
140
|
+
|
|
141
|
+
* **a)** Accompany the combined library with a copy of the same work based
|
|
142
|
+
on the Library, uncombined with any other library facilities,
|
|
143
|
+
conveyed under the terms of this License.
|
|
144
|
+
* **b)** Give prominent notice with the combined library that part of it
|
|
145
|
+
is a work based on the Library, and explaining where to find the
|
|
146
|
+
accompanying uncombined form of the same work.
|
|
147
|
+
|
|
148
|
+
### 6. Revised Versions of the GNU Lesser General Public License
|
|
149
|
+
|
|
150
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
151
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
152
|
+
versions will be similar in spirit to the present version, but may
|
|
153
|
+
differ in detail to address new problems or concerns.
|
|
154
|
+
|
|
155
|
+
Each version is given a distinguishing version number. If the
|
|
156
|
+
Library as you received it specifies that a certain numbered version
|
|
157
|
+
of the GNU Lesser General Public License “or any later version”
|
|
158
|
+
applies to it, you have the option of following the terms and
|
|
159
|
+
conditions either of that published version or of any later version
|
|
160
|
+
published by the Free Software Foundation. If the Library as you
|
|
161
|
+
received it does not specify a version number of the GNU Lesser
|
|
162
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
163
|
+
General Public License ever published by the Free Software Foundation.
|
|
164
|
+
|
|
165
|
+
If the Library as you received it specifies that a proxy can decide
|
|
166
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
167
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
168
|
+
permanent authorization for you to choose that version for the
|
|
169
|
+
Library.
|
data/README.md
CHANGED
|
@@ -30,7 +30,7 @@ class MyRackMiddleware
|
|
|
30
30
|
ur = Ur.from_rack_request(env)
|
|
31
31
|
|
|
32
32
|
# set additional properties of the ur, for example:
|
|
33
|
-
ur.
|
|
33
|
+
ur.logger_tags(my_logger)
|
|
34
34
|
|
|
35
35
|
rack_response = ur.with_rack_response(@app, env) do
|
|
36
36
|
# do things after the response
|
|
@@ -50,7 +50,7 @@ class MyFaradayMiddleware < ::Faraday::Middleware
|
|
|
50
50
|
ur = Ur.from_faraday_request(request_env)
|
|
51
51
|
|
|
52
52
|
# set additional properties of the ur, for example:
|
|
53
|
-
ur.
|
|
53
|
+
ur.logger_tags(my_logger)
|
|
54
54
|
|
|
55
55
|
ur.faraday_on_complete(@app, request_env) do |response_env|
|
|
56
56
|
# do things after the response
|
|
@@ -61,4 +61,6 @@ end
|
|
|
61
61
|
|
|
62
62
|
## License
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
[<img align="right" src="https://github.com/notEthan/ur/raw/master/resources/icons/LGPL-3.0.png">](https://www.gnu.org/licenses/lgpl-3.0.html)
|
|
65
|
+
|
|
66
|
+
Ur is Open Source Software licensed under the terms of the [GNU Lesser General Public License version 3](https://www.gnu.org/licenses/lgpl-3.0.html).
|
data/lib/ur.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "ur/version"
|
|
2
4
|
|
|
3
5
|
require 'jsi'
|
|
@@ -37,8 +39,6 @@ class Ur
|
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
new({'bound' => 'inbound'}).tap do |ur|
|
|
40
|
-
ur.metadata.begin!
|
|
41
|
-
|
|
42
42
|
ur.request['method'] = rack_request.request_method
|
|
43
43
|
|
|
44
44
|
ur.request.addressable_uri = Addressable::URI.new(
|
|
@@ -68,9 +68,8 @@ class Ur
|
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
def from_faraday_request(request_env
|
|
71
|
+
def from_faraday_request(request_env)
|
|
72
72
|
new({'bound' => 'outbound'}).tap do |ur|
|
|
73
|
-
ur.metadata.begin!
|
|
74
73
|
ur.request['method'] = request_env[:method].to_s
|
|
75
74
|
ur.request.uri = request_env[:url].normalize.to_s
|
|
76
75
|
ur.request.headers = request_env[:request_headers]
|
|
@@ -89,7 +88,11 @@ class Ur
|
|
|
89
88
|
self.metadata = {} if self.metadata.nil?
|
|
90
89
|
end
|
|
91
90
|
|
|
92
|
-
|
|
91
|
+
# Ur#logger_tags applies tags from a tagged logger to this ur's metadata.
|
|
92
|
+
# note: ur does not log anything and this logger is not stored.
|
|
93
|
+
# @param [logger] a tagged logger
|
|
94
|
+
# @return [void]
|
|
95
|
+
def logger_tags(logger)
|
|
93
96
|
if logger && logger.formatter.respond_to?(:current_tags)
|
|
94
97
|
metadata.tags = logger.formatter.current_tags.dup
|
|
95
98
|
end
|
|
@@ -103,8 +106,6 @@ class Ur
|
|
|
103
106
|
response.body = response_body.to_enum.to_a.join('')
|
|
104
107
|
|
|
105
108
|
response_body_proxy = ::Rack::BodyProxy.new(response_body) do
|
|
106
|
-
metadata.finish!
|
|
107
|
-
|
|
108
109
|
yield
|
|
109
110
|
end
|
|
110
111
|
[status, response_headers, response_body_proxy]
|
|
@@ -115,7 +116,6 @@ class Ur
|
|
|
115
116
|
response.status = response_env[:status]
|
|
116
117
|
response.headers = response_env[:response_headers]
|
|
117
118
|
response.set_body_from_faraday(response_env)
|
|
118
|
-
metadata.finish!
|
|
119
119
|
|
|
120
120
|
yield(response_env)
|
|
121
121
|
end
|
data/lib/ur/content_type.rb
CHANGED
data/lib/ur/faraday.rb
CHANGED
data/lib/ur/faraday/yield_ur.rb
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Ur
|
|
2
4
|
module Faraday
|
|
3
|
-
|
|
5
|
+
# Faraday middleware which yields an Ur to the given block
|
|
6
|
+
class YieldUr < ::Ur::FaradayMiddleware
|
|
4
7
|
def initialize(app, options = {}, &block)
|
|
5
8
|
raise(ArgumentError, "no block given to yield ur") unless block
|
|
6
9
|
raise(TypeError, "options must be a Hash") unless options.respond_to?(:to_hash)
|
|
@@ -11,8 +14,9 @@ class Ur
|
|
|
11
14
|
|
|
12
15
|
def call(request_env)
|
|
13
16
|
ur = (@options[:ur_class] || Ur).from_faraday_request(request_env)
|
|
14
|
-
ur
|
|
17
|
+
begin_request(ur)
|
|
15
18
|
ur.faraday_on_complete(@app, request_env) do |response_env|
|
|
19
|
+
finish_request(ur)
|
|
16
20
|
@yield_to.call(ur)
|
|
17
21
|
end
|
|
18
22
|
end
|
data/lib/ur/metadata.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'ur' unless Object.const_defined?(:Ur)
|
|
2
4
|
|
|
3
5
|
class Ur
|
|
@@ -13,10 +15,13 @@ class Ur
|
|
|
13
15
|
|
|
14
16
|
attr_accessor :began_at_ns
|
|
15
17
|
|
|
18
|
+
# sets began_at from the current time
|
|
16
19
|
def begin!
|
|
17
20
|
self.began_at ||= Time.now
|
|
18
21
|
self.began_at_ns ||= Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)
|
|
19
22
|
end
|
|
23
|
+
|
|
24
|
+
# sets the duration from the current time and began_at
|
|
20
25
|
def finish!
|
|
21
26
|
return if duration
|
|
22
27
|
if began_at_ns
|
data/lib/ur/middleware.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'ur' unless Object.const_defined?(:Ur)
|
|
2
4
|
|
|
3
5
|
class Ur
|
|
@@ -9,6 +11,15 @@ class Ur
|
|
|
9
11
|
attr_reader :app
|
|
10
12
|
attr_reader :options
|
|
11
13
|
|
|
14
|
+
def begin_request(ur)
|
|
15
|
+
ur.metadata.begin!
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def finish_request(ur)
|
|
19
|
+
ur.logger_tags(@options[:logger])
|
|
20
|
+
ur.metadata.finish!
|
|
21
|
+
end
|
|
22
|
+
|
|
12
23
|
def invoke_callback(name, *a, &b)
|
|
13
24
|
if @options[name]
|
|
14
25
|
@options[name].call(*a, &b)
|
|
@@ -21,8 +32,9 @@ class Ur
|
|
|
21
32
|
def call(request_env)
|
|
22
33
|
ur = Ur.from_faraday_request(request_env)
|
|
23
34
|
invoke_callback(:before_request, ur)
|
|
24
|
-
ur
|
|
35
|
+
begin_request(ur)
|
|
25
36
|
ur.faraday_on_complete(@app, request_env) do |response_env|
|
|
37
|
+
finish_request(ur)
|
|
26
38
|
invoke_callback(:after_response, ur)
|
|
27
39
|
end
|
|
28
40
|
end
|
|
@@ -33,8 +45,9 @@ class Ur
|
|
|
33
45
|
def call(env)
|
|
34
46
|
ur = Ur.from_rack_request(env)
|
|
35
47
|
invoke_callback(:before_request, ur)
|
|
36
|
-
ur
|
|
48
|
+
begin_request(ur)
|
|
37
49
|
ur.with_rack_response(@app, env) do
|
|
50
|
+
finish_request(ur)
|
|
38
51
|
invoke_callback(:after_response, ur)
|
|
39
52
|
end
|
|
40
53
|
end
|
data/lib/ur/request.rb
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'ur' unless Object.const_defined?(:Ur)
|
|
2
4
|
|
|
3
5
|
class Ur
|
|
6
|
+
# functionality common to Request and Response
|
|
4
7
|
module RequestAndResponse
|
|
8
|
+
# functionality for handling request/response entities from Faraday
|
|
5
9
|
module FaradayEntity
|
|
10
|
+
# @param env [Faraday::Env] faraday env passed to middleware #call
|
|
6
11
|
def set_body_from_faraday(env)
|
|
7
12
|
if env[:raw_body].respond_to?(:to_str)
|
|
8
13
|
self.body = env[:raw_body].to_str.dup
|
|
@@ -20,6 +25,9 @@ class Ur
|
|
|
20
25
|
end
|
|
21
26
|
include FaradayEntity
|
|
22
27
|
|
|
28
|
+
# @return [Ur::ContentType] the string value of the content type header. returns an
|
|
29
|
+
# {Ur::ContentType}, a subclass of String which additionally parses the Content-Type
|
|
30
|
+
# according to relevant RFCs.
|
|
23
31
|
def content_type
|
|
24
32
|
headers.each do |k, v|
|
|
25
33
|
return ContentType.new(v) if k =~ /\Acontent[-_]type\z/i
|
|
@@ -27,6 +35,7 @@ class Ur
|
|
|
27
35
|
nil
|
|
28
36
|
end
|
|
29
37
|
|
|
38
|
+
# the media type of the content type
|
|
30
39
|
def media_type
|
|
31
40
|
content_type ? content_type.media_type : nil
|
|
32
41
|
end
|
|
@@ -38,7 +47,7 @@ class Ur
|
|
|
38
47
|
|
|
39
48
|
# @return [Boolean] is our content type XML?
|
|
40
49
|
def xml?
|
|
41
|
-
content_type && content_type.
|
|
50
|
+
content_type && content_type.xml?
|
|
42
51
|
end
|
|
43
52
|
|
|
44
53
|
# @return [Boolean] is our content type x-www-form-urlencoded?
|
data/lib/ur/response.rb
CHANGED
data/lib/ur/sub_ur.rb
CHANGED
data/lib/ur/version.rb
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
UR_VERSION = "0.1.
|
|
1
|
+
UR_VERSION = "0.1.1".freeze
|
|
Binary file
|
data/resources/ur.schema.yml
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
id: https://schemas.ur.unth.net/ur
|
|
1
|
+
$id: https://schemas.ur.unth.net/ur
|
|
2
2
|
type: object
|
|
3
3
|
properties:
|
|
4
4
|
bound:
|
|
5
5
|
type: string
|
|
6
|
-
description: '[
|
|
6
|
+
description: '[RFC7230] The terms "inbound" and "outbound" are used to describe directional requirements in relation to the request route: "inbound" means toward the origin server and "outbound" means toward the user agent.'
|
|
7
7
|
enum:
|
|
8
8
|
- inbound
|
|
9
9
|
- outbound
|
|
@@ -12,7 +12,7 @@ properties:
|
|
|
12
12
|
properties:
|
|
13
13
|
method:
|
|
14
14
|
type: string
|
|
15
|
-
description: '[
|
|
15
|
+
description: '[RFC7230] The method token indicates the request method to be performed on the target resource.'
|
|
16
16
|
example: POST
|
|
17
17
|
uri:
|
|
18
18
|
type: string
|
|
@@ -27,6 +27,10 @@ properties:
|
|
|
27
27
|
properties:
|
|
28
28
|
status:
|
|
29
29
|
type: integer
|
|
30
|
+
description: >
|
|
31
|
+
The status-code element is a 3-digit integer code describing the
|
|
32
|
+
result of the server's attempt to understand and satisfy the client's
|
|
33
|
+
corresponding request.
|
|
30
34
|
example: 200
|
|
31
35
|
headers:
|
|
32
36
|
type: object
|
|
@@ -37,6 +41,7 @@ properties:
|
|
|
37
41
|
properties:
|
|
38
42
|
began_at_s:
|
|
39
43
|
type: string
|
|
44
|
+
format: date-time
|
|
40
45
|
duration:
|
|
41
46
|
type: number
|
|
42
47
|
tags:
|
data/test/ur_rack_test.rb
CHANGED
|
@@ -10,8 +10,6 @@ describe 'Ur rack integration' do
|
|
|
10
10
|
assert_equal('bar', ur.request.headers['foo'])
|
|
11
11
|
assert_equal('https://ur.unth.net/', ur.request.uri)
|
|
12
12
|
assert(ur.response.empty?)
|
|
13
|
-
assert_instance_of(Time, ur.metadata.began_at)
|
|
14
|
-
assert_nil(ur.metadata.duration)
|
|
15
13
|
assert(ur.validate)
|
|
16
14
|
end
|
|
17
15
|
it 'builds from a rack request' do
|
|
@@ -22,8 +20,6 @@ describe 'Ur rack integration' do
|
|
|
22
20
|
assert_equal('bar', ur.request.headers['foo'])
|
|
23
21
|
assert_equal('https://ur.unth.net/', ur.request.uri)
|
|
24
22
|
assert(ur.response.empty?)
|
|
25
|
-
assert_instance_of(Time, ur.metadata.began_at)
|
|
26
|
-
assert_nil(ur.metadata.duration)
|
|
27
23
|
assert(ur.validate)
|
|
28
24
|
end
|
|
29
25
|
end
|
data/test/ur_test.rb
CHANGED
|
@@ -37,7 +37,7 @@ describe 'Ur' do
|
|
|
37
37
|
assert_equal('bar', ur.request.headers['foo'])
|
|
38
38
|
assert_equal('https://ur.unth.net/', ur.request.uri)
|
|
39
39
|
assert(ur.response.empty?)
|
|
40
|
-
|
|
40
|
+
assert_nil(ur.metadata.began_at)
|
|
41
41
|
assert_nil(ur.metadata.duration)
|
|
42
42
|
assert(ur.validate)
|
|
43
43
|
end,
|
|
@@ -71,7 +71,7 @@ describe 'Ur' do
|
|
|
71
71
|
assert_equal('https://ur.unth.net/', ur.request.uri)
|
|
72
72
|
assert_equal(Addressable::URI.parse('https://ur.unth.net/'), ur.request.addressable_uri)
|
|
73
73
|
assert(ur.response.empty?)
|
|
74
|
-
|
|
74
|
+
assert_nil(ur.metadata.began_at)
|
|
75
75
|
assert_nil(ur.metadata.duration)
|
|
76
76
|
assert(ur.validate)
|
|
77
77
|
end,
|
data/ur.gemspec
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
lib = File.expand_path("../lib", __FILE__)
|
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
3
|
require "ur/version"
|
|
@@ -12,31 +11,23 @@ Gem::Specification.new do |spec|
|
|
|
12
11
|
spec.summary = 'ur: unified request representation'
|
|
13
12
|
spec.description = 'ur provides a unified representation of a request and response. it can be interpreted from rack, faraday, or potentially other sources, and provides a consistent interface to access the attributes inherent to the request and additional useful parsers and computation from the request.'
|
|
14
13
|
spec.homepage = "https://github.com/notEthan/ur"
|
|
15
|
-
spec.license = "
|
|
14
|
+
spec.license = "LGPL-3.0"
|
|
16
15
|
|
|
17
|
-
ignore_files
|
|
16
|
+
ignore_files = %w(.gitignore .travis.yml Gemfile test)
|
|
18
17
|
ignore_files_re = %r{\A(#{ignore_files.map { |f| Regexp.escape(f) }.join('|')})(/|\z)}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
22
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(ignore_files_re) }
|
|
23
|
-
spec.test_files = `git ls-files -z test`.split("\x0") + [
|
|
24
|
-
'.simplecov',
|
|
25
|
-
]
|
|
26
|
-
end
|
|
27
|
-
spec.bindir = "exe"
|
|
28
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(ignore_files_re) }
|
|
19
|
+
spec.test_files = `git ls-files -z test`.split("\x0") + ['.simplecov']
|
|
29
20
|
spec.require_paths = ["lib"]
|
|
30
21
|
|
|
31
|
-
spec.add_dependency "jsi", "
|
|
22
|
+
spec.add_dependency "jsi", ">= 0.2.0", "< 0.4.0"
|
|
32
23
|
spec.add_dependency "addressable", "~> 2.0"
|
|
33
24
|
spec.add_development_dependency "rack"
|
|
34
25
|
spec.add_development_dependency "rack-test"
|
|
35
26
|
spec.add_development_dependency "faraday"
|
|
36
27
|
spec.add_development_dependency "faraday_middleware"
|
|
37
28
|
spec.add_development_dependency "activesupport"
|
|
38
|
-
spec.add_development_dependency "rake"
|
|
39
|
-
spec.add_development_dependency "minitest"
|
|
29
|
+
spec.add_development_dependency "rake"
|
|
30
|
+
spec.add_development_dependency "minitest"
|
|
40
31
|
spec.add_development_dependency "minitest-reporters"
|
|
41
32
|
spec.add_development_dependency "simplecov"
|
|
42
33
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ur
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ethan
|
|
8
8
|
autorequire:
|
|
9
|
-
bindir:
|
|
9
|
+
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-02-09 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
19
|
version: 0.2.0
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 0.4.0
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
|
-
- - "
|
|
27
|
+
- - ">="
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
29
|
version: 0.2.0
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 0.4.0
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: addressable
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -112,30 +118,30 @@ dependencies:
|
|
|
112
118
|
name: rake
|
|
113
119
|
requirement: !ruby/object:Gem::Requirement
|
|
114
120
|
requirements:
|
|
115
|
-
- - "
|
|
121
|
+
- - ">="
|
|
116
122
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: '
|
|
123
|
+
version: '0'
|
|
118
124
|
type: :development
|
|
119
125
|
prerelease: false
|
|
120
126
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
127
|
requirements:
|
|
122
|
-
- - "
|
|
128
|
+
- - ">="
|
|
123
129
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: '
|
|
130
|
+
version: '0'
|
|
125
131
|
- !ruby/object:Gem::Dependency
|
|
126
132
|
name: minitest
|
|
127
133
|
requirement: !ruby/object:Gem::Requirement
|
|
128
134
|
requirements:
|
|
129
|
-
- - "
|
|
135
|
+
- - ">="
|
|
130
136
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: '
|
|
137
|
+
version: '0'
|
|
132
138
|
type: :development
|
|
133
139
|
prerelease: false
|
|
134
140
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
141
|
requirements:
|
|
136
|
-
- - "
|
|
142
|
+
- - ">="
|
|
137
143
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: '
|
|
144
|
+
version: '0'
|
|
139
145
|
- !ruby/object:Gem::Dependency
|
|
140
146
|
name: minitest-reporters
|
|
141
147
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -177,7 +183,7 @@ files:
|
|
|
177
183
|
- ".simplecov"
|
|
178
184
|
- ".yardopts"
|
|
179
185
|
- CHANGELOG.md
|
|
180
|
-
- LICENSE.
|
|
186
|
+
- LICENSE.md
|
|
181
187
|
- README.md
|
|
182
188
|
- Rakefile.rb
|
|
183
189
|
- lib/ur.rb
|
|
@@ -191,6 +197,7 @@ files:
|
|
|
191
197
|
- lib/ur/response.rb
|
|
192
198
|
- lib/ur/sub_ur.rb
|
|
193
199
|
- lib/ur/version.rb
|
|
200
|
+
- resources/icons/LGPL-3.0.png
|
|
194
201
|
- resources/ur.schema.yml
|
|
195
202
|
- test/content_type_test.rb
|
|
196
203
|
- test/test_helper.rb
|
|
@@ -201,7 +208,7 @@ files:
|
|
|
201
208
|
- ur.gemspec
|
|
202
209
|
homepage: https://github.com/notEthan/ur
|
|
203
210
|
licenses:
|
|
204
|
-
-
|
|
211
|
+
- LGPL-3.0
|
|
205
212
|
metadata: {}
|
|
206
213
|
post_install_message:
|
|
207
214
|
rdoc_options: []
|
|
@@ -218,8 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
218
225
|
- !ruby/object:Gem::Version
|
|
219
226
|
version: '0'
|
|
220
227
|
requirements: []
|
|
221
|
-
|
|
222
|
-
rubygems_version: 2.7.8
|
|
228
|
+
rubygems_version: 3.0.6
|
|
223
229
|
signing_key:
|
|
224
230
|
specification_version: 4
|
|
225
231
|
summary: 'ur: unified request representation'
|
data/LICENSE.txt
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Ethan
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|