elastics-client 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.md +28 -0
- data/VERSION +1 -0
- data/elastics-client.gemspec +33 -0
- data/lib/elastics.rb +108 -0
- data/lib/elastics/api_stubs.rb +1268 -0
- data/lib/elastics/api_templates/cluster_api.yml +94 -0
- data/lib/elastics/api_templates/core_api.yml +202 -0
- data/lib/elastics/api_templates/indices_api.yml +304 -0
- data/lib/elastics/class_proxy/base.rb +29 -0
- data/lib/elastics/class_proxy/templates.rb +97 -0
- data/lib/elastics/class_proxy/templates/doc.rb +91 -0
- data/lib/elastics/class_proxy/templates/search.rb +72 -0
- data/lib/elastics/configuration.rb +25 -0
- data/lib/elastics/deprecation.rb +153 -0
- data/lib/elastics/errors.rb +43 -0
- data/lib/elastics/http_clients/base.rb +15 -0
- data/lib/elastics/http_clients/loader.rb +51 -0
- data/lib/elastics/http_clients/patron.rb +29 -0
- data/lib/elastics/http_clients/rest_client.rb +36 -0
- data/lib/elastics/logger.rb +37 -0
- data/lib/elastics/prog_bar.rb +39 -0
- data/lib/elastics/rails.rb +1 -0
- data/lib/elastics/result.rb +24 -0
- data/lib/elastics/result/bulk.rb +20 -0
- data/lib/elastics/result/document.rb +67 -0
- data/lib/elastics/result/multi_get.rb +24 -0
- data/lib/elastics/result/search.rb +28 -0
- data/lib/elastics/struct/array.rb +25 -0
- data/lib/elastics/struct/hash.rb +105 -0
- data/lib/elastics/struct/paginable.rb +58 -0
- data/lib/elastics/struct/prunable.rb +60 -0
- data/lib/elastics/struct/symbolize.rb +27 -0
- data/lib/elastics/tasks.rb +62 -0
- data/lib/elastics/template.rb +124 -0
- data/lib/elastics/template/common.rb +42 -0
- data/lib/elastics/template/logger.rb +66 -0
- data/lib/elastics/template/partial.rb +28 -0
- data/lib/elastics/template/search.rb +30 -0
- data/lib/elastics/template/slim_search.rb +13 -0
- data/lib/elastics/template/tags.rb +56 -0
- data/lib/elastics/templates.rb +20 -0
- data/lib/elastics/utility_methods.rb +131 -0
- data/lib/elastics/utils.rb +103 -0
- data/lib/elastics/variables.rb +62 -0
- data/lib/tasks.rake +28 -0
- metadata +148 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
module Elastics
|
2
|
+
class Variables < Struct::Hash
|
3
|
+
|
4
|
+
def initialize(*hashes)
|
5
|
+
deep_merge! super(), *hashes
|
6
|
+
end
|
7
|
+
|
8
|
+
def finalize
|
9
|
+
self[:index] = self[:index].uniq.join(',') if self[:index].is_a?(Array)
|
10
|
+
self[:type] = self[:type].uniq.join(',') if self[:type].is_a?(Array)
|
11
|
+
# so you can pass :fields => [:field_one, :field_two]
|
12
|
+
self[:params!].each{|k,v| self[:params][k] = v.uniq.join(',') if v.is_a?(Array)}
|
13
|
+
if self[:page]
|
14
|
+
self[:page] = self[:page].to_i
|
15
|
+
self[:page] = 1 unless self[:page] > 0
|
16
|
+
self[:params][:from] ||= ((self[:page] - 1) * (self[:params][:size] || 10)).ceil unless self[:page] == 1
|
17
|
+
else
|
18
|
+
self[:page] = 1
|
19
|
+
end
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
# returns Prunable::Value if the value is in VALUES (called from stringified)
|
24
|
+
def get_prunable(key)
|
25
|
+
val = fetch_nested(key)
|
26
|
+
return val if self[:no_pruning].include?(key)
|
27
|
+
Prunable::VALUES.include?(val) ? Prunable::Value : val
|
28
|
+
end
|
29
|
+
|
30
|
+
# allows to store keys like 'a.3.c' into vars[:a][3][:c]
|
31
|
+
def store_nested(key, value)
|
32
|
+
var = unnest(key).reverse.inject(value) do |memo,k|
|
33
|
+
if k.is_a?(Symbol)
|
34
|
+
{k => memo}
|
35
|
+
else
|
36
|
+
ar = []
|
37
|
+
ar[k] = memo
|
38
|
+
ar
|
39
|
+
end
|
40
|
+
end
|
41
|
+
deep_merge! var
|
42
|
+
end
|
43
|
+
|
44
|
+
# allows to fetch values for tag names like 'a.3.c' fetching vars[:a][3][:c]
|
45
|
+
def fetch_nested(key)
|
46
|
+
unnest(key).inject(self, :fetch)
|
47
|
+
rescue NoMethodError, KeyError
|
48
|
+
raise MissingVariableError, "the required #{key.inspect} variable is missing."
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def unnest(key)
|
54
|
+
key.to_s.split('.').map{|s| s =~ /^\d+$/ ? s.to_i : s.to_sym}
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
# shorter alias
|
59
|
+
Vars = Variables
|
60
|
+
end
|
61
|
+
|
62
|
+
|
data/lib/tasks.rake
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'elastics'
|
2
|
+
|
3
|
+
env = defined?(Rails) ? :environment : []
|
4
|
+
|
5
|
+
namespace :'elastics-client' do
|
6
|
+
|
7
|
+
# deprecated tasks
|
8
|
+
task(:create_indices => env) do
|
9
|
+
Elastics::Deprecation.warn 'flex:create_indices', 'elastics:index:create', nil
|
10
|
+
Elastics::Tasks.new.create_indices
|
11
|
+
end
|
12
|
+
task(:delete_indices => env) do
|
13
|
+
Elastics::Deprecation.warn 'flex:delete_indices', 'elastics:index:delete', nil
|
14
|
+
Elastics::Tasks.new.delete_indices
|
15
|
+
end
|
16
|
+
|
17
|
+
namespace :index do
|
18
|
+
|
19
|
+
desc 'creates index/indices from the Elastics::Configuration.config_file file'
|
20
|
+
task(:create => env) { Elastics::Tasks.new.create_indices }
|
21
|
+
|
22
|
+
desc 'destroys index/indices in the Elastics::Configuration.config_file file'
|
23
|
+
task(:delete => env) { Elastics::Tasks.new.delete_indices }
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: elastics-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Domizio Demichelis
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-08-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: multi_json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.3.4
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.3.4
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: progressbar
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.11.0
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.12.0
|
41
|
+
type: :runtime
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.11.0
|
49
|
+
- - ~>
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 0.12.0
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: dye
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.1.4
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.1.4
|
68
|
+
description: Core gem used by all the elastics gems.
|
69
|
+
email: dd.nexus@gmail.com
|
70
|
+
executables: []
|
71
|
+
extensions: []
|
72
|
+
extra_rdoc_files: []
|
73
|
+
files:
|
74
|
+
- LICENSE
|
75
|
+
- README.md
|
76
|
+
- VERSION
|
77
|
+
- elastics-client.gemspec
|
78
|
+
- lib/elastics.rb
|
79
|
+
- lib/elastics/api_stubs.rb
|
80
|
+
- lib/elastics/api_templates/cluster_api.yml
|
81
|
+
- lib/elastics/api_templates/core_api.yml
|
82
|
+
- lib/elastics/api_templates/indices_api.yml
|
83
|
+
- lib/elastics/class_proxy/base.rb
|
84
|
+
- lib/elastics/class_proxy/templates.rb
|
85
|
+
- lib/elastics/class_proxy/templates/doc.rb
|
86
|
+
- lib/elastics/class_proxy/templates/search.rb
|
87
|
+
- lib/elastics/configuration.rb
|
88
|
+
- lib/elastics/deprecation.rb
|
89
|
+
- lib/elastics/errors.rb
|
90
|
+
- lib/elastics/http_clients/base.rb
|
91
|
+
- lib/elastics/http_clients/loader.rb
|
92
|
+
- lib/elastics/http_clients/patron.rb
|
93
|
+
- lib/elastics/http_clients/rest_client.rb
|
94
|
+
- lib/elastics/logger.rb
|
95
|
+
- lib/elastics/prog_bar.rb
|
96
|
+
- lib/elastics/rails.rb
|
97
|
+
- lib/elastics/result.rb
|
98
|
+
- lib/elastics/result/bulk.rb
|
99
|
+
- lib/elastics/result/document.rb
|
100
|
+
- lib/elastics/result/multi_get.rb
|
101
|
+
- lib/elastics/result/search.rb
|
102
|
+
- lib/elastics/struct/array.rb
|
103
|
+
- lib/elastics/struct/hash.rb
|
104
|
+
- lib/elastics/struct/paginable.rb
|
105
|
+
- lib/elastics/struct/prunable.rb
|
106
|
+
- lib/elastics/struct/symbolize.rb
|
107
|
+
- lib/elastics/tasks.rb
|
108
|
+
- lib/elastics/template.rb
|
109
|
+
- lib/elastics/template/common.rb
|
110
|
+
- lib/elastics/template/logger.rb
|
111
|
+
- lib/elastics/template/partial.rb
|
112
|
+
- lib/elastics/template/search.rb
|
113
|
+
- lib/elastics/template/slim_search.rb
|
114
|
+
- lib/elastics/template/tags.rb
|
115
|
+
- lib/elastics/templates.rb
|
116
|
+
- lib/elastics/utility_methods.rb
|
117
|
+
- lib/elastics/utils.rb
|
118
|
+
- lib/elastics/variables.rb
|
119
|
+
- lib/tasks.rake
|
120
|
+
homepage: http://elastics.github.io/elastics
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
post_install_message: ! "________________________________________________________________________________\n\n
|
124
|
+
\ ELASTICS INSTALLATION NOTES\n________________________________________________________________________________\n\nNew
|
125
|
+
Documentation: http://elastics.github.io/elastics\n\nUpgrading Tutorial: http://elastics.github.io/elastics/doc/7-Tutorials/2-Migrate-from-0.x.html\n\n________________________________________________________________________________\n"
|
126
|
+
rdoc_options:
|
127
|
+
- --charset=UTF-8
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ! '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 1.3.6
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 1.8.25
|
145
|
+
signing_key:
|
146
|
+
specification_version: 3
|
147
|
+
summary: Client gem for elasticsearch
|
148
|
+
test_files: []
|