leif 0.0.6 → 0.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3610c76b9d9f405c0e4bdb4e0a32e9762cd51cb4
4
- data.tar.gz: ef233fb2ad75558607817a0c0497263ea4a6d681
3
+ metadata.gz: 14358331d926739fcb9ddaf54f07ce82cec9dc0e
4
+ data.tar.gz: b3f7f28d1530a0c7b3ea479fad8fb9a221b861d0
5
5
  SHA512:
6
- metadata.gz: 1fe9d60703d464079f71339e5aeaf3ec2a7d8fc9adc89f809bca82deb98e21f8da1665c5711496aa1ff279fa517dcd42865a9240c08bf03f0c159db0a04cb55c
7
- data.tar.gz: 1b5a54e33254a55c1d06e63ff73c889631ed7253d0dcb034d3687bf164be395d61ba60eb499d606f63bf306a20158c065eb6de316545784aa922778f82a54cce
6
+ metadata.gz: e32dd3fef31bf00c8857688e647510e625ce6f77b5875fd1307ae9d10124ae4613985a98566be1ae6c2eb89d203fc50f236544f381dc34c0da8605d517eb841f
7
+ data.tar.gz: dd73d4a03a69ab51abed53c039e2dcc68af1b196f2f584525b693b02fdc21b2057d51d3e1c0003684be4ce2d0030598f31d1912533f9c14728cdef4e26e0e641
data/README.md CHANGED
@@ -14,7 +14,8 @@ $ gem install leif
14
14
  $ leif
15
15
  ```
16
16
 
17
- `leif` includes a man page. To read it:
17
+ `leif` includes a man page. Read it [on the web][manpage] or install
18
+ `gem-man`:
18
19
 
19
20
  ``` bash
20
21
  $ gem install gem-man
@@ -24,20 +25,54 @@ $ gem man leif
24
25
  ## Interactive Commands
25
26
 
26
27
  - `root`:
27
- Go back to the root
28
+ Go back to the root.
28
29
 
29
30
  - `follow` <u>rel</u>:
30
- Follow link with the given relation.
31
+ Follow link with the relation <u>rel</u> on the collection or selected item.
31
32
 
32
- - `basic` <u>username</u> [<u>password</u>]:
33
+ - `create`:
34
+ Begin editing the template to create a new item.
35
+
36
+ - `update`:
37
+ Begin editing the template to update the item selected with `items`.
38
+
39
+ - `request`:
40
+ Print the HTTP headers of the last request.
41
+
42
+ - `response`:
43
+ Print the HTTP headers of the last response.
44
+
45
+ - `body`:
46
+ Print the HTTP body of the last response.
47
+
48
+ - `collection`:
49
+ Print the collection from the last response.
50
+
51
+ - `template`:
52
+ Print the template from the last response.
53
+
54
+ - `items`:
55
+ Print each item from the last response one at a time in order to `update`
56
+ or `follow` an item's link.
57
+
58
+ - `item`:
59
+ Print the selected item.
60
+
61
+ - `basic` [<u>username</u> [<u>password</u>]]:
33
62
  Authenticate with HTTP Basic and reload the current resource. Will be
34
- prompted for password if it is omitted.
63
+ prompted for username and password if omitted.
35
64
 
36
65
  - `token` <u>token</u>:
37
66
  Authenticate using the given token and reload the current resource.
38
67
 
68
+ - `debug`:
69
+ Print debug output from the previous HTTP request and response.
70
+
39
71
  - `help`:
40
- Print interactive command help.
72
+ Print available commands.
73
+
74
+ - `quit`:
75
+ Exit `leif`.
41
76
 
42
77
  ## Example
43
78
 
@@ -73,3 +108,6 @@ sample workflow. It should give you a general overview of what's possible.
73
108
  Value: The Guide
74
109
 
75
110
  Name (empty to submit):
111
+
112
+
113
+ [manpage]: http://cloudapp.github.io/leif
data/lib/leif/cli.rb CHANGED
@@ -55,11 +55,7 @@ module Leif
55
55
  def print_overview
56
56
  print_request
57
57
  print_response
58
-
59
- banner 'Body' do |out|
60
- out.print JSON.pretty_generate(@response.body).lines
61
- end
62
-
58
+ print_body
63
59
  print_links collection
64
60
  end
65
61
 
@@ -131,6 +127,12 @@ module Leif
131
127
  end
132
128
  end
133
129
 
130
+ def print_body
131
+ banner 'Body' do |out|
132
+ out.print JSON.pretty_generate(@response.body).lines
133
+ end
134
+ end
135
+
134
136
  def print_links(subject)
135
137
  banner 'Links' do |out|
136
138
  unless subject.link_relations.empty?
@@ -139,6 +141,12 @@ module Leif
139
141
  end
140
142
  end
141
143
 
144
+ def print_collection
145
+ banner 'Collection' do |out|
146
+ out.print JSON.pretty_generate(collection).lines
147
+ end
148
+ end
149
+
142
150
  def print_template(template = collection.template, label = 'Template')
143
151
  banner label do |out|
144
152
  out.print JSON.pretty_generate(template).lines
@@ -264,9 +272,11 @@ EOS
264
272
  when 'create' then create_item
265
273
  when 'update' then update_item
266
274
 
267
- when 'request' then print_request; get_next_action
268
- when 'response' then print_response; get_next_action
269
- when 'template' then print_template; get_next_action
275
+ when 'request' then print_request; get_next_action
276
+ when 'response' then print_response; get_next_action
277
+ when 'body' then print_body; get_next_action
278
+ when 'collection' then print_collection; get_next_action
279
+ when 'template' then print_template; get_next_action
270
280
  when 'items' then print_items
271
281
 
272
282
  when 'b', 'basic' then request_basic_authentication(*args)
@@ -18,29 +18,14 @@ module Leif
18
18
  end
19
19
  end
20
20
 
21
- class Collection
21
+ class Collection < SimpleDelegator
22
22
  extend Forwardable
23
23
  include Linked
24
24
 
25
- def_delegators :@data, :fetch, :has_key?
26
-
27
25
  def initialize(body)
28
- @data = body.fetch('collection')
26
+ super body.fetch('collection')
29
27
  end
30
28
 
31
- # def link_href(relation)
32
- # links.find {|link| link.fetch('rel') == relation }.fetch('href')
33
- # end
34
-
35
- # def link_relations
36
- # links.map {|link| link.fetch('rel') }
37
- # end
38
-
39
- # def links
40
- # return [] unless has_key?('links')
41
- # fetch('links')
42
- # end
43
-
44
29
  def items
45
30
  return [] unless has_key?('items')
46
31
  fetch('items').map {|item| Item.new(item) }
data/lib/leif/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Leif
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
data/man/leif.1 CHANGED
@@ -32,11 +32,19 @@ Begin editing the template to update the item selected with \fBitems\fR\.
32
32
  .
33
33
  .TP
34
34
  \fBrequest\fR
35
- Reprint the details of the last request\.
35
+ Print the HTTP headers of the last request\.
36
36
  .
37
37
  .TP
38
38
  \fBresponse\fR
39
- Reprint the details of the last response\.
39
+ Print the HTTP headers of the last response\.
40
+ .
41
+ .TP
42
+ \fBbody\fR
43
+ Print the HTTP body of the last response\.
44
+ .
45
+ .TP
46
+ \fBcollection\fR
47
+ Print the collection from the last response\.
40
48
  .
41
49
  .TP
42
50
  \fBtemplate\fR
@@ -44,7 +52,7 @@ Print the template from the last response\.
44
52
  .
45
53
  .TP
46
54
  \fBitems\fR
47
- Print each item from the last response one at a time in order to update, delete, or follow an item\'s link\.
55
+ Print each item from the last response one at a time in order to \fBupdate\fR or \fBfollow\fR an item\'s link\.
48
56
  .
49
57
  .TP
50
58
  \fBitem\fR
@@ -71,7 +79,7 @@ Print available commands\.
71
79
  Exit \fBleif\fR\.
72
80
  .
73
81
  .SH "EXAMPLES"
74
- Follow a rel=account link:
82
+ Follow a rel=account link on the collection:
75
83
  .
76
84
  .IP "" 4
77
85
  .
@@ -84,6 +92,23 @@ Follow a rel=account link:
84
92
  .IP "" 0
85
93
  .
86
94
  .P
95
+ Select an item and follow its rel=collection link:
96
+ .
97
+ .IP "" 4
98
+ .
99
+ .nf
100
+
101
+ > items
102
+
103
+ Select this item [y,n]? y
104
+
105
+ > follow collection
106
+ .
107
+ .fi
108
+ .
109
+ .IP "" 0
110
+ .
111
+ .P
87
112
  Use HTTP Basic authentication and reload the current resource:
88
113
  .
89
114
  .IP "" 4
@@ -139,9 +164,11 @@ Update an item filling the \fBpassword\fR field:
139
164
  .
140
165
  .nf
141
166
 
142
- > update
167
+ > items
143
168
 
144
- Select this item to update [y,n]? y
169
+ Select this item [y,n]? y
170
+
171
+ > update
145
172
 
146
173
  Name (empty to submit): password
147
174
  Value: towel
data/man/leif.1.html CHANGED
@@ -94,11 +94,13 @@ programs.</p>
94
94
  <dt><code>follow</code> <var>rel</var></dt><dd><p>Follow link with the relation <var>rel</var> on the collection or selected item.</p></dd>
95
95
  <dt class="flush"><code>create</code></dt><dd><p>Begin editing the template to create a new item.</p></dd>
96
96
  <dt class="flush"><code>update</code></dt><dd><p>Begin editing the template to update the item selected with <code>items</code>.</p></dd>
97
- <dt class="flush"><code>request</code></dt><dd><p>Reprint the details of the last request.</p></dd>
98
- <dt><code>response</code></dt><dd><p>Reprint the details of the last response.</p></dd>
97
+ <dt class="flush"><code>request</code></dt><dd><p>Print the HTTP headers of the last request.</p></dd>
98
+ <dt><code>response</code></dt><dd><p>Print the HTTP headers of the last response.</p></dd>
99
+ <dt class="flush"><code>body</code></dt><dd><p>Print the HTTP body of the last response.</p></dd>
100
+ <dt><code>collection</code></dt><dd><p>Print the collection from the last response.</p></dd>
99
101
  <dt><code>template</code></dt><dd><p>Print the template from the last response.</p></dd>
100
- <dt class="flush"><code>items</code></dt><dd><p>Print each item from the last response one at a time in order to update,
101
- delete, or follow an item's link.</p></dd>
102
+ <dt class="flush"><code>items</code></dt><dd><p>Print each item from the last response one at a time in order to <code>update</code>
103
+ or <code>follow</code> an item's link.</p></dd>
102
104
  <dt class="flush"><code>item</code></dt><dd><p>Print the selected item.</p></dd>
103
105
  <dt><code>basic</code> [<var>username</var> [<var>password</var>]]</dt><dd><p>Authenticate with HTTP Basic and reload the current resource. Will be
104
106
  prompted for username and password if omitted.</p></dd>
@@ -111,11 +113,20 @@ prompted for username and password if omitted.</p></dd>
111
113
 
112
114
  <h2 id="EXAMPLES">EXAMPLES</h2>
113
115
 
114
- <p>Follow a rel=account link:</p>
116
+ <p>Follow a rel=account link on the collection:</p>
115
117
 
116
118
  <pre><code>&gt; follow account
117
119
  </code></pre>
118
120
 
121
+ <p>Select an item and follow its rel=collection link:</p>
122
+
123
+ <pre><code>&gt; items
124
+
125
+ Select this item [y,n]? y
126
+
127
+ &gt; follow collection
128
+ </code></pre>
129
+
119
130
  <p>Use HTTP Basic authentication and reload the current resource:</p>
120
131
 
121
132
  <pre><code>&gt; basic
@@ -143,9 +154,11 @@ Name (empty to submit):
143
154
 
144
155
  <p>Update an item filling the <code>password</code> field:</p>
145
156
 
146
- <pre><code>&gt; update
157
+ <pre><code>&gt; items
158
+
159
+ Select this item [y,n]? y
147
160
 
148
- Select this item to update [y,n]? y
161
+ &gt; update
149
162
 
150
163
  Name (empty to submit): password
151
164
  Value: towel
data/man/leif.1.ronn CHANGED
@@ -25,17 +25,23 @@ programs.
25
25
  Begin editing the template to update the item selected with `items`.
26
26
 
27
27
  - `request`:
28
- Reprint the details of the last request.
28
+ Print the HTTP headers of the last request.
29
29
 
30
30
  - `response`:
31
- Reprint the details of the last response.
31
+ Print the HTTP headers of the last response.
32
+
33
+ - `body`:
34
+ Print the HTTP body of the last response.
35
+
36
+ - `collection`:
37
+ Print the collection from the last response.
32
38
 
33
39
  - `template`:
34
40
  Print the template from the last response.
35
41
 
36
42
  - `items`:
37
- Print each item from the last response one at a time in order to update,
38
- delete, or follow an item's link.
43
+ Print each item from the last response one at a time in order to `update`
44
+ or `follow` an item's link.
39
45
 
40
46
  - `item`:
41
47
  Print the selected item.
@@ -58,10 +64,18 @@ programs.
58
64
 
59
65
  ## EXAMPLES
60
66
 
61
- Follow a rel=account link:
67
+ Follow a rel=account link on the collection:
62
68
 
63
69
  > follow account
64
70
 
71
+ Select an item and follow its rel=collection link:
72
+
73
+ > items
74
+
75
+ Select this item [y,n]? y
76
+
77
+ > follow collection
78
+
65
79
  Use HTTP Basic authentication and reload the current resource:
66
80
 
67
81
  > basic
@@ -86,9 +100,11 @@ Create a new item filling the `name` and `bookmark_url` fields:
86
100
 
87
101
  Update an item filling the `password` field:
88
102
 
89
- > update
103
+ > items
90
104
 
91
- Select this item to update [y,n]? y
105
+ Select this item [y,n]? y
106
+
107
+ > update
92
108
 
93
109
  Name (empty to submit): password
94
110
  Value: towel
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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Larry Marburger