desi 0.2.7 → 0.2.8
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 +1 -0
- data/lib/desi/downloader.rb +3 -3
- data/lib/desi/http_client.rb +1 -1
- data/lib/desi/index_manager.rb +26 -5
- data/lib/desi/runner.rb +1 -1
- data/lib/desi/upstream.rb +20 -11
- data/lib/desi/version.rb +1 -1
- data/spec/desi/index_manager_spec.rb +2 -2
- metadata +5 -5
data/.gitignore
CHANGED
data/lib/desi/downloader.rb
CHANGED
@@ -10,14 +10,14 @@ module Desi
|
|
10
10
|
|
11
11
|
def initialize(opts = {})
|
12
12
|
@destination_dir = Pathname(opts.fetch(:destination_dir, Desi::LocalInstall.new))
|
13
|
-
@host = URI(opts.fetch(:host, '
|
13
|
+
@host = URI(opts.fetch(:host, 'https://nodeload.github.com/'))
|
14
14
|
@client = opts.fetch(:http_client_factory, Desi::HttpClient).new(@host)
|
15
15
|
@verbose = opts[:verbose]
|
16
16
|
end
|
17
17
|
|
18
18
|
def download!(version, opts = {})
|
19
|
-
path = "/
|
20
|
-
destination_name = @destination_dir.join File.basename(version.
|
19
|
+
path = "/elasticsearch/elasticsearch/tar.gz/#{version.version_name}"
|
20
|
+
destination_name = @destination_dir.join File.basename(version.filename)
|
21
21
|
|
22
22
|
raise "ERROR: File #{destination_name} already present!" if destination_name.exist?
|
23
23
|
|
data/lib/desi/http_client.rb
CHANGED
data/lib/desi/index_manager.rb
CHANGED
@@ -8,6 +8,27 @@ module Desi
|
|
8
8
|
# Elastic Search cluster
|
9
9
|
class IndexManager
|
10
10
|
|
11
|
+
class Index
|
12
|
+
attr_reader :name, :number_of_documents
|
13
|
+
|
14
|
+
def initialize(name, data)
|
15
|
+
@name = name
|
16
|
+
@number_of_documents = data["docs"]["num_docs"] if data && data["docs"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
@name
|
21
|
+
end
|
22
|
+
|
23
|
+
def inspect
|
24
|
+
"#{@name} (#{@number_of_documents} documents)"
|
25
|
+
end
|
26
|
+
|
27
|
+
def <=>(other)
|
28
|
+
@name <=> other.name
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
11
32
|
# Initializes a Desi::IndexManager instance
|
12
33
|
#
|
13
34
|
# @param [#to_hash] opts Hash of extra opts
|
@@ -53,7 +74,7 @@ module Desi
|
|
53
74
|
@outputter.puts "Indices from host #{@host} matching the pattern #{pattern.inspect}\n\n" if @verbose
|
54
75
|
|
55
76
|
list = indices(pattern).sort
|
56
|
-
list.each {|i| @outputter.puts i } if @verbose
|
77
|
+
list.each {|i| @outputter.puts i.inspect } if @verbose
|
57
78
|
list
|
58
79
|
end
|
59
80
|
|
@@ -78,7 +99,7 @@ module Desi
|
|
78
99
|
|
79
100
|
indices(Regexp.new(pattern)).each do |index|
|
80
101
|
@client.delete("/#{index}")
|
81
|
-
@outputter.puts " * #{index}" if @verbose
|
102
|
+
@outputter.puts " * #{index.inspect}" if @verbose
|
82
103
|
end
|
83
104
|
end
|
84
105
|
|
@@ -110,9 +131,9 @@ module Desi
|
|
110
131
|
private
|
111
132
|
|
112
133
|
def indices(pattern)
|
113
|
-
JSON.parse(@client.get('/_status').body)["indices"].
|
114
|
-
|
115
|
-
}
|
134
|
+
JSON.parse(@client.get('/_status').body)["indices"].map {|k, v|
|
135
|
+
Index.new(k, v) if k =~ pattern
|
136
|
+
}.compact
|
116
137
|
end
|
117
138
|
|
118
139
|
def to_uri(host_string)
|
data/lib/desi/runner.rb
CHANGED
data/lib/desi/upstream.rb
CHANGED
@@ -6,17 +6,17 @@ require "json"
|
|
6
6
|
module Desi
|
7
7
|
class Upstream
|
8
8
|
|
9
|
-
class Release < Struct.new(:
|
9
|
+
class Release < Struct.new(:version_name, :download_url)
|
10
10
|
def to_s
|
11
|
-
|
11
|
+
name
|
12
12
|
end
|
13
13
|
|
14
14
|
def name
|
15
|
-
|
15
|
+
"elasticsearch-#{version}"
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
18
|
+
def filename
|
19
|
+
"elasticsearch-#{version}.tar.gz"
|
20
20
|
end
|
21
21
|
|
22
22
|
def ===(name_or_version)
|
@@ -24,7 +24,17 @@ module Desi
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def <=>(other)
|
27
|
-
other.
|
27
|
+
other.sortable_version <=> sortable_version
|
28
|
+
end
|
29
|
+
|
30
|
+
def version
|
31
|
+
version_name.gsub(/^v/, '')
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def sortable_version
|
37
|
+
version_name.split('.').map {|c| c.to_i }
|
28
38
|
end
|
29
39
|
end
|
30
40
|
|
@@ -33,9 +43,8 @@ module Desi
|
|
33
43
|
end
|
34
44
|
|
35
45
|
def releases
|
36
|
-
@releases ||=
|
37
|
-
|
38
|
-
map {|v| Release.new(v['name'], v['description'], v['created_at'], v['html_url']) }.
|
46
|
+
@releases ||= fetch_tags.
|
47
|
+
map {|v| Release.new(v['name'], v['tarball_url']) }.
|
39
48
|
sort
|
40
49
|
end
|
41
50
|
|
@@ -49,8 +58,8 @@ module Desi
|
|
49
58
|
|
50
59
|
private
|
51
60
|
|
52
|
-
def
|
53
|
-
JSON.parse @client.get('/repos/elasticsearch/elasticsearch/
|
61
|
+
def fetch_tags
|
62
|
+
JSON.parse @client.get('/repos/elasticsearch/elasticsearch/tags').body
|
54
63
|
end
|
55
64
|
|
56
65
|
end
|
data/lib/desi/version.rb
CHANGED
@@ -28,13 +28,13 @@ describe Desi::IndexManager do
|
|
28
28
|
describe "#list" do
|
29
29
|
context "with no specified pattern" do
|
30
30
|
it "returns the names of all indices" do
|
31
|
-
subject.list.should == %w[bar foo]
|
31
|
+
subject.list.map(&:name).should == %w[bar foo]
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
context "with a pattern" do
|
36
36
|
it "returns the matching indices" do
|
37
|
-
subject.list('oo').should == %w[foo]
|
37
|
+
subject.list('oo').map(&:name).should == %w[foo]
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
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.2.
|
4
|
+
version: 0.2.8
|
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:
|
12
|
+
date: 2013-01-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: boson
|
@@ -207,7 +207,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
207
207
|
version: '0'
|
208
208
|
segments:
|
209
209
|
- 0
|
210
|
-
hash:
|
210
|
+
hash: 4007543491113843537
|
211
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
212
|
none: false
|
213
213
|
requirements:
|
@@ -216,10 +216,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
216
|
version: '0'
|
217
217
|
segments:
|
218
218
|
- 0
|
219
|
-
hash:
|
219
|
+
hash: 4007543491113843537
|
220
220
|
requirements: []
|
221
221
|
rubyforge_project:
|
222
|
-
rubygems_version: 1.8.
|
222
|
+
rubygems_version: 1.8.23
|
223
223
|
signing_key:
|
224
224
|
specification_version: 3
|
225
225
|
summary: A developer tool to quickly set up an Elastic Search local install.
|