knife-essentials 0.5.1 → 0.5.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.
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  class Chef
2
4
  class Knife
3
5
  class Raw < Chef::Knife
@@ -7,7 +9,13 @@ class Chef
7
9
  :long => '--method METHOD',
8
10
  :short => '-m METHOD',
9
11
  :default => "GET",
10
- :description => "RequestSpecifies the local repository layout. Values: default or full"
12
+ :description => "Request method (GET, POST, PUT or DELETE)"
13
+
14
+ option :pretty,
15
+ :long => '--[no-]pretty',
16
+ :boolean => true,
17
+ :default => true,
18
+ :description => "Pretty-print JSON output"
11
19
 
12
20
  option :input,
13
21
  :long => '--input FILE',
@@ -60,8 +68,11 @@ class Chef
60
68
  response_body = response.body
61
69
 
62
70
  if response.kind_of?(Net::HTTPSuccess)
63
- # This is where we differ from Chef::REST: we return the raw body always.
64
- response_body
71
+ if config[:pretty] && response['content-type'] =~ /json/
72
+ JSON.pretty_generate(JSON.parse(response_body, :create_additions => false))
73
+ else
74
+ response_body
75
+ end
65
76
  elsif redirect_location = redirected_to(response)
66
77
  raise "Redirected to #{create_url(redirect_location)}"
67
78
  follow_redirect {api_request(:GET, create_url(redirect_location))}
@@ -1,4 +1,4 @@
1
1
  module ChefFS
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-essentials
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: