print_json_response 2.0 → 2.0.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.
data/History.txt CHANGED
@@ -1,9 +1,13 @@
1
+ === 2.0.1
2
+ * Bug fixes:
3
+ * irb mode works with $response now
4
+
1
5
  === 2.0
2
6
 
3
7
  * Major enhancement:
4
8
  * Added djr "diff json response", diff the output of two json results
5
9
 
6
- === 1.0 / ??
10
+ === 1.0
7
11
 
8
12
  * Major Enhancement
9
13
  * Birthday!
data/README.txt CHANGED
@@ -33,8 +33,8 @@ pjr can jump into irb, instead of printing json
33
33
  $ pjr -i someurl.json
34
34
  Retrieving http://127.0.0.1:3000/someurl.json:
35
35
  Loading IRB.
36
- JSON response is in @response
37
- irb(main):001:0> @response['what']
36
+ JSON response is in $response
37
+ irb(main):001:0> $response['what']
38
38
  => "oh hey look some pretty-printed json"
39
39
 
40
40
  djr can diff two JSON results:
@@ -4,9 +4,29 @@ require 'uri'
4
4
 
5
5
  require 'json'
6
6
 
7
+ require 'pp'
8
+ module PP::PPMethods
9
+
10
+ def pp_hash obj
11
+ group(1, '{', '}') {
12
+ keys = obj.keys.sort
13
+ seplist(keys, nil, :each) {|k|
14
+ group {
15
+ pp k
16
+ text '=>'
17
+ group(1) {
18
+ breakable ''
19
+ pp obj[k]
20
+ }
21
+ }
22
+ }
23
+ }
24
+ end
25
+ end
26
+
7
27
  class PrintJsonResponse
8
28
 
9
- VERSION = '2.0'
29
+ VERSION = '2.0.1'
10
30
 
11
31
  DEFAULT_HOST = 'http://127.0.0.1:3000'
12
32
 
@@ -42,7 +62,7 @@ document like:
42
62
  options[:diff_opts] = value
43
63
  end if djr
44
64
 
45
- opts.on '--[no-]irb', 'Dump the results into @response in IRB' do |value|
65
+ opts.on '--[no-]irb', 'Dump the results into $response in IRB' do |value|
46
66
  options[:irb] = value
47
67
  end
48
68
  end
@@ -53,7 +73,9 @@ document like:
53
73
 
54
74
  urls = argv.shift(djr ? 2 : 1)
55
75
 
56
- options[:path] = argv
76
+ options[:path] = argv.dup
77
+
78
+ argv.clear
57
79
 
58
80
  return urls, options
59
81
  end
@@ -91,7 +113,6 @@ document like:
91
113
  end
92
114
 
93
115
  def diff results
94
- require 'pp'
95
116
  require 'tempfile'
96
117
  require 'enumerator'
97
118
 
@@ -119,8 +140,8 @@ document like:
119
140
 
120
141
  def irb json
121
142
  require 'irb'
122
- @response = json
123
- puts "JSON response is in @response"
143
+ $response = json
144
+ puts "JSON response is in $response"
124
145
  IRB.start
125
146
  end
126
147
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: print_json_response
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- version: "2.0"
9
+ - 1
10
+ version: 2.0.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Jacob Dunphy