elastic_record 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/elastic_record.gemspec +1 -1
- data/lib/elastic_record/config.rb +33 -3
- data/lib/elastic_record/railtie.rb +2 -1
- data/test/elastic_record/config_test.rb +19 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cafcc9bf248f805f94ae803aa56c68f5fc98fd4
|
4
|
+
data.tar.gz: 9a35cccb819ffa8d12dca1a46ebdd83196857184
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de0b6cc1b50121db62927f58561b7e7f5f06251ef1250c6e91c30824aeff21c10edc5419f3e989fd028a0f4ad8023ccbe938538986fb77f2b1d11640d3440aa2
|
7
|
+
data.tar.gz: 101e114d54c18f9f0d04264e68191ed07b62415116ecda1c26c7428a82abad7b97a8f81e3f9bebbdb03101e0ede8230c7d0a1b3eec0098d23710cb6d21501f76
|
data/elastic_record.gemspec
CHANGED
@@ -2,8 +2,6 @@ require 'active_support/core_ext/class/attribute'
|
|
2
2
|
|
3
3
|
module ElasticRecord
|
4
4
|
class Config
|
5
|
-
class_attribute :servers
|
6
|
-
|
7
5
|
class_attribute :connection_options
|
8
6
|
self.connection_options = {}
|
9
7
|
|
@@ -18,9 +16,41 @@ module ElasticRecord
|
|
18
16
|
@models ||= model_names.map { |model_name| model_name.constantize }
|
19
17
|
end
|
20
18
|
|
19
|
+
def servers
|
20
|
+
@servers
|
21
|
+
end
|
22
|
+
|
23
|
+
def servers=(values)
|
24
|
+
unless values.is_a?(Array)
|
25
|
+
values = values.split(',')
|
26
|
+
end
|
27
|
+
@servers = values
|
28
|
+
end
|
29
|
+
|
21
30
|
def settings=(settings)
|
22
31
|
self.servers = settings['servers']
|
23
|
-
|
32
|
+
|
33
|
+
if settings['options']
|
34
|
+
warn("**************************************",
|
35
|
+
"elasticsearch.yml/:options is deprecated. For example, the following:",
|
36
|
+
"development:",
|
37
|
+
" servers: 127.0.0.1:9200",
|
38
|
+
" options:",
|
39
|
+
" timeout: 10",
|
40
|
+
" retries: 2",
|
41
|
+
"",
|
42
|
+
"becomes:",
|
43
|
+
"",
|
44
|
+
"development:",
|
45
|
+
" servers: 127.0.0.1:9200",
|
46
|
+
" timeout: 10",
|
47
|
+
" retries: 2",
|
48
|
+
"**************************************")
|
49
|
+
self.connection_options = settings['options']
|
50
|
+
else
|
51
|
+
self.connection_options = settings
|
52
|
+
end
|
53
|
+
|
24
54
|
if scroll_keep_alive = settings['scroll_keep_alive'].presence
|
25
55
|
self.scroll_keep_alive = scroll_keep_alive
|
26
56
|
end
|
@@ -7,7 +7,8 @@ module ElasticRecord
|
|
7
7
|
initializer "elastic_record.config" do |app|
|
8
8
|
pathname = Rails.root.join('config', 'elasticsearch.yml')
|
9
9
|
if pathname.exist?
|
10
|
-
config =
|
10
|
+
config = ERB.new(pathname.read).result
|
11
|
+
config = YAML.load(config)
|
11
12
|
|
12
13
|
if config = config[Rails.env]
|
13
14
|
ElasticRecord::Config.settings = config
|
@@ -11,7 +11,24 @@ class ElasticRecord::ConfigTest < MiniTest::Unit::TestCase
|
|
11
11
|
assert_equal [Warehouse, Widget], ElasticRecord::Config.models
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
|
14
|
+
def test_servers
|
15
|
+
with_servers ['abc.com', 'xyz.com'] do
|
16
|
+
assert_equal ['abc.com', 'xyz.com'], ElasticRecord::Config.servers
|
17
|
+
end
|
18
|
+
|
19
|
+
with_servers 'abc.com,xyz.com' do
|
20
|
+
assert_equal ['abc.com', 'xyz.com'], ElasticRecord::Config.servers
|
21
|
+
end
|
16
22
|
end
|
23
|
+
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def with_servers(values)
|
28
|
+
original = ElasticRecord::Config.servers
|
29
|
+
ElasticRecord::Config.servers = values
|
30
|
+
yield
|
31
|
+
ensure
|
32
|
+
ElasticRecord::Config.servers = original
|
33
|
+
end
|
17
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Infogroup
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: arelastic
|