admin-cf-plugin 0.2.0.rc2 → 0.2.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/admin-cf-plugin/curl.rb +10 -3
- data/lib/admin-cf-plugin/version.rb +1 -1
- data/spec/curl_spec.rb +28 -13
- data/spec/spec_helper.rb +1 -0
- metadata +36 -64
data/lib/admin-cf-plugin/curl.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "multi_json"
|
2
|
+
|
1
3
|
require "cf/cli"
|
2
4
|
|
3
5
|
module CFAdmin
|
@@ -42,10 +44,15 @@ module CFAdmin
|
|
42
44
|
:payload => body,
|
43
45
|
:content => body && content)
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
+
body = res[:body]
|
48
|
+
|
49
|
+
type = res[:headers]["content-type"]
|
50
|
+
|
51
|
+
if type && type.include?("application/json")
|
52
|
+
json = MultiJson.load(body)
|
53
|
+
puts MultiJson.dump(json, :pretty => true)
|
47
54
|
else
|
48
|
-
puts
|
55
|
+
puts body
|
49
56
|
end
|
50
57
|
end
|
51
58
|
|
data/spec/curl_spec.rb
CHANGED
@@ -1,46 +1,61 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
3
|
+
command CFAdmin::Curl do
|
4
4
|
let(:fake_home_dir) { "#{SPEC_ROOT}/fixtures/fake_home_dir" }
|
5
|
+
|
5
6
|
stub_home_dir_with { fake_home_dir }
|
6
7
|
|
7
|
-
|
8
|
+
let(:client) { fake_client }
|
9
|
+
|
10
|
+
context "when the response is JSON" do
|
11
|
+
subject { cf %W[curl GET /foo] }
|
12
|
+
|
13
|
+
it "pretty-prints the response" do
|
14
|
+
stub_request(:get, "http://example.com/foo").to_return(
|
15
|
+
:headers => {
|
16
|
+
"content-type" => "application/json; charset=utf8"
|
17
|
+
},
|
18
|
+
:status => 200,
|
19
|
+
:body => '{"foo":"bar"}'
|
20
|
+
)
|
21
|
+
|
22
|
+
subject
|
8
23
|
|
9
|
-
|
10
|
-
|
11
|
-
|
24
|
+
expect(output).to say(<<OUT)
|
25
|
+
{
|
26
|
+
"foo": "bar"
|
27
|
+
}
|
28
|
+
OUT
|
12
29
|
end
|
13
30
|
end
|
14
31
|
|
15
32
|
context "with an implicit target" do
|
16
|
-
|
33
|
+
subject { cf %W[curl GET /apps/5/instances] }
|
17
34
|
|
18
35
|
it "makes a request to the current target" do
|
19
|
-
stub_request(:get, "
|
36
|
+
stub_request(:get, "http://example.com/apps/5/instances").to_return(
|
20
37
|
:status => 200,
|
21
38
|
:body => 'some-body'
|
22
39
|
)
|
23
40
|
|
24
41
|
subject
|
25
42
|
|
26
|
-
expect(
|
27
|
-
expect(stdout.string).to include('"body": "some-body"')
|
43
|
+
expect(output).to say("some-body")
|
28
44
|
end
|
29
45
|
end
|
30
46
|
|
31
47
|
context "with an explicit target" do
|
32
|
-
|
48
|
+
subject { cf %W[curl GET https://some-other-domain.com/apps/5/instances] }
|
33
49
|
|
34
50
|
it "makes a request to the given target" do
|
35
|
-
stub_request(:get, "https://
|
51
|
+
stub_request(:get, "https://some-other-domain.com/apps/5/instances").to_return(
|
36
52
|
:status => 200,
|
37
53
|
:body => 'some-other-body'
|
38
54
|
)
|
39
55
|
|
40
56
|
subject
|
41
57
|
|
42
|
-
expect(
|
43
|
-
expect(stdout.string).to include('"body": "some-other-body"')
|
58
|
+
expect(output).to say("some-other-body")
|
44
59
|
end
|
45
60
|
end
|
46
61
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,59 +1,39 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: admin-cf-plugin
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0.rc3
|
5
5
|
prerelease: 6
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
- rc
|
11
|
-
- 2
|
12
|
-
version: 0.2.0.rc2
|
13
6
|
platform: ruby
|
14
|
-
authors:
|
7
|
+
authors:
|
15
8
|
- Alex Suraci
|
16
9
|
autorequire:
|
17
10
|
bindir: bin
|
18
11
|
cert_chain: []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
date: 2013-03-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cfoundry
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 6
|
32
|
-
- 0
|
33
|
-
- rc
|
34
|
-
- 2
|
35
|
-
version: 0.6.0.rc2
|
36
|
-
- - <
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
hash: 5
|
39
|
-
segments:
|
40
|
-
- 0
|
41
|
-
- 7
|
42
|
-
version: "0.7"
|
43
|
-
prerelease: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.6.0
|
44
22
|
type: :runtime
|
45
|
-
|
46
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.6.0
|
47
30
|
description:
|
48
|
-
email:
|
31
|
+
email:
|
49
32
|
- asuraci@vmware.com
|
50
33
|
executables: []
|
51
|
-
|
52
34
|
extensions: []
|
53
|
-
|
54
35
|
extra_rdoc_files: []
|
55
|
-
|
56
|
-
files:
|
36
|
+
files:
|
57
37
|
- Rakefile
|
58
38
|
- lib/admin-cf-plugin/curl.rb
|
59
39
|
- lib/admin-cf-plugin/guid.rb
|
@@ -65,40 +45,32 @@ files:
|
|
65
45
|
- spec/spec_helper.rb
|
66
46
|
homepage: http://cloudfoundry.com/
|
67
47
|
licenses: []
|
68
|
-
|
69
48
|
post_install_message:
|
70
49
|
rdoc_options: []
|
71
|
-
|
72
|
-
require_paths:
|
50
|
+
require_paths:
|
73
51
|
- lib
|
74
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
53
|
none: false
|
76
|
-
requirements:
|
77
|
-
- -
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
|
80
|
-
segments:
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
segments:
|
81
59
|
- 0
|
82
|
-
|
83
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
hash: -4357441552025755471
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
62
|
none: false
|
85
|
-
requirements:
|
86
|
-
- -
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
hash: 25
|
89
|
-
segments:
|
90
|
-
- 1
|
91
|
-
- 3
|
92
|
-
- 1
|
63
|
+
requirements:
|
64
|
+
- - ! '>'
|
65
|
+
- !ruby/object:Gem::Version
|
93
66
|
version: 1.3.1
|
94
67
|
requirements: []
|
95
|
-
|
96
68
|
rubyforge_project: admin-cf-plugin
|
97
|
-
rubygems_version: 1.8.
|
69
|
+
rubygems_version: 1.8.25
|
98
70
|
signing_key:
|
99
71
|
specification_version: 3
|
100
72
|
summary: Cloud Foundry administration commands.
|
101
|
-
test_files:
|
73
|
+
test_files:
|
102
74
|
- spec/curl_spec.rb
|
103
75
|
- spec/guid_spec.rb
|
104
76
|
- spec/spec_helper.rb
|