-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
53 lines (45 loc) · 1.29 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require 'bundler'
Bundler.require(:test)
require 'yaml'
require 'rubberband'
desc "Build elasticshell"
task :build do
system "gem build elasticshell.gemspec"
end
version = File.read(File.expand_path('../VERSION', __FILE__)).strip
desc "Release elasticshell-#{version}"
task :release => :build do
system "gem push elasticshell-#{version}.gem"
end
namespace :spec do
def client
@client ||= ElasticSearch.new("http://localhost:9200")
end
namespace :data do
def data
@data ||= YAML.load_file(File.join(File.dirname(__FILE__), 'spec/support/data.yml'))
end
desc "Empty data from local Elasticsearch database"
task :delete do
data.each_pair do |index_name, types|
client.delete_index(index_name)
end
end
desc "Load data into a local Elasticsearch"
task :load do
data.each_pair do |index_name, types|
types.each_pair do |type_name, records|
records.each_pair do |id, record|
if id == '_noid_'
record.each do |unsaved_record|
client.index(unsaved_record, :type => type_name, :index => index_name)
end
else
client.index(record, :id => id, :type => type_name, :index => index_name)
end
end
end
end
end
end
end