cft_smartcloud 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG +11 -0
- data/README.md +106 -0
- data/VERSION +1 -1
- data/bin/cft_smartcloud +33 -7
- data/bin/smartcloud +33 -7
- data/cft_smartcloud.gemspec +84 -20
- data/lib/config/config.yml +2 -0
- data/lib/curl_client.rb +42 -0
- data/lib/rest-client-1.6.6-master/.gitignore +6 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/README.rdoc +10 -1
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/Rakefile +0 -0
- data/lib/rest-client-1.6.6-master/VERSION +1 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/bin/restclient +5 -4
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/history.md +22 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/rest-client.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/rest_client.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/abstract_response.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/exceptions.rb +0 -0
- data/lib/rest-client-1.6.6-master/lib/restclient/net_http_ext.rb +55 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/payload.rb +17 -2
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/raw_response.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/request.rb +21 -19
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/resource.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/response.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient.rb +0 -0
- data/lib/rest-client-1.6.6-master/rest-client.gemspec +76 -0
- data/lib/rest-client-1.6.6-master/spec/abstract_response_spec.rb +85 -0
- data/lib/rest-client-1.6.6-master/spec/base.rb +16 -0
- data/lib/rest-client-1.6.6-master/spec/exceptions_spec.rb +98 -0
- data/lib/rest-client-1.6.6-master/spec/integration/certs/equifax.crt +19 -0
- data/lib/rest-client-1.6.6-master/spec/integration/certs/verisign.crt +14 -0
- data/lib/rest-client-1.6.6-master/spec/integration/request_spec.rb +25 -0
- data/lib/rest-client-1.6.6-master/spec/integration_spec.rb +38 -0
- data/lib/rest-client-1.6.6-master/spec/master_shake.jpg +0 -0
- data/lib/rest-client-1.6.6-master/spec/payload_spec.rb +234 -0
- data/lib/rest-client-1.6.6-master/spec/raw_response_spec.rb +17 -0
- data/lib/rest-client-1.6.6-master/spec/request2_spec.rb +40 -0
- data/lib/rest-client-1.6.6-master/spec/request_spec.rb +536 -0
- data/lib/rest-client-1.6.6-master/spec/resource_spec.rb +134 -0
- data/lib/rest-client-1.6.6-master/spec/response_spec.rb +169 -0
- data/lib/rest-client-1.6.6-master/spec/restclient_spec.rb +73 -0
- data/lib/slop-2.3.1/.gemtest +0 -0
- data/lib/slop-2.3.1/.gitignore +6 -0
- data/lib/slop-2.3.1/.yardopts +6 -0
- data/lib/slop-2.3.1/CHANGES.md +137 -0
- data/lib/slop-2.3.1/LICENSE +20 -0
- data/lib/slop-2.3.1/README.md +293 -0
- data/lib/slop-2.3.1/Rakefile +6 -0
- data/lib/slop-2.3.1/lib/slop.rb +1022 -0
- data/lib/slop-2.3.1/slop.gemspec +11 -0
- data/lib/slop-2.3.1/test/commands_test.rb +151 -0
- data/lib/slop-2.3.1/test/helper.rb +13 -0
- data/lib/slop-2.3.1/test/option_test.rb +198 -0
- data/lib/slop-2.3.1/test/slop_test.rb +574 -0
- data/lib/smartcloud.rb +186 -116
- data/lib/terminal-table-1.4.4/History.rdoc +53 -0
- data/lib/terminal-table-1.4.4/Manifest +24 -0
- data/lib/terminal-table-1.4.4/README.rdoc +240 -0
- data/lib/terminal-table-1.4.4/Rakefile +15 -0
- data/lib/terminal-table-1.4.4/Todo.rdoc +14 -0
- data/lib/terminal-table-1.4.4/examples/examples.rb +80 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/cell.rb +88 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/core_ext.rb +8 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/import.rb +4 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/row.rb +48 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/separator.rb +14 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/style.rb +61 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/table.rb +217 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/table_helper.rb +9 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/version.rb +6 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table.rb +27 -0
- data/lib/terminal-table-1.4.4/spec/cell_spec.rb +54 -0
- data/lib/terminal-table-1.4.4/spec/core_ext_spec.rb +18 -0
- data/lib/terminal-table-1.4.4/spec/import_spec.rb +11 -0
- data/lib/terminal-table-1.4.4/spec/spec.opts +1 -0
- data/lib/terminal-table-1.4.4/spec/spec_helper.rb +8 -0
- data/lib/terminal-table-1.4.4/spec/table_spec.rb +525 -0
- data/lib/terminal-table-1.4.4/tasks/docs.rake +13 -0
- data/lib/terminal-table-1.4.4/tasks/gemspec.rake +3 -0
- data/lib/terminal-table-1.4.4/tasks/spec.rake +25 -0
- data/lib/terminal-table-1.4.4/terminal-table.gemspec +30 -0
- data/responses/addresses +26 -0
- data/responses/addresses.blank +2 -0
- data/responses/instances +74 -0
- data/responses/keys +33 -0
- data/responses/locations +142 -0
- data/responses/offerings_image +3780 -0
- data/responses/storage +379 -0
- metadata +86 -22
- data/README.rdoc +0 -75
- data/lib/rest-client-1.6.3/VERSION +0 -1
- data/lib/rest-client-1.6.3/lib/restclient/net_http_ext.rb +0 -21
@@ -0,0 +1,234 @@
|
|
1
|
+
require File.join(File.dirname(File.expand_path(__FILE__)), 'base')
|
2
|
+
|
3
|
+
describe RestClient::Payload do
|
4
|
+
context "A regular Payload" do
|
5
|
+
it "should use standard enctype as default content-type" do
|
6
|
+
RestClient::Payload::UrlEncoded.new({}).headers['Content-Type'].
|
7
|
+
should == 'application/x-www-form-urlencoded'
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should form properly encoded params" do
|
11
|
+
RestClient::Payload::UrlEncoded.new({:foo => 'bar'}).to_s.
|
12
|
+
should == "foo=bar"
|
13
|
+
["foo=bar&baz=qux", "baz=qux&foo=bar"].should include(
|
14
|
+
RestClient::Payload::UrlEncoded.new({:foo => 'bar', :baz => 'qux'}).to_s)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should escape parameters" do
|
18
|
+
RestClient::Payload::UrlEncoded.new({'foo ' => 'bar'}).to_s.
|
19
|
+
should == "foo%20=bar"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should properly handle hashes as parameter" do
|
23
|
+
RestClient::Payload::UrlEncoded.new({:foo => {:bar => 'baz'}}).to_s.
|
24
|
+
should == "foo[bar]=baz"
|
25
|
+
RestClient::Payload::UrlEncoded.new({:foo => {:bar => {:baz => 'qux'}}}).to_s.
|
26
|
+
should == "foo[bar][baz]=qux"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should handle many attributes inside a hash" do
|
30
|
+
parameters = RestClient::Payload::UrlEncoded.new({:foo => {:bar => 'baz', :baz => 'qux'}}).to_s
|
31
|
+
parameters.should include("foo[bar]=baz", "foo[baz]=qux")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should handle attributes inside a an array inside an hash" do
|
35
|
+
parameters = RestClient::Payload::UrlEncoded.new({"foo" => [{"bar" => 'baz'}, {"bar" => 'qux'}]}).to_s
|
36
|
+
parameters.should include("foo[bar]=baz", "foo[bar]=qux")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should handle attributes inside a an array inside an array inside an hash" do
|
40
|
+
parameters = RestClient::Payload::UrlEncoded.new({"foo" => [[{"bar" => 'baz'}, {"bar" => 'qux'}]]}).to_s
|
41
|
+
parameters.should include("foo[bar]=baz", "foo[bar]=qux")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should form properly use symbols as parameters" do
|
45
|
+
RestClient::Payload::UrlEncoded.new({:foo => :bar}).to_s.
|
46
|
+
should == "foo=bar"
|
47
|
+
RestClient::Payload::UrlEncoded.new({:foo => {:bar => :baz}}).to_s.
|
48
|
+
should == "foo[bar]=baz"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should properly handle arrays as repeated parameters" do
|
52
|
+
RestClient::Payload::UrlEncoded.new({:foo => ['bar']}).to_s.
|
53
|
+
should == "foo[]=bar"
|
54
|
+
RestClient::Payload::UrlEncoded.new({:foo => ['bar', 'baz']}).to_s.
|
55
|
+
should == "foo[]=bar&foo[]=baz"
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should not close if stream already closed' do
|
59
|
+
p = RestClient::Payload::UrlEncoded.new({'foo ' => 'bar'})
|
60
|
+
3.times {p.close}
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
context "A multipart Payload" do
|
66
|
+
it "should use standard enctype as default content-type" do
|
67
|
+
m = RestClient::Payload::Multipart.new({})
|
68
|
+
m.stub!(:boundary).and_return(123)
|
69
|
+
m.headers['Content-Type'].should == 'multipart/form-data; boundary=123'
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should not error on close if stream already closed' do
|
73
|
+
m = RestClient::Payload::Multipart.new(:file => File.new(File.join(File.dirname(File.expand_path(__FILE__)), 'master_shake.jpg')))
|
74
|
+
3.times {m.close}
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should form properly separated multipart data" do
|
78
|
+
m = RestClient::Payload::Multipart.new([[:bar, "baz"], [:foo, "bar"]])
|
79
|
+
m.to_s.should == <<-EOS
|
80
|
+
--#{m.boundary}\r
|
81
|
+
Content-Disposition: form-data; name="bar"\r
|
82
|
+
\r
|
83
|
+
baz\r
|
84
|
+
--#{m.boundary}\r
|
85
|
+
Content-Disposition: form-data; name="foo"\r
|
86
|
+
\r
|
87
|
+
bar\r
|
88
|
+
--#{m.boundary}--\r
|
89
|
+
EOS
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should not escape parameters names" do
|
93
|
+
m = RestClient::Payload::Multipart.new([["bar ", "baz"]])
|
94
|
+
m.to_s.should == <<-EOS
|
95
|
+
--#{m.boundary}\r
|
96
|
+
Content-Disposition: form-data; name="bar "\r
|
97
|
+
\r
|
98
|
+
baz\r
|
99
|
+
--#{m.boundary}--\r
|
100
|
+
EOS
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should form properly separated multipart data" do
|
104
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
105
|
+
m = RestClient::Payload::Multipart.new({:foo => f})
|
106
|
+
m.to_s.should == <<-EOS
|
107
|
+
--#{m.boundary}\r
|
108
|
+
Content-Disposition: form-data; name="foo"; filename="master_shake.jpg"\r
|
109
|
+
Content-Type: image/jpeg\r
|
110
|
+
\r
|
111
|
+
#{IO.read(f.path)}\r
|
112
|
+
--#{m.boundary}--\r
|
113
|
+
EOS
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should ignore the name attribute when it's not set" do
|
117
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
118
|
+
m = RestClient::Payload::Multipart.new({nil => f})
|
119
|
+
m.to_s.should == <<-EOS
|
120
|
+
--#{m.boundary}\r
|
121
|
+
Content-Disposition: form-data; filename="master_shake.jpg"\r
|
122
|
+
Content-Type: image/jpeg\r
|
123
|
+
\r
|
124
|
+
#{IO.read(f.path)}\r
|
125
|
+
--#{m.boundary}--\r
|
126
|
+
EOS
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should detect optional (original) content type and filename" do
|
130
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
131
|
+
f.instance_eval "def content_type; 'text/plain'; end"
|
132
|
+
f.instance_eval "def original_filename; 'foo.txt'; end"
|
133
|
+
m = RestClient::Payload::Multipart.new({:foo => f})
|
134
|
+
m.to_s.should == <<-EOS
|
135
|
+
--#{m.boundary}\r
|
136
|
+
Content-Disposition: form-data; name="foo"; filename="foo.txt"\r
|
137
|
+
Content-Type: text/plain\r
|
138
|
+
\r
|
139
|
+
#{IO.read(f.path)}\r
|
140
|
+
--#{m.boundary}--\r
|
141
|
+
EOS
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should handle hash in hash parameters" do
|
145
|
+
m = RestClient::Payload::Multipart.new({:bar => {:baz => "foo"}})
|
146
|
+
m.to_s.should == <<-EOS
|
147
|
+
--#{m.boundary}\r
|
148
|
+
Content-Disposition: form-data; name="bar[baz]"\r
|
149
|
+
\r
|
150
|
+
foo\r
|
151
|
+
--#{m.boundary}--\r
|
152
|
+
EOS
|
153
|
+
|
154
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
155
|
+
f.instance_eval "def content_type; 'text/plain'; end"
|
156
|
+
f.instance_eval "def original_filename; 'foo.txt'; end"
|
157
|
+
m = RestClient::Payload::Multipart.new({:foo => {:bar => f}})
|
158
|
+
m.to_s.should == <<-EOS
|
159
|
+
--#{m.boundary}\r
|
160
|
+
Content-Disposition: form-data; name="foo[bar]"; filename="foo.txt"\r
|
161
|
+
Content-Type: text/plain\r
|
162
|
+
\r
|
163
|
+
#{IO.read(f.path)}\r
|
164
|
+
--#{m.boundary}--\r
|
165
|
+
EOS
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
context "streamed payloads" do
|
171
|
+
it "should properly determine the size of file payloads" do
|
172
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
173
|
+
payload = RestClient::Payload.generate(f)
|
174
|
+
payload.size.should == 22_545
|
175
|
+
payload.length.should == 22_545
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should properly determine the size of other kinds of streaming payloads" do
|
179
|
+
s = StringIO.new 'foo'
|
180
|
+
payload = RestClient::Payload.generate(s)
|
181
|
+
payload.size.should == 3
|
182
|
+
payload.length.should == 3
|
183
|
+
|
184
|
+
begin
|
185
|
+
f = Tempfile.new "rest-client"
|
186
|
+
f.write 'foo bar'
|
187
|
+
|
188
|
+
payload = RestClient::Payload.generate(f)
|
189
|
+
payload.size.should == 7
|
190
|
+
payload.length.should == 7
|
191
|
+
ensure
|
192
|
+
f.close
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
context "Payload generation" do
|
198
|
+
it "should recognize standard urlencoded params" do
|
199
|
+
RestClient::Payload.generate({"foo" => 'bar'}).should be_kind_of(RestClient::Payload::UrlEncoded)
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should recognize multipart params" do
|
203
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
204
|
+
RestClient::Payload.generate({"foo" => f}).should be_kind_of(RestClient::Payload::Multipart)
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should be multipart if forced" do
|
208
|
+
RestClient::Payload.generate({"foo" => "bar", :multipart => true}).should be_kind_of(RestClient::Payload::Multipart)
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should return data if no of the above" do
|
212
|
+
RestClient::Payload.generate("data").should be_kind_of(RestClient::Payload::Base)
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should recognize nested multipart payloads in hashes" do
|
216
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
217
|
+
RestClient::Payload.generate({"foo" => {"file" => f}}).should be_kind_of(RestClient::Payload::Multipart)
|
218
|
+
end
|
219
|
+
|
220
|
+
it "should recognize nested multipart payloads in arrays" do
|
221
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
222
|
+
RestClient::Payload.generate({"foo" => [f]}).should be_kind_of(RestClient::Payload::Multipart)
|
223
|
+
end
|
224
|
+
|
225
|
+
it "should recognize file payloads that can be streamed" do
|
226
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
227
|
+
RestClient::Payload.generate(f).should be_kind_of(RestClient::Payload::Streamed)
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should recognize other payloads that can be streamed" do
|
231
|
+
RestClient::Payload.generate(StringIO.new('foo')).should be_kind_of(RestClient::Payload::Streamed)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.join( File.dirname(File.expand_path(__FILE__)), 'base')
|
2
|
+
|
3
|
+
describe RestClient::RawResponse do
|
4
|
+
before do
|
5
|
+
@tf = mock("Tempfile", :read => "the answer is 42", :open => true)
|
6
|
+
@net_http_res = mock('net http response')
|
7
|
+
@response = RestClient::RawResponse.new(@tf, @net_http_res, {})
|
8
|
+
end
|
9
|
+
|
10
|
+
it "behaves like string" do
|
11
|
+
@response.to_s.should == 'the answer is 42'
|
12
|
+
end
|
13
|
+
|
14
|
+
it "exposes a Tempfile" do
|
15
|
+
@response.file.should == @tf
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.join( File.dirname(File.expand_path(__FILE__)), 'base')
|
2
|
+
|
3
|
+
require 'webmock/rspec'
|
4
|
+
include WebMock
|
5
|
+
|
6
|
+
describe RestClient::Request do
|
7
|
+
|
8
|
+
it "manage params for get requests" do
|
9
|
+
stub_request(:get, 'http://some/resource?a=b&c=d').with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'Foo'=>'bar'}).to_return(:body => 'foo', :status => 200)
|
10
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get, :headers => {:foo => :bar, :params => {:a => :b, 'c' => 'd'}}).body.should == 'foo'
|
11
|
+
|
12
|
+
stub_request(:get, 'http://some/resource').with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'Foo'=>'bar', 'params' => 'a'}).to_return(:body => 'foo', :status => 200)
|
13
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get, :headers => {:foo => :bar, :params => :a}).body.should == 'foo'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can use a block to process response" do
|
17
|
+
response_value = nil
|
18
|
+
block = Proc.new do |http_response|
|
19
|
+
response_value = http_response.body
|
20
|
+
end
|
21
|
+
stub_request(:get, 'http://some/resource?a=b&c=d').with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'Foo'=>'bar'}).to_return(:body => 'foo', :status => 200)
|
22
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get, :headers => {:foo => :bar, :params => {:a => :b, 'c' => 'd'}}, :block_response => block)
|
23
|
+
response_value.should == "foo"
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'closes payload if not nil' do
|
27
|
+
test_file = File.new(File.join( File.dirname(File.expand_path(__FILE__)), 'master_shake.jpg'))
|
28
|
+
initial_count = tmp_count
|
29
|
+
|
30
|
+
stub_request(:post, 'http://some/resource').with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate'}).to_return(:body => 'foo', :status => 200)
|
31
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :post, :payload => {:file => test_file})
|
32
|
+
|
33
|
+
tmp_count.should == initial_count
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
def tmp_count
|
39
|
+
Dir.glob(Dir::tmpdir + "/*").size
|
40
|
+
end
|