ies 0.1.0 → 0.1.1

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/exe/ies +49 -1
  4. data/lib/ies/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47c7c2d77f8ff8d07212bc60d773614d18764381
4
- data.tar.gz: 03517aff4a8736de60fdaa8b3249bf3b0de393dd
3
+ metadata.gz: 85f0467f2e1f8aea96e12bfa298a8d72a0ea7def
4
+ data.tar.gz: e22581b173471dbf3af9c76e2f95a0960bbc6a89
5
5
  SHA512:
6
- metadata.gz: 47bdab05321cb8b0de903e64383e9d31af114818230673af2861b1281b000f0019a48a94885fa805fef9b12d2f20e3c11c940bd74908fbb169677f8a63124b24
7
- data.tar.gz: 9aac88c88446e6ee30629d5c0a93f2bf88da5b8be067a750cbf9120bdb03edea954ff441f0003cd1c3597a507be4b516093c847b7360d21b7d95a89c5c8d0ee7
6
+ metadata.gz: a1f3954909be2e066a6f08fc958163057475c468d663d4b453807baf9bfe92ddbd387f4d65e55bdcbe1456a97a8779258cb38c98da0d7f9f68768e49eef5706b
7
+ data.tar.gz: edb5db150149cc27377c6b47accef750271ae7a715704147ec22b01c14297d04c4e450d577f52bb7b7c4b3bf787bf50b8be7d26b5949e5c9d1d860c165e6d154
data/README.md CHANGED
@@ -23,7 +23,7 @@ Or install it yourself as:
23
23
  You can access the REPL for Elasticsearch Ruby by running `ies` from the command line.
24
24
 
25
25
  ```rb
26
- $ ELASTICSEARCH_URL=localhost:9250 ies
26
+ $ ies
27
27
  ies> search index: 'index_name', q: 'keyword'
28
28
  ```
29
29
 
data/exe/ies CHANGED
@@ -8,5 +8,53 @@ require 'optparse'
8
8
  require 'elasticsearch'
9
9
  require 'pry'
10
10
 
11
+ options = {
12
+ url: nil,
13
+ log: false,
14
+ require: [],
15
+ execute: [],
16
+ }
17
+
18
+ OptionParser.new do |opts|
19
+ opts.banner = 'Usage: ies [options]'
20
+
21
+ opts.on("--url URL", "elasticsearch's URLs that are separated with comma. (Default: ENV['ELASTICSEARCH_URL])") do |value|
22
+ options[:url] = value
23
+ end
24
+
25
+ opts.on("-l", "--log", "log client requets. (Default: #{options[:log]})") do |value|
26
+ options[:log] = value
27
+ end
28
+
29
+ opts.on("-e COMMAND", "--execute COMMAND", "one line of script. Several -e's allowed.") do |value|
30
+ options[:execute] << value
31
+ end
32
+
33
+ opts.on("-r LIBRARY", "--require LIBRARY", "require the library") do |values|
34
+ options[:require] << values
35
+ end
36
+
37
+ opts.on("-h", "--help") do
38
+ puts opts
39
+ exit
40
+ end
41
+ end.parse!
42
+
43
+ options[:require].each do |library|
44
+ require library
45
+ end
46
+
47
+ client_opts = {}
48
+ client_opts[:log] = options[:log]
49
+ client_opts[:url] = options[:url] if options[:url]
50
+
51
+ client = Elasticsearch::Client.new(client_opts)
52
+
53
+ if !options[:execute].empty?
54
+ scripts = options[:execute].join("\n")
55
+ client.instance_eval(scripts)
56
+ exit
57
+ end
58
+
11
59
  Pry.config.prompt = [proc { "ies> " }, proc { "ies| " }]
12
- Elasticsearch::Client.new(log: true).pry
60
+ client.pry
@@ -1,3 +1,3 @@
1
1
  module Ies
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mizokami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-25 00:00:00.000000000 Z
11
+ date: 2016-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry