desi 0.4.0 → 0.5.0

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/.gitignore CHANGED
@@ -17,3 +17,4 @@ test/version_tmp
17
17
  tmp
18
18
  .rvmrc
19
19
  .rbenv*
20
+ tags
data/README.md CHANGED
@@ -144,9 +144,13 @@ will be spun up by (`desi start`)
144
144
 
145
145
  ## Change setting(s)
146
146
 
147
- Right now, there's actually only one setting to change: the installation
148
- directory. Desi will look for files `/etc/desi.yml` or `~/.desi.yml` and use
149
- the *directory* entry specified. The default directory is `~/elasticsearch`.
147
+ There are two settings at the moment: location of the installation directory
148
+ (`directory`, default: `~/elasticsearch`) and ES host address (`server`,
149
+ default: `localhost:9200`).
150
+
151
+ Desi will look for files `/etc/desi.yml` or `~/.desi.yml` (the options found in
152
+ the former will be overriden by the ones found in the latter).
153
+
150
154
 
151
155
  * command-line
152
156
 
@@ -157,6 +161,7 @@ the *directory* entry specified. The default directory is `~/elasticsearch`.
157
161
  ```ruby
158
162
  Desi.configure do |c|
159
163
  c.directory = "~/local/foo"
164
+ c.server = "192.168.1.42:9200"
160
165
  end
161
166
  ```
162
167
 
data/desi.gemspec CHANGED
@@ -21,6 +21,7 @@ an Elastic Search local install for development purposes.}
21
21
  gem.add_development_dependency "guard-yard"
22
22
  gem.add_development_dependency "redcarpet"
23
23
  gem.add_development_dependency "rb-inotify"
24
+ gem.add_development_dependency "pry"
24
25
 
25
26
  gem.files = `git ls-files`.split($\)
26
27
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -15,9 +15,10 @@ module Desi
15
15
  @directory = Pathname(File.expand_path(dir))
16
16
  end
17
17
 
18
+ attr_accessor :server
19
+
18
20
  def load_configuration!
19
- config = config_files_data
20
- config = defaults if config.empty?
21
+ config = defaults.merge(config_files_data)
21
22
 
22
23
  public_methods(false).select {|m| m.to_s =~ /=$/ }.each do |setter|
23
24
  attr_name = setter.to_s.tr('=', '')
@@ -57,7 +58,7 @@ module Desi
57
58
  end
58
59
 
59
60
  def defaults
60
- {'directory' => "~/elasticsearch"}
61
+ {'directory' => "~/elasticsearch", "server" => "localhost:9200"}
61
62
  end
62
63
 
63
64
  instance.load_configuration!
@@ -72,6 +73,7 @@ module Desi
72
73
  #
73
74
  # Desi.configure do |c|
74
75
  # c.directory = "~/es"
76
+ # c.server = "127.0.0.53:9200"
75
77
  # end
76
78
  #
77
79
  # @return [Desi::Configuration] the configuration
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require "desi/http_client"
4
+ require "desi/configuration"
4
5
 
5
6
  module Desi
6
7
 
@@ -33,7 +34,7 @@ module Desi
33
34
  #
34
35
  # @param [#to_hash] opts Hash of extra opts
35
36
  #
36
- # @option opts [#to_s] :host ('http://127.0.0.1:9200') Host to manage indices for
37
+ # @option opts [#to_s] :host ('http://localhost:9200') Host to manage indices for
37
38
  # @option opts [Boolean] :verbose (nil) Whether to output the actions' result
38
39
  # on STDOUT
39
40
  # @option opts [#new] :http_client_factory (Desi::HttpClient) HTTP transport class
@@ -45,7 +46,7 @@ module Desi
45
46
  #
46
47
  # @api public
47
48
  def initialize(opts = {})
48
- @host = to_uri(opts.fetch(:host, 'http://127.0.0.1:9200'))
49
+ @host = to_uri(opts.fetch(:host) { Desi.configuration.server })
49
50
  @verbose = opts[:verbose]
50
51
  @outputter = opts.fetch(:outputter, Kernel)
51
52
  @client = opts.fetch(:http_client_factory, Desi::HttpClient).new(@host)
@@ -137,7 +138,7 @@ module Desi
137
138
  end
138
139
 
139
140
  def to_uri(host_string)
140
- scheme, host, port = ['http', '127.0.0.1', 9200]
141
+ scheme, host, port = ['http', 'localhost', 9200]
141
142
 
142
143
  %r{(?<scheme>(https?|))(?:\:\/\/|)(?<host>[^:]*?):?(?<port>\d*)/?$}.match(host_string.to_s) do |m|
143
144
  scheme = m[:scheme] unless m[:scheme].empty?
@@ -5,6 +5,7 @@ require "desi/cocaine"
5
5
  require "ostruct"
6
6
  require "desi/http_client"
7
7
  require "desi/local_install"
8
+ require "desi/configuration"
8
9
 
9
10
  module Desi
10
11
 
@@ -23,7 +24,7 @@ module Desi
23
24
  class ProcessManager
24
25
 
25
26
  def initialize(opts = {})
26
- @host = opts.fetch(:host, 'http://127.0.0.1:9200')
27
+ @host = opts.fetch(:host) { Desi.configuration.server }
27
28
  @verbose = opts[:verbose]
28
29
  @foreground = opts[:foreground]
29
30
  @local_install = LocalInstall.new
data/lib/desi/runner.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'boson/runner'
4
+ require "desi/configuration"
4
5
 
5
6
  module Desi
6
7
  class Runner < Boson::Runner
@@ -84,7 +85,7 @@ module Desi
84
85
 
85
86
  desc "Show current status"
86
87
  verbosity_option
87
- option "--host", type: :string, desc: "Elastic Search cluster URL", default: '127.0.0.1:9200'
88
+ option "--host", type: :string, desc: "Elastic Search cluster URL", default: Desi.configuration.server
88
89
  def status(options = {})
89
90
  set_verbosity!(options)
90
91
  Desi::ProcessManager.new(options).status
@@ -92,7 +93,7 @@ module Desi
92
93
 
93
94
  desc "List indices"
94
95
  verbosity_option
95
- option "--host", type: :string, desc: "Elastic Search cluster URL", default: '127.0.0.1:9200'
96
+ option "--host", type: :string, desc: "Elastic Search cluster URL", default: Desi.configuration.server
96
97
  option "--delete", type: :boolean, desc: "Delete the specified indices (You've been warned!)", default: false
97
98
  option "--empty", type: :boolean, desc: "Delete all documents from the specified indices", default: false
98
99
  def indices(pattern = nil, options = {})
@@ -106,6 +107,10 @@ module Desi
106
107
  else
107
108
  index_manager.list(pattern)
108
109
  end
110
+
111
+ rescue Errno::ECONNREFUSED
112
+ warn "Server #{options[:host]} appears to be unavailable!"
113
+ exit 1
109
114
  end
110
115
 
111
116
  desc "Show tail output from Elastic Search's log file"
data/lib/desi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Desi
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: desi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
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: 2013-03-01 00:00:00.000000000 Z
12
+ date: 2013-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: boson
@@ -155,6 +155,22 @@ dependencies:
155
155
  - - ! '>='
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: pry
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
158
174
  description: ! 'Desi (Developper ElasticSearch Installer) is very simple tool to quickly
159
175
  set up
160
176
 
@@ -206,18 +222,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
222
  - - ! '>='
207
223
  - !ruby/object:Gem::Version
208
224
  version: '0'
209
- segments:
210
- - 0
211
- hash: 2218572512027312974
212
225
  required_rubygems_version: !ruby/object:Gem::Requirement
213
226
  none: false
214
227
  requirements:
215
228
  - - ! '>='
216
229
  - !ruby/object:Gem::Version
217
230
  version: '0'
218
- segments:
219
- - 0
220
- hash: 2218572512027312974
221
231
  requirements: []
222
232
  rubyforge_project:
223
233
  rubygems_version: 1.8.23