sequel-elasticsearch 0.4.9 → 0.4.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 181431ca4bddeae82a6126453bf9439679feeb08243cf6d8a3158438cf5aed40
4
- data.tar.gz: 80660bb4500762573c1e1cfc60b0242fff8cbb4ba0cf2d5bc922084eabd15a4a
3
+ metadata.gz: 127744853b0d25416671270e0c75376721284923f3b3194a2304c819f0571e06
4
+ data.tar.gz: 2aa0e317aa39975bcf71fa5c50d759fd9acc448551af6165be298a97280f066b
5
5
  SHA512:
6
- metadata.gz: 31071ac5cbeab5900fb4f505bd7d4357b5c45823a839fb7fa25a7192ed4aaa76cd77d3400322acc2bd70aeb213ebd6d12671f99e97b7bb9986823ae1aefdf000
7
- data.tar.gz: 5e326ca98cad26b326e169a87d550d6ebcf00a12f01b22c2906a4dae7af71570080e469e79d8446b969fe93fb64cdbab34a2bd1074f7704f7eb182b859eabc40
6
+ metadata.gz: 4fa15223dff93ee23bc8ec8a1c42d02db514e4888514a2aa049fc1e118f4f5565f2a18e73ad0bc21da0ba08c98926f3005ff02b81467ec111d8fcb3dcca75f04
7
+ data.tar.gz: 50ff3ef8237090863eb7d62d83ddb79477e32b95ebe0458bda0abf1bd4c0b73c90887aafe5be9bb4035294900a0ff04e58e244d3d1e3aba1b68ed4218874a91f
@@ -4,6 +4,6 @@ module Sequel
4
4
  # See https://jrgns.github.io/sequel-elasticsearch
5
5
  module Elasticsearch
6
6
  # The Gem's version.
7
- VERSION = '0.4.9'.freeze
7
+ VERSION = '0.4.10'.freeze
8
8
  end
9
9
  end
@@ -21,16 +21,9 @@ module Sequel
21
21
 
22
22
  # Configure the plugin
23
23
  def self.configure(model, opts = OPTS)
24
- environment_scoped = if opts[:environment_scoped].nil?
25
- model.environment != 'test'
26
- else
27
- opts[:environment_scoped]
28
- end
29
-
30
24
  model.elasticsearch_opts = opts[:elasticsearch] || {}
31
25
  model.elasticsearch_index = (opts[:index] || model.table_name).to_sym
32
26
  model.elasticsearch_type = (opts[:type] || :_doc).to_sym
33
- model.elasticsearch_environment_scoped = environment_scoped
34
27
  model
35
28
  end
36
29
 
@@ -39,11 +32,9 @@ module Sequel
39
32
  # The extra options that will be passed to the Elasticsearch client.
40
33
  attr_accessor :elasticsearch_opts
41
34
  # The Elasticsearch index to which the documents will be written.
42
- attr_writer :elasticsearch_index
35
+ attr_accessor :elasticsearch_index
43
36
  # The Elasticsearch type to which the documents will be written.
44
37
  attr_accessor :elasticsearch_type
45
- # If generated indices should include the environment name
46
- attr_accessor :elasticsearch_environment_scoped
47
38
 
48
39
  # Return the Elasticsearch client used to communicate with the cluster.
49
40
  def es_client
@@ -129,6 +120,7 @@ module Sequel
129
120
  alias_index(index_name)
130
121
  end
131
122
 
123
+ # Remove previous aliases and point the `elasticsearch_index` to the new index.
132
124
  def alias_index(new_index)
133
125
  es_client.indices.update_aliases body: {
134
126
  actions: [
@@ -143,29 +135,14 @@ module Sequel
143
135
  es_client.indices.get_alias(name: elasticsearch_index)&.keys&.sort&.first
144
136
  end
145
137
 
146
- def elasticsearch_index
147
- return @elasticsearch_index unless elasticsearch_environment_scoped
148
-
149
- "#{@elasticsearch_index}-#{environment}".to_sym
150
- end
151
-
152
- # Generate a timestamped index name according to the environment.
153
- # This will use the +APP_ENV+ or +RACK_ENV+ ENV variable and a timestamp
154
- # to construct index names like this:
155
- #
156
- # base-name-staging-20191004.123456 # This is a staging index
157
- # base-name-production-20191005.171213 # This is a production index
138
+ # Generate a timestamped index name.
139
+ # This will use the current timestamp to construct index names like this:
158
140
  #
159
- # The adding of the environment name to the index can be turned off by
160
- # setting +elasticsearch_environment_scoped+ to false.
141
+ # base-name-20191004.123456
161
142
  def timestamped_index
162
- time_str = Time.now.strftime('%Y%m%d.%H%M%S')
143
+ time_str = Time.now.strftime('%Y%m%d.%H%M%S') # TODO: Make the format configurable
163
144
  "#{elasticsearch_index}-#{time_str}".to_sym
164
145
  end
165
-
166
- def environment
167
- ENV['APP_ENV'] || ENV['RACK_ENV'] || 'development'
168
- end
169
146
  end
170
147
 
171
148
  # The instance methods that will be added to the Sequel::Model
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurgens du Toit
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-05 00:00:00.000000000 Z
11
+ date: 2019-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch