leif 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/leif +25 -1
- data/lib/leif/version.rb +1 -1
- data/man/leif.1 +4 -0
- data/man/leif.1.html +1 -0
- data/man/leif.1.ronn +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dcc95800bc2d5d1ae86cd703bfbe9cc45fada5c
|
4
|
+
data.tar.gz: 0f19f4caffd24aa042d345ebcc6c92a240201b9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9ca62217fa3b5b7032fcb21ddbb351dc59e0d4fd2e725e5883b59ebc7c76fce2bd39877f4dc3c7035d27af54fec50039d24df791ef7b49b2ee7db36d381032f
|
7
|
+
data.tar.gz: 1bc16991a37bf09fe812e7003e998cdd215d56babf3455d119f3ab63dee1321d0747bf147dd08a941971c19402474c9f8f22eaf266451bf9723ccd7b9339ffb1
|
data/bin/leif
CHANGED
@@ -36,13 +36,27 @@ end
|
|
36
36
|
|
37
37
|
def conn
|
38
38
|
@conn ||= Faraday.new(url: 'https://api.getcloudapp.com') do |config|
|
39
|
-
|
39
|
+
config.response :logger, logger
|
40
40
|
config.response :json, :content_type => /\bjson$/
|
41
41
|
config.adapter Faraday.default_adapter
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
def logger
|
46
|
+
@logger ||= Logger.new(debug_output)
|
47
|
+
end
|
48
|
+
|
49
|
+
def debug_output
|
50
|
+
@debug_output ||= StringIO.new
|
51
|
+
end
|
52
|
+
|
53
|
+
def reset_debug_output
|
54
|
+
debug_output.rewind
|
55
|
+
debug_output.truncate 0
|
56
|
+
end
|
57
|
+
|
45
58
|
def make_request(uri)
|
59
|
+
reset_debug_output
|
46
60
|
@response = CollectionJsonResponse.new(conn.get(uri))
|
47
61
|
end
|
48
62
|
|
@@ -131,6 +145,13 @@ def follow_link(relation = :ask)
|
|
131
145
|
make_request @response.link(relation).href
|
132
146
|
end
|
133
147
|
|
148
|
+
def print_debug
|
149
|
+
section 'Debug' do |out|
|
150
|
+
debug_output.rewind
|
151
|
+
out.print_lines debug_output.readlines
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
134
155
|
def print_help
|
135
156
|
puts <<EOS
|
136
157
|
root:
|
@@ -155,6 +176,7 @@ def get_next_action
|
|
155
176
|
when 'f', 'follow' then follow_link(*args)
|
156
177
|
when 'b', 'basic' then request_basic_authentication(*args)
|
157
178
|
when 't', 'token' then request_token_authentication(*args)
|
179
|
+
when 'd', 'debug' then print_debug; get_next_action
|
158
180
|
when '?', 'help' then print_help; get_next_action
|
159
181
|
when 'q', 'quit' then exit
|
160
182
|
else puts 'Try again.'; get_next_action
|
@@ -181,4 +203,6 @@ BEGIN {
|
|
181
203
|
require 'json'
|
182
204
|
require 'faraday'
|
183
205
|
require 'faraday_middleware'
|
206
|
+
require 'logger'
|
207
|
+
require 'stringio'
|
184
208
|
}
|
data/lib/leif/version.rb
CHANGED
data/man/leif.1
CHANGED
@@ -29,4 +29,8 @@ Authenticate with HTTP Basic and reload the current resource\. Will be prompted
|
|
29
29
|
.TP
|
30
30
|
\fBtoken\fR \fItoken\fR
|
31
31
|
Authenticate using the given token and reload the current resource\.
|
32
|
+
.
|
33
|
+
.TP
|
34
|
+
\fBdebug\fR
|
35
|
+
Print debug output from the previous HTTP request and response\.
|
32
36
|
|
data/man/leif.1.html
CHANGED
@@ -94,6 +94,7 @@ programs.</p>
|
|
94
94
|
<dt><code>basic</code> <var>username</var> [<var>password</var>]</dt><dd><p>Authenticate with HTTP Basic and reload the current resource. Will be
|
95
95
|
prompted for password if it is omitted.</p></dd>
|
96
96
|
<dt><code>token</code> <var>token</var></dt><dd><p>Authenticate using the given token and reload the current resource.</p></dd>
|
97
|
+
<dt class="flush"><code>debug</code></dt><dd><p>Print debug output from the previous HTTP request and response.</p></dd>
|
97
98
|
</dl>
|
98
99
|
|
99
100
|
|
data/man/leif.1.ronn
CHANGED