desi 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +20 -1
- data/lib/desi/configuration.rb +87 -0
- data/lib/desi/local_install.rb +1 -2
- data/lib/desi/runner.rb +1 -1
- data/lib/desi/version.rb +1 -1
- data/lib/desi.rb +1 -0
- metadata +3 -8
data/README.md
CHANGED
@@ -55,7 +55,7 @@ will be spun up by (`desi start`)
|
|
55
55
|
|
56
56
|
```shell
|
57
57
|
$ desi list
|
58
|
-
Local ES installs (current one is tagged with '*'):
|
58
|
+
Local ES installs in /home/me/elasticsearch (current one is tagged with '*'):
|
59
59
|
* elasticsearch-0.19.9 (/home/me/elasticsearch/elasticsearch-0.19.9)
|
60
60
|
- elasticsearch-0.19.8 (/home/me/elasticsearch/elasticsearch-0.19.8)
|
61
61
|
```
|
@@ -135,6 +135,25 @@ will be spun up by (`desi start`)
|
|
135
135
|
```
|
136
136
|
|
137
137
|
|
138
|
+
## Change setting(s)
|
139
|
+
|
140
|
+
Right now, there's actually only one setting to change: the installation
|
141
|
+
directory. Desi will look for files `/etc/desi.yml` or `~/.desi.yml` and use
|
142
|
+
the *directory* entry specified. The default directory is `~/elasticsearch`.
|
143
|
+
|
144
|
+
* command-line
|
145
|
+
|
146
|
+
`echo -e "---\n directory: ~/foobar" > ~/.desi.yml` for instance
|
147
|
+
|
148
|
+
* library
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
Desi.configure do |c|
|
152
|
+
c.directory = "~/local/foo"
|
153
|
+
end
|
154
|
+
```
|
155
|
+
|
156
|
+
|
138
157
|
|
139
158
|
## Installation
|
140
159
|
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "singleton"
|
4
|
+
require "yaml"
|
5
|
+
require "pathname"
|
6
|
+
|
7
|
+
module Desi
|
8
|
+
|
9
|
+
class Configuration
|
10
|
+
include Singleton
|
11
|
+
|
12
|
+
attr_reader :directory
|
13
|
+
|
14
|
+
def directory=(dir)
|
15
|
+
@directory = Pathname(File.expand_path(dir))
|
16
|
+
end
|
17
|
+
|
18
|
+
def load_configuration!
|
19
|
+
config = config_files_data
|
20
|
+
config = defaults if config.empty?
|
21
|
+
|
22
|
+
public_methods(false).select {|m| m.to_s =~ /=$/ }.each do |setter|
|
23
|
+
attr_name = setter.to_s.tr('=', '')
|
24
|
+
|
25
|
+
if config.has_key?(attr_name)
|
26
|
+
send(setter, config[attr_name])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def config_files
|
36
|
+
%w[/etc/desi.yml ~/.desi.yml]
|
37
|
+
end
|
38
|
+
|
39
|
+
def config_files_data
|
40
|
+
config_files.each_with_object({}) do |filename, hash|
|
41
|
+
hash.merge! config_file_data(filename)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def config_file_data(filename)
|
46
|
+
file = File.expand_path(filename)
|
47
|
+
return {} unless File.exists?(file)
|
48
|
+
|
49
|
+
data = YAML.load_file(file)
|
50
|
+
|
51
|
+
if data.is_a? Hash
|
52
|
+
data
|
53
|
+
else
|
54
|
+
warn "Configuration file #{filename} contains malformed data and will be ignored"
|
55
|
+
{}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def defaults
|
60
|
+
{'directory' => "~/elasticsearch"}
|
61
|
+
end
|
62
|
+
|
63
|
+
instance.load_configuration!
|
64
|
+
end # Configuration
|
65
|
+
|
66
|
+
module_function
|
67
|
+
|
68
|
+
|
69
|
+
# Change configuration settings
|
70
|
+
#
|
71
|
+
# @example
|
72
|
+
#
|
73
|
+
# Desi.configure do |c|
|
74
|
+
# c.directory = "~/es"
|
75
|
+
# end
|
76
|
+
#
|
77
|
+
# @return [Desi::Configuration] the configuration
|
78
|
+
def configure(&block)
|
79
|
+
yield configuration
|
80
|
+
configuration
|
81
|
+
end
|
82
|
+
|
83
|
+
def configuration
|
84
|
+
Configuration.instance
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
data/lib/desi/local_install.rb
CHANGED
@@ -4,7 +4,6 @@ require "pathname"
|
|
4
4
|
|
5
5
|
module Desi
|
6
6
|
class LocalInstall
|
7
|
-
DEFAULT_DIR = '~/elasticsearch'
|
8
7
|
|
9
8
|
class Release
|
10
9
|
def self.all_in(workdir)
|
@@ -53,7 +52,7 @@ module Desi
|
|
53
52
|
|
54
53
|
def initialize(workdir = nil, opts = {})
|
55
54
|
@verbose = opts[:verbose]
|
56
|
-
@workdir = Pathname(File.expand_path(workdir ||
|
55
|
+
@workdir = Pathname(File.expand_path(workdir || Desi.configuration.directory))
|
57
56
|
create!
|
58
57
|
end
|
59
58
|
|
data/lib/desi/runner.rb
CHANGED
@@ -13,7 +13,7 @@ module Desi
|
|
13
13
|
desc "List locally installed Elastic Search releases"
|
14
14
|
verbosity_option
|
15
15
|
def list(options = {})
|
16
|
-
puts "Local ES installs (current one is tagged with '*'):" unless quiet?(options)
|
16
|
+
puts "Local ES installs in #{Desi.configuration.directory} (current one is tagged with '*'):" unless quiet?(options)
|
17
17
|
Desi::LocalInstall.new.releases.sort.reverse.each do |v|
|
18
18
|
puts v
|
19
19
|
end
|
data/lib/desi/version.rb
CHANGED
data/lib/desi.rb
CHANGED
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
|
+
version: 0.3.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-
|
12
|
+
date: 2013-02-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: boson
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- desi.gemspec
|
181
181
|
- lib/desi.rb
|
182
182
|
- lib/desi/cocaine.rb
|
183
|
+
- lib/desi/configuration.rb
|
183
184
|
- lib/desi/downloader.rb
|
184
185
|
- lib/desi/http_client.rb
|
185
186
|
- lib/desi/index_manager.rb
|
@@ -205,18 +206,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
206
|
- - ! '>='
|
206
207
|
- !ruby/object:Gem::Version
|
207
208
|
version: '0'
|
208
|
-
segments:
|
209
|
-
- 0
|
210
|
-
hash: -3536869085604684472
|
211
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
210
|
none: false
|
213
211
|
requirements:
|
214
212
|
- - ! '>='
|
215
213
|
- !ruby/object:Gem::Version
|
216
214
|
version: '0'
|
217
|
-
segments:
|
218
|
-
- 0
|
219
|
-
hash: -3536869085604684472
|
220
215
|
requirements: []
|
221
216
|
rubyforge_project:
|
222
217
|
rubygems_version: 1.8.23
|