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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1797138f211bfbb414f907b9b2ec4b03341e14a0
4
- data.tar.gz: 596ebf85889c706e6681435e2311f4aa6a04f0bc
3
+ metadata.gz: 5dcc95800bc2d5d1ae86cd703bfbe9cc45fada5c
4
+ data.tar.gz: 0f19f4caffd24aa042d345ebcc6c92a240201b9a
5
5
  SHA512:
6
- metadata.gz: 371586765c6584c61486ccdfaeeca69268c6738acac464fef4197aac8c7ad9a0bb8704a897f8b171ac8c4f1d405675100ea8b37c6c119f45164f6bb8486ff373
7
- data.tar.gz: 09852a6c60e78b330e16632b18c8207c58d01a19d9e43822ece83e12c7d307d54fb202774ff0d3bc5678dfe6aef889231d7ff0a7922a2f56f49f3e2db667c931
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
- # config.response :logger
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
@@ -1,3 +1,3 @@
1
1
  module Leif
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
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
@@ -24,3 +24,6 @@ programs.
24
24
 
25
25
  - `token` <token>:
26
26
  Authenticate using the given token and reload the current resource.
27
+
28
+ - `debug`:
29
+ Print debug output from the previous HTTP request and response.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leif
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Larry Marburger