elasticshell 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/lib/elasticshell/client.rb
CHANGED
@@ -20,7 +20,7 @@ module Elasticshell
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def safely verb, params={}, options={}, body=''
|
23
|
-
request(verb, params, options.merge(:safely => true))
|
23
|
+
request(verb, params, options.merge(:safely => true), body)
|
24
24
|
end
|
25
25
|
|
26
26
|
def request verb, params={}, options={}, body=''
|
@@ -46,8 +46,8 @@ module Elasticshell
|
|
46
46
|
|
47
47
|
def connect servers, first_attempt=false
|
48
48
|
string = servers.join(' ')
|
49
|
-
Elasticshell.debug("Attempting to connect to #{string} ...")
|
50
|
-
raise ClientError.new("Timed out or failed to connect to
|
49
|
+
Elasticshell.debug("Attempting to connect to #{string} ...") if first_attempt
|
50
|
+
raise ClientError.new("Timed out or failed to connect to any servers") if servers.empty?
|
51
51
|
begin
|
52
52
|
server = servers.shift
|
53
53
|
timeout(5) do
|
@@ -15,7 +15,7 @@ module Elasticshell
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def perform_request!
|
18
|
-
self.response = shell.client.
|
18
|
+
self.response = shell.client.request(request[:verb], {:op => request[:path].gsub(/^\//,'') }, request[:query_options].merge(:log => shell.log_requests?), request[:body])
|
19
19
|
end
|
20
20
|
|
21
21
|
def pipe?
|
@@ -29,10 +29,6 @@ module Elasticshell
|
|
29
29
|
self.raw = command.shell.input.gsub(/ (?:\||>).*$/,'')
|
30
30
|
end
|
31
31
|
|
32
|
-
def strip_file_redirect!
|
33
|
-
self.raw = command.shell.input.gsub(/ >.*$/,'')
|
34
|
-
end
|
35
|
-
|
36
32
|
def split_verb_and_request!
|
37
33
|
if raw =~ Regexp.new("^(#{verb_re})\s+(.+)$", true)
|
38
34
|
self.verb, self.request_string = canonicalize_verb($1), $2
|
@@ -8,50 +8,50 @@ describe Commands::Request do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should recognize a simple request" do
|
11
|
-
@shell.client.should_receive(:
|
11
|
+
@shell.client.should_receive(:request).with("GET", { :op => "_simple" }, kind_of(Hash), "").and_return('{}')
|
12
12
|
@shell.eval_line("_simple")
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should recognize a simple request with a different verb" do
|
16
|
-
@shell.client.should_receive(:
|
16
|
+
@shell.client.should_receive(:request).with("POST", { :op => "_simple" }, kind_of(Hash), "").and_return('{}')
|
17
17
|
@shell.eval_line("POST _simple")
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should recognize a request with an absolute path" do
|
21
|
-
@shell.client.should_receive(:
|
21
|
+
@shell.client.should_receive(:request).with("GET", { :op => "some/thing" }, kind_of(Hash), "").and_return('{}')
|
22
22
|
@shell.eval_line("/some/thing")
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should recognize a request with a query string" do
|
26
|
-
@shell.client.should_receive(:
|
26
|
+
@shell.client.should_receive(:request).with("GET", { :op => "_simple" }, {"foo" => "bar", "baz" => "booz what", :log => true}, "").and_return('{}')
|
27
27
|
@shell.eval_line("_simple?foo=bar&baz=booz+what")
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should recognize a request with an inline body" do
|
31
|
-
@shell.client.should_receive(:
|
31
|
+
@shell.client.should_receive(:request).with("POST", { :op => "_simple" }, kind_of(Hash), "{}").and_return('{}')
|
32
32
|
@shell.eval_line("POST _simple {}")
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should recognize a request with a body read from a local file" do
|
36
36
|
File.should_receive(:exist?).with("/some/file.json").and_return(true)
|
37
37
|
File.should_receive(:read).with("/some/file.json").and_return("{}")
|
38
|
-
@shell.client.should_receive(:
|
38
|
+
@shell.client.should_receive(:request).with("GET", { :op => "_simple" }, kind_of(Hash), "{}").and_return('{}')
|
39
39
|
@shell.eval_line("_simple /some/file.json")
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should recognize a request with a body read from STDIN" do
|
43
43
|
@shell.input_stream.stub!(:gets).and_return("{}")
|
44
|
-
@shell.client.should_receive(:
|
44
|
+
@shell.client.should_receive(:request).with("GET", { :op => "_simple" }, kind_of(Hash), "{}").and_return('{}')
|
45
45
|
@shell.eval_line("_simple -")
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should be able to pipe the output of a request to Ruby inline" do
|
49
|
-
@shell.client.should_receive(:
|
49
|
+
@shell.client.should_receive(:request).with("GET", { :op => "_simple" }, kind_of(Hash), "").and_return('{}')
|
50
50
|
@shell.eval_line("_simple | response")
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should be able to pipe the output of a request to a RIPL session" do
|
54
|
-
@shell.client.should_receive(:
|
54
|
+
@shell.client.should_receive(:request).with("GET", { :op => "_simple" }, kind_of(Hash), "").and_return('{}')
|
55
55
|
require 'ripl'
|
56
56
|
Ripl.should_receive(:start)
|
57
57
|
@shell.eval_line("_simple |")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticshell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -187,7 +187,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
187
187
|
version: '0'
|
188
188
|
segments:
|
189
189
|
- 0
|
190
|
-
hash:
|
190
|
+
hash: -3702363232636425021
|
191
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
192
|
none: false
|
193
193
|
requirements:
|