restify 2.0.1 → 2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/restify/relation.rb +6 -2
- data/lib/restify/version.rb +1 -1
- data/spec/restify/relation_spec.rb +54 -1
- data/vendor/bundle/ruby/3.4.0/bundler/gems/my-rubocop-3bcd2110ca87/LICENSE +21 -0
- data/vendor/bundle/ruby/3.4.0/bundler/gems/my-rubocop-3bcd2110ca87/README.md +23 -0
- data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.2/CHANGELOG.md +255 -0
- data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.2/MIT-LICENSE +20 -0
- data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.2/README.rdoc +40 -0
- data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/CHANGELOG.md +301 -0
- data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/LICENSE.txt +202 -0
- data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/README.md +121 -0
- data/vendor/bundle/ruby/3.4.0/gems/base64-0.2.0/LICENSE.txt +22 -0
- data/vendor/bundle/ruby/3.4.0/gems/base64-0.2.0/README.md +48 -0
- data/vendor/bundle/ruby/3.4.0/gems/benchmark-0.4.0/README.md +138 -0
- data/vendor/bundle/ruby/3.4.0/gems/bigdecimal-3.1.9/LICENSE +56 -0
- data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/CHANGELOG.md +603 -0
- data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/LICENSE.txt +21 -0
- data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/README.md +407 -0
- data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.3/LICENSE +20 -0
- data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.3/README.md +167 -0
- data/vendor/bundle/ruby/3.4.0/gems/drb-2.2.1/LICENSE.txt +22 -0
- data/vendor/bundle/ruby/3.4.0/gems/ethon-0.16.0/CHANGELOG.md +375 -0
- data/vendor/bundle/ruby/3.4.0/gems/ethon-0.16.0/LICENSE +20 -0
- data/vendor/bundle/ruby/3.4.0/gems/ethon-0.16.0/README.md +118 -0
- data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.2-x86_64-linux-gnu/CHANGELOG.md +473 -0
- data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.2-x86_64-linux-gnu/LICENSE +24 -0
- data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.2-x86_64-linux-gnu/LICENSE.SPECS +22 -0
- data/vendor/bundle/ruby/3.4.0/gems/ffi-1.17.2-x86_64-linux-gnu/README.md +137 -0
- data/vendor/bundle/ruby/3.4.0/gems/hitimes-3.1.0/LICENSE.txt +16 -0
- data/vendor/bundle/ruby/3.4.0/gems/hitimes-3.1.0/README.md +187 -0
- data/vendor/bundle/ruby/3.4.0/gems/i18n-1.14.7/MIT-LICENSE +20 -0
- data/vendor/bundle/ruby/3.4.0/gems/i18n-1.14.7/README.md +127 -0
- data/vendor/bundle/ruby/3.4.0/gems/little-plugger-1.1.4/README.rdoc +53 -0
- data/vendor/bundle/ruby/3.4.0/gems/logger-1.7.0/README.md +104 -0
- data/vendor/bundle/ruby/3.4.0/gems/logging-2.4.0/LICENSE +22 -0
- data/vendor/bundle/ruby/3.4.0/gems/logging-2.4.0/README.md +140 -0
- data/vendor/bundle/ruby/3.4.0/gems/minitest-5.25.5/README.rdoc +842 -0
- data/vendor/bundle/ruby/3.4.0/gems/msgpack-1.8.0/ChangeLog +368 -0
- data/vendor/bundle/ruby/3.4.0/gems/msgpack-1.8.0/LICENSE +177 -0
- data/vendor/bundle/ruby/3.4.0/gems/msgpack-1.8.0/README.md +302 -0
- data/vendor/bundle/ruby/3.4.0/gems/multi_json-1.15.0/CHANGELOG.md +275 -0
- data/vendor/bundle/ruby/3.4.0/gems/multi_json-1.15.0/LICENSE.md +20 -0
- data/vendor/bundle/ruby/3.4.0/gems/multi_json-1.15.0/README.md +121 -0
- data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-api-1.5.0/CHANGELOG.md +193 -0
- data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-api-1.5.0/LICENSE +201 -0
- data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-api-1.5.0/README.md +68 -0
- data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-common-0.22.0/CHANGELOG.md +98 -0
- data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-common-0.22.0/LICENSE +201 -0
- data/vendor/bundle/ruby/3.4.0/gems/opentelemetry-common-0.22.0/README.md +62 -0
- data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.2/CHANGELOG.md +498 -0
- data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.2/LICENSE.txt +22 -0
- data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.2/README.md +222 -0
- data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.15/CHANGELOG.md +1146 -0
- data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.15/MIT-LICENSE +20 -0
- data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.15/README.md +355 -0
- data/vendor/bundle/ruby/3.4.0/gems/rake-13.2.1/MIT-LICENSE +21 -0
- data/vendor/bundle/ruby/3.4.0/gems/rake-13.2.1/README.rdoc +155 -0
- data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/LICENSE +21 -0
- data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/README.md +107 -0
- data/vendor/bundle/ruby/3.4.0/gems/securerandom-0.4.1/README.md +72 -0
- data/vendor/bundle/ruby/3.4.0/gems/typhoeus-1.4.1/CHANGELOG.md +410 -0
- data/vendor/bundle/ruby/3.4.0/gems/typhoeus-1.4.1/LICENSE +22 -0
- data/vendor/bundle/ruby/3.4.0/gems/typhoeus-1.4.1/README.md +588 -0
- data/vendor/bundle/ruby/3.4.0/gems/tzinfo-2.0.6/LICENSE +19 -0
- data/vendor/bundle/ruby/3.4.0/gems/tzinfo-2.0.6/README.md +406 -0
- data/vendor/bundle/ruby/3.4.0/gems/uri-1.0.3/README.md +55 -0
- metadata +66 -4
- data/doc/file.README.html +0 -192
data/doc/file.README.html
DELETED
@@ -1,192 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="UTF-8">
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
-
<title>
|
7
|
-
File: README
|
8
|
-
|
9
|
-
— Documentation by YARD 0.9.37
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="css/style.css" type="text/css" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="css/common.css" type="text/css" />
|
16
|
-
|
17
|
-
<script type="text/javascript">
|
18
|
-
pathId = "README";
|
19
|
-
relpath = '';
|
20
|
-
</script>
|
21
|
-
|
22
|
-
|
23
|
-
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
-
|
25
|
-
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
-
|
27
|
-
|
28
|
-
</head>
|
29
|
-
<body>
|
30
|
-
<div class="nav_wrap">
|
31
|
-
<iframe id="nav" src="file_list.html?1"></iframe>
|
32
|
-
<div id="resizer"></div>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<div id="main" tabindex="-1">
|
36
|
-
<div id="header">
|
37
|
-
<div id="menu">
|
38
|
-
|
39
|
-
<a href="_index.html">Index</a> »
|
40
|
-
<span class="title">File: README</span>
|
41
|
-
|
42
|
-
</div>
|
43
|
-
|
44
|
-
<div id="search">
|
45
|
-
|
46
|
-
<a class="full_list_link" id="class_list_link"
|
47
|
-
href="class_list.html">
|
48
|
-
|
49
|
-
<svg width="24" height="24">
|
50
|
-
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
51
|
-
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
52
|
-
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
-
</svg>
|
54
|
-
</a>
|
55
|
-
|
56
|
-
</div>
|
57
|
-
<div class="clear"></div>
|
58
|
-
</div>
|
59
|
-
|
60
|
-
<div id="content"><div id='filecontents'><h1 id="restify">Restify</h1>
|
61
|
-
|
62
|
-
<p><a href="https://rubygems.org/gems/restify"><img src="https://img.shields.io/gem/v/restify?logo=ruby" alt="Gem Version"></a>
|
63
|
-
<a href="https://github.com/jgraichen/restify/actions"><img src="https://img.shields.io/github/actions/workflow/status/jgraichen/restify/test.yml?logo=github" alt="GitHub Actions Workflow Status"></a>
|
64
|
-
<a href="https://codebeat.co/projects/github-com-jgraichen-restify-main"><img src="https://codebeat.co/badges/368f8033-bd76-48bc-9777-85f1d4befa94" alt="Code Quality"></a></p>
|
65
|
-
|
66
|
-
<p>Restify is an hypermedia REST client that does parallel, concurrent and keep-alive requests by default.</p>
|
67
|
-
|
68
|
-
<p>Restify scans Link headers and returned resource for links and relations to other resources, represented as RFC6570 URI Templates, and exposes those to the developer.</p>
|
69
|
-
|
70
|
-
<p>Restify can be used to consume hypermedia REST APIs (like GitHubs), to build a site-specific library or to use within your own backend services.</p>
|
71
|
-
|
72
|
-
<p>Restify is build upon the following libraries:</p>
|
73
|
-
|
74
|
-
<ul>
|
75
|
-
<li><a href="https://github.com/ruby-concurrency/concurrent-ruby">concurrent-ruby</a></li>
|
76
|
-
<li><a href="https://github.com/sporkmonger/addressable">addressable</a></li>
|
77
|
-
<li><a href="https://github.com/typhoeus/typhoeus">typhoeus</a></li>
|
78
|
-
</ul>
|
79
|
-
|
80
|
-
<p>The HTTP adapters are mostly run in a background thread and may not survive mid-application forks.</p>
|
81
|
-
|
82
|
-
<p>Restify includes processors to parse responses and to extract links between resources. The following formats are can be parsed:</p>
|
83
|
-
|
84
|
-
<ul>
|
85
|
-
<li>JSON</li>
|
86
|
-
<li>MessagePack</li>
|
87
|
-
</ul>
|
88
|
-
|
89
|
-
<p>Links are extracted from</p>
|
90
|
-
|
91
|
-
<ul>
|
92
|
-
<li>HTTP Link header</li>
|
93
|
-
<li>Github-style relations in payloads</li>
|
94
|
-
</ul>
|
95
|
-
|
96
|
-
<h2 id="installation">Installation</h2>
|
97
|
-
|
98
|
-
<p>Add it to your Gemfile:</p>
|
99
|
-
|
100
|
-
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>restify</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>~> 2.0</span><span class='tstring_end'>'</span></span>
|
101
|
-
</code></pre>
|
102
|
-
|
103
|
-
<p>Or install it manually:</p>
|
104
|
-
|
105
|
-
<pre class="code console"><code class="console">gem install restify
|
106
|
-
</code></pre>
|
107
|
-
|
108
|
-
<h2 id="usage">Usage</h2>
|
109
|
-
|
110
|
-
<p>Create new Restify object. It essentially means to request some start-resource usually the "root" resource:</p>
|
111
|
-
|
112
|
-
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Restify.html" title="Restify (module)">Restify</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Restify/Global.html#new-instance_method" title="Restify::Global#new (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>https://api.github.com</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span>
|
113
|
-
<span class='comment'># => {"current_user_url"=>"https://api.github.com/user",
|
114
|
-
</span><span class='comment'># "current_user_authorizations_html_url"=>"https://github.com/settings/connections/applications{/client_id}",
|
115
|
-
</span><span class='comment'># ...
|
116
|
-
</span><span class='comment'># "repository_url"=>"https://api.github.com/repos/{owner}/{repo}",
|
117
|
-
</span><span class='comment'># ...
|
118
|
-
</span></code></pre>
|
119
|
-
|
120
|
-
<p>We are essentially requesting <code>'http://api.github.com'</code> via HTTP <code>get</code>. <code>get</code> is returning a <code>Promise</code>, similar to Java's <code>Future</code>. The <code>value</code> call resolves the returned <code>Promise</code> by blocking the thread until the resource is actually there. <code>value!</code> will additionally raise errors instead of returning <code>nil</code>. You can chain handlers using the <code>then</code> method. This allows you to be build a dependency chain that will be executed when the last promise is needed.</p>
|
121
|
-
|
122
|
-
<p>As we can see GitHub returns us a field <code>repository_url</code> with a URI template. Restify automatically scans for <code>*_url</code> fields in the JSON response and exposes these as relations. It additionally scans the HTTP Header field <code>Link</code> for relations like pagination.</p>
|
123
|
-
|
124
|
-
<p>We can now use the relations to navigate from resource to resource like a browser from one web page to another page.</p>
|
125
|
-
|
126
|
-
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_repositories'>repositories</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_rel'>rel</span><span class='lparen'>(</span><span class='symbol'>:repository</span><span class='rparen'>)</span>
|
127
|
-
<span class='comment'># => #<Restify::Relation:0x00000005548968 @context=#<Restify::Context:0x007f6024066ae0 @uri=#<Addressable::URI:0x29d8684 URI:https://api.github.com>>, @template=#<Addressable::Template:0x2aa44a0 PATTERN:https://api.github.com/repos/{owner}/{repo}>>
|
128
|
-
</span></code></pre>
|
129
|
-
|
130
|
-
<p>This gets us the relation named <code>repository</code> that we can request now. The usual HTTP methods are available on a relation:</p>
|
131
|
-
|
132
|
-
<pre class="code ruby"><code class="ruby">def get(params, params:, headers:, **)
|
133
|
-
def head(params, params:, headers:, **)
|
134
|
-
def delete(params, params:, headers:, **)
|
135
|
-
|
136
|
-
def put(data = nil, params:, headers:, **)
|
137
|
-
def post(data = nil, params:, headers:, **)
|
138
|
-
def patch(data = nil, params:, headers:, **)
|
139
|
-
</code></pre>
|
140
|
-
|
141
|
-
<p>URL templates can define some parameters such as <code>{owner}</code> or <code>{repo}</code>. They will be expanded from the <code>params</code> given to the HTTP method.</p>
|
142
|
-
|
143
|
-
<p>Now send a GET request with some parameters to request a specific repository:</p>
|
144
|
-
|
145
|
-
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_repo'>repo</span> <span class='op'>=</span> <span class='id identifier rubyid_repositories'>repositories</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>owner:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>jgraichen</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>repo:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>restify</span><span class='tstring_end'>'</span></span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span>
|
146
|
-
</code></pre>
|
147
|
-
|
148
|
-
<p>Now fetch a list of commits for this repo and get this first one:</p>
|
149
|
-
|
150
|
-
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_commit'>commit</span> <span class='op'>=</span> <span class='id identifier rubyid_repo'>repo</span><span class='period'>.</span><span class='id identifier rubyid_rel'>rel</span><span class='lparen'>(</span><span class='symbol'>:commits</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
151
|
-
</code></pre>
|
152
|
-
|
153
|
-
<p>And print it:</p>
|
154
|
-
|
155
|
-
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Last commit: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_commit'>commit</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>sha</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
156
|
-
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>By </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_commit'>commit</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>commit</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>author</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>name</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'> <</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_commit'>commit</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>commit</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>author</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>email</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>></span><span class='tstring_end'>"</span></span>
|
157
|
-
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_commit'>commit</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>commit</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>message</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
158
|
-
</code></pre>
|
159
|
-
|
160
|
-
<p>See commented example in main spec <a href="https://github.com/jgraichen/restify/blob/master/spec/restify_spec.rb#L100"><code>spec/restify_spec.rb</code></a> or in the <code>examples</code> directory.</p>
|
161
|
-
|
162
|
-
<h2 id="contributing">Contributing</h2>
|
163
|
-
|
164
|
-
<ol>
|
165
|
-
<li><a href="http://github.com/jgraichen/restify/fork">Fork it</a></li>
|
166
|
-
<li>Create your feature branch (<code>git checkout -b my-new-feature</code>)</li>
|
167
|
-
<li>Commit specs for your feature so that I do not break it later</li>
|
168
|
-
<li>Commit your changes (<code>git commit -am 'Add some feature'</code>)</li>
|
169
|
-
<li>Push to the branch (<code>git push origin my-new-feature</code>)</li>
|
170
|
-
<li>Create new Pull Request</li>
|
171
|
-
</ol>
|
172
|
-
|
173
|
-
<h2 id="license">License</h2>
|
174
|
-
|
175
|
-
<p>Copyright (C) 2014-2025 Jan Graichen</p>
|
176
|
-
|
177
|
-
<p>This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</p>
|
178
|
-
|
179
|
-
<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</p>
|
180
|
-
|
181
|
-
<p>You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>.</p>
|
182
|
-
</div></div>
|
183
|
-
|
184
|
-
<div id="footer">
|
185
|
-
Generated on Sun Feb 16 14:11:59 2025 by
|
186
|
-
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
187
|
-
0.9.37 (ruby-3.4.2).
|
188
|
-
</div>
|
189
|
-
|
190
|
-
</div>
|
191
|
-
</body>
|
192
|
-
</html>
|