elasticshell 0.0.2 → 0.0.4
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/README.rdoc +119 -55
- data/VERSION +1 -1
- data/bin/es +0 -2
- data/lib/elasticshell.rb +30 -25
- data/lib/elasticshell/client.rb +34 -13
- data/lib/elasticshell/command.rb +14 -170
- data/lib/elasticshell/commands/blank.rb +14 -0
- data/lib/elasticshell/commands/cd.rb +27 -0
- data/lib/elasticshell/commands/connect.rb +31 -0
- data/lib/elasticshell/commands/df.rb +23 -0
- data/lib/elasticshell/commands/help.rb +77 -0
- data/lib/elasticshell/commands/ls.rb +66 -0
- data/lib/elasticshell/commands/pretty.rb +21 -0
- data/lib/elasticshell/commands/pwd.rb +17 -0
- data/lib/elasticshell/commands/request.rb +81 -0
- data/lib/elasticshell/commands/request_parser.rb +77 -0
- data/lib/elasticshell/commands/set_verb.rb +23 -0
- data/lib/elasticshell/commands/unknown.rb +17 -0
- data/lib/elasticshell/scopes.rb +81 -50
- data/lib/elasticshell/scopes/cluster.rb +8 -16
- data/lib/elasticshell/scopes/global.rb +22 -23
- data/lib/elasticshell/scopes/index.rb +35 -29
- data/lib/elasticshell/scopes/mapping.rb +8 -28
- data/lib/elasticshell/scopes/nodes.rb +6 -15
- data/lib/elasticshell/shell.rb +155 -93
- data/lib/elasticshell/utils.rb +10 -0
- data/lib/elasticshell/{error.rb → utils/error.rb} +1 -0
- data/lib/elasticshell/utils/has_name.rb +14 -0
- data/lib/elasticshell/utils/has_verb.rb +15 -0
- data/lib/elasticshell/{log.rb → utils/log.rb} +1 -1
- data/lib/elasticshell/utils/recognizes_verb.rb +25 -0
- data/spec/elasticshell/client_spec.rb +55 -0
- data/spec/elasticshell/commands/blank_spec.rb +14 -0
- data/spec/elasticshell/commands/cd_spec.rb +23 -0
- data/spec/elasticshell/commands/connect_spec.rb +21 -0
- data/spec/elasticshell/commands/df_spec.rb +18 -0
- data/spec/elasticshell/commands/help_spec.rb +21 -0
- data/spec/elasticshell/commands/ls_spec.rb +24 -0
- data/spec/elasticshell/commands/pretty_spec.rb +19 -0
- data/spec/elasticshell/commands/pwd_spec.rb +14 -0
- data/spec/elasticshell/commands/request_parser_spec.rb +4 -0
- data/spec/elasticshell/commands/request_spec.rb +60 -0
- data/spec/elasticshell/commands/set_verb_spec.rb +14 -0
- data/spec/elasticshell/scopes_spec.rb +79 -0
- data/spec/elasticshell/shell_spec.rb +19 -0
- data/spec/elasticshell/utils/has_name_spec.rb +15 -0
- data/spec/elasticshell/utils/has_verb_spec.rb +24 -0
- data/spec/elasticshell/utils/recognizes_verb_spec.rb +23 -0
- data/spec/spec_helper.rb +4 -5
- data/spec/support/data.yml +45 -0
- data/spec/support/fake_output.rb +27 -0
- metadata +73 -4
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RecognizesVerb do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@obj = Class.new { include RecognizesVerb }.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "can recognize an HTTP verb" do
|
10
|
+
expect(@obj.is_http_verb?("GET")).to be_true
|
11
|
+
expect(@obj.is_http_verb?("get")).to be_true
|
12
|
+
expect(@obj.is_http_verb?("HEAD")).to be_true
|
13
|
+
expect(@obj.is_http_verb?("POST")).to be_true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can canonicalize HTTP verbs" do
|
17
|
+
expect(@obj.canonicalize_verb("get")).to eq("GET")
|
18
|
+
expect(@obj.canonicalize_verb("gEt")).to eq("GET")
|
19
|
+
expect(@obj.canonicalize_verb(:get)).to eq("GET")
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
|
3
|
-
ELASTICSHELL_ROOT = File.expand_path(__FILE__, '../../lib')
|
3
|
+
ELASTICSHELL_ROOT = File.expand_path(__FILE__, '../../lib') unless defined?(ELASTICSHELL_ROOT)
|
4
4
|
$: << ELASTICSHELL_ROOT unless $:.include?(ELASTICSHELL_ROOT)
|
5
5
|
require 'elasticshell'
|
6
|
+
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |path| require path }
|
6
7
|
include Elasticshell
|
8
|
+
include Elasticshell::Spec
|
9
|
+
|
7
10
|
|
8
|
-
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |path| require path }
|
9
11
|
|
10
|
-
RSpec.configure do |config|
|
11
|
-
config.mock_with :rspec
|
12
|
-
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
|
3
|
+
blog:
|
4
|
+
entries:
|
5
|
+
1:
|
6
|
+
title: Do you suffer from headaches?
|
7
|
+
date: "2012-10-15 Mon 17:37"
|
8
|
+
tags:
|
9
|
+
- stress
|
10
|
+
- headaches
|
11
|
+
- quackery
|
12
|
+
body: |-
|
13
|
+
Then you should really think about investing in a better pillow.
|
14
|
+
|
15
|
+
2:
|
16
|
+
title: My favorite color is lobster.
|
17
|
+
date: "2012-10-16 Tue 17:37"
|
18
|
+
tags:
|
19
|
+
- inane
|
20
|
+
- silly
|
21
|
+
body: |-
|
22
|
+
I don't even think 'lobster' is a color.
|
23
|
+
_noid_:
|
24
|
+
- title: I am not saved.
|
25
|
+
date: "2012-10-17 Wed 17:37"
|
26
|
+
tags:
|
27
|
+
- acid
|
28
|
+
- rest
|
29
|
+
body: |-
|
30
|
+
Wouldn't ACID REST be a cool name for a band? Or a skin disease?
|
31
|
+
|
32
|
+
comments:
|
33
|
+
1:
|
34
|
+
post_id: 2
|
35
|
+
date: "2012-10-18 Thr 17:37"
|
36
|
+
author: Some Jackass
|
37
|
+
body: |
|
38
|
+
Have you seen *my* blog? It's super cool.
|
39
|
+
|
40
|
+
2:
|
41
|
+
post_id: 1
|
42
|
+
date: "2012-10-19 Fri 17:37"
|
43
|
+
author: Your Mom
|
44
|
+
body: |
|
45
|
+
You never calll!
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Elasticshell
|
2
|
+
module Spec
|
3
|
+
class FakeOutput
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@buffer = ''
|
7
|
+
end
|
8
|
+
|
9
|
+
def write s
|
10
|
+
@buffer += s
|
11
|
+
end
|
12
|
+
|
13
|
+
def puts s
|
14
|
+
write(s + "\n")
|
15
|
+
end
|
16
|
+
|
17
|
+
def read
|
18
|
+
@buffer
|
19
|
+
end
|
20
|
+
|
21
|
+
def gets arg
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
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.4
|
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-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: ZenTest
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: json
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,6 +91,22 @@ dependencies:
|
|
75
91
|
- - ! '>='
|
76
92
|
- !ruby/object:Gem::Version
|
77
93
|
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: ripl
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
78
110
|
description: Elasticshell provides a command-line shell 'es' for connecting to and
|
79
111
|
querying an Elasticsearch database. The shell will tab-complete Elasticsearch API
|
80
112
|
commands and index/mapping names.
|
@@ -86,21 +118,55 @@ extensions: []
|
|
86
118
|
extra_rdoc_files: []
|
87
119
|
files:
|
88
120
|
- bin/es
|
121
|
+
- lib/elasticshell/utils.rb
|
89
122
|
- lib/elasticshell/scopes/cluster.rb
|
90
123
|
- lib/elasticshell/scopes/mapping.rb
|
91
124
|
- lib/elasticshell/scopes/global.rb
|
92
125
|
- lib/elasticshell/scopes/index.rb
|
93
126
|
- lib/elasticshell/scopes/nodes.rb
|
127
|
+
- lib/elasticshell/commands/help.rb
|
128
|
+
- lib/elasticshell/commands/connect.rb
|
129
|
+
- lib/elasticshell/commands/pretty.rb
|
130
|
+
- lib/elasticshell/commands/pwd.rb
|
131
|
+
- lib/elasticshell/commands/unknown.rb
|
132
|
+
- lib/elasticshell/commands/request_parser.rb
|
133
|
+
- lib/elasticshell/commands/cd.rb
|
134
|
+
- lib/elasticshell/commands/set_verb.rb
|
135
|
+
- lib/elasticshell/commands/df.rb
|
136
|
+
- lib/elasticshell/commands/request.rb
|
137
|
+
- lib/elasticshell/commands/blank.rb
|
138
|
+
- lib/elasticshell/commands/ls.rb
|
94
139
|
- lib/elasticshell/command.rb
|
95
|
-
- lib/elasticshell/log.rb
|
96
140
|
- lib/elasticshell/shell.rb
|
97
141
|
- lib/elasticshell/client.rb
|
98
|
-
- lib/elasticshell/error.rb
|
99
142
|
- lib/elasticshell/scopes.rb
|
143
|
+
- lib/elasticshell/utils/log.rb
|
144
|
+
- lib/elasticshell/utils/recognizes_verb.rb
|
145
|
+
- lib/elasticshell/utils/has_name.rb
|
146
|
+
- lib/elasticshell/utils/has_verb.rb
|
147
|
+
- lib/elasticshell/utils/error.rb
|
100
148
|
- lib/elasticshell.rb
|
101
149
|
- spec/elasticshell/scopes_spec.rb
|
150
|
+
- spec/elasticshell/commands/request_spec.rb
|
151
|
+
- spec/elasticshell/commands/blank_spec.rb
|
152
|
+
- spec/elasticshell/commands/cd_spec.rb
|
153
|
+
- spec/elasticshell/commands/connect_spec.rb
|
154
|
+
- spec/elasticshell/commands/ls_spec.rb
|
155
|
+
- spec/elasticshell/commands/pretty_spec.rb
|
156
|
+
- spec/elasticshell/commands/request_parser_spec.rb
|
157
|
+
- spec/elasticshell/commands/help_spec.rb
|
158
|
+
- spec/elasticshell/commands/df_spec.rb
|
159
|
+
- spec/elasticshell/commands/set_verb_spec.rb
|
160
|
+
- spec/elasticshell/commands/pwd_spec.rb
|
102
161
|
- spec/elasticshell/command_spec.rb
|
162
|
+
- spec/elasticshell/client_spec.rb
|
163
|
+
- spec/elasticshell/shell_spec.rb
|
164
|
+
- spec/elasticshell/utils/recognizes_verb_spec.rb
|
165
|
+
- spec/elasticshell/utils/has_name_spec.rb
|
166
|
+
- spec/elasticshell/utils/has_verb_spec.rb
|
103
167
|
- spec/spec_helper.rb
|
168
|
+
- spec/support/fake_output.rb
|
169
|
+
- spec/support/data.yml
|
104
170
|
- LICENSE
|
105
171
|
- README.rdoc
|
106
172
|
- VERSION
|
@@ -116,6 +182,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
182
|
- - ! '>='
|
117
183
|
- !ruby/object:Gem::Version
|
118
184
|
version: '0'
|
185
|
+
segments:
|
186
|
+
- 0
|
187
|
+
hash: -2162304866060905026
|
119
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
189
|
none: false
|
121
190
|
requirements:
|