elasticsearch-rails 8.0.0.pre → 8.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64ebf5844db4e95b8dfe3713ca0059c700d6a75907f96de772f0446c07e4f5da
4
- data.tar.gz: 290065237c0e894f0d905b2f74a867fb8a2fff13cd6a0c9f7bbe3a0a5681382f
3
+ metadata.gz: ad1605494dc4d7e8b3e47dbece4aa520f4407117f3abc0b774277e9a52baa0da
4
+ data.tar.gz: 19a2243d269e8ddb6ab17bb5e2e9272e4dc6bb36855b4fe83b84ea3eb82ef60e
5
5
  SHA512:
6
- metadata.gz: d3e5e62c7a52f4bd25ea892f3336f9b27d66b04a1599cab018e44565b594b562a5fb906234cacc23b7eb6898455f1c2f6064737493754c4c779059d997467ef4
7
- data.tar.gz: 2c02e8ba745189d9d38996d4b5d6dc25de0b45cbe00cde33a37fc6cca033404e5a81d67f2ea77a9c62c66864cc6cee8542214a9ead2f51378be7995a0d05546f
6
+ metadata.gz: 2a9f94de3cd3b297af45123027010d0dce6ffcee38577a06f4fbfe1023b58eea8f257d3970ea05d8c2403e288ae03945d20789ef8a1b3f08a1577639d4e9b39a
7
+ data.tar.gz: 0c2f2455b7f27fcd1ee0c6b246f2bbc289655ffc920aed28a1b07cbe04cd38e9b2eb1e8ad433ce613c0c85787ff11e9bc2d71be7e0db921c8ea7a39ffd349a9b
data/README.md CHANGED
@@ -6,18 +6,19 @@ library, providing features suitable for Ruby on Rails applications.
6
6
 
7
7
  ## Compatibility
8
8
 
9
- This library is compatible with Ruby 1.9.3 and higher.
9
+ This library is compatible with Ruby 3.1 and higher.
10
10
 
11
- The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `7.x` of the Elasticsearch stack. **We haven't tested and updated the code for Elasticsearch `8.0` yet**.
11
+ The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `8.x` of the Elasticsearch stack.
12
12
 
13
- | Rubygem | | Elasticsearch |
14
- |:-------------:|:-:| :-----------: |
15
- | 0.1 | → | 1.x |
16
- | 2.x | → | 2.x |
17
- | 5.x | → | 5.x |
18
- | 6.x | → | 6.x |
19
- | 7.x | → | 7.x |
20
- | main | → | 7.x |
13
+ | Rubygem | | Elasticsearch |
14
+ |:-------:|:-:|:-------------:|
15
+ | 0.1 | → | 1.x |
16
+ | 2.x | → | 2.x |
17
+ | 5.x | → | 5.x |
18
+ | 6.x | → | 6.x |
19
+ | 7.x | → | 7.x |
20
+ | 8.x | → | 8.x |
21
+ | main | → | 8.x |
21
22
 
22
23
  ## Installation
23
24
 
@@ -137,9 +138,9 @@ This software is licensed under the Apache 2 license, quoted below.
137
138
  the Apache License, Version 2.0 (the "License"); you may
138
139
  not use this file except in compliance with the License.
139
140
  You may obtain a copy of the License at
140
-
141
+
141
142
  http://www.apache.org/licenses/LICENSE-2.0
142
-
143
+
143
144
  Unless required by applicable law or agreed to in writing,
144
145
  software distributed under the License is distributed on an
145
146
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,7 +18,6 @@
18
18
  module Elasticsearch
19
19
  module Rails
20
20
  module Instrumentation
21
-
22
21
  # A log subscriber to attach to Elasticsearch related events
23
22
  #
24
23
  # @see https://github.com/rails/rails/blob/master/activerecord/lib/active_record/log_subscriber.rb
@@ -46,11 +45,21 @@ module Elasticsearch
46
45
  payload = event.payload
47
46
  name = "#{payload[:klass]} #{payload[:name]} (#{event.duration.round(1)}ms)"
48
47
  search = payload[:search].inspect.gsub(/:(\w+)=>/, '\1: ')
48
+ debug %Q| #{color(name, GREEN, color_option(true))} #{colorize_logging ? "\e[2m#{search}\e[0m" : search}|
49
+ end
49
50
 
50
- debug %Q| #{color(name, GREEN, true)} #{colorize_logging ? "\e[2m#{search}\e[0m" : search}|
51
+ private
52
+
53
+ def color_option(bold_value)
54
+ new_color_syntax? ? { bold: bold_value } : bold_value
51
55
  end
52
- end
53
56
 
57
+ def new_color_syntax?
58
+ return @new_color_syntax if defined?(@new_color_syntax)
59
+
60
+ @new_color_syntax = ::ActiveSupport.respond_to?(:gem_version) && ::ActiveSupport::gem_version >= '7.1'
61
+ end
62
+ end
54
63
  end
55
64
  end
56
65
  end
@@ -80,7 +80,6 @@ namespace :elasticsearch do
80
80
  total_errors = klass.__elasticsearch__.import force: ENV.fetch('FORCE', false),
81
81
  batch_size: ENV.fetch('BATCH', 1000).to_i,
82
82
  index: ENV.fetch('INDEX', nil),
83
- type: ENV.fetch('TYPE', nil),
84
83
  scope: ENV.fetch('SCOPE', nil) do |response|
85
84
  pbar.inc response['items'].size if pbar
86
85
  STDERR.flush
@@ -17,6 +17,6 @@
17
17
 
18
18
  module Elasticsearch
19
19
  module Rails
20
- VERSION = '8.0.0.pre'.freeze
20
+ VERSION = '8.0.1'.freeze
21
21
  end
22
22
  end
@@ -0,0 +1,57 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ require 'spec_helper'
19
+ require 'elasticsearch/rails/instrumentation/log_subscriber'
20
+
21
+ describe Elasticsearch::Rails::Instrumentation::LogSubscriber do
22
+ subject(:instance) { described_class.new }
23
+
24
+ let(:logger) { instance_double(Logger) }
25
+
26
+ before do
27
+ allow(instance).to receive(:logger) { logger }
28
+ end
29
+
30
+ describe '#search' do
31
+ subject { instance.search(event) }
32
+
33
+ let(:event) { double("search.elasticsearch", duration: 1.2345, payload: { name: "execute", search: { query: { match_all: {}}}}) }
34
+
35
+ it 'logs the event' do
36
+ expect(instance).to receive(:color).with(" execute (1.2ms)", described_class::GREEN, { bold: true }).and_call_original
37
+ expect(logger).to receive(:debug?) { true }
38
+ expect(logger).to receive(:debug).with(" \e[1m\e[32m execute (1.2ms)\e[0m \e[2m{query: {match_all: {}}}\e[0m")
39
+ subject
40
+ end
41
+
42
+ context 'when ActiveSupport version is older' do
43
+ let(:active_support_version) { '7.0.0' }
44
+
45
+ before do
46
+ allow(::ActiveSupport).to receive(:gem_version) { Gem::Version.new(active_support_version) }
47
+ end
48
+
49
+ it 'logs the event' do
50
+ expect(instance).to receive(:color).with(' execute (1.2ms)', described_class::GREEN, true).and_return "\e[1m\e[32m execute (1.2ms)\e[0m"
51
+ expect(logger).to receive(:debug?) { true }
52
+ expect(logger).to receive(:debug).with(" \e[1m\e[32m execute (1.2ms)\e[0m \e[2m{query: {match_all: {}}}\e[0m")
53
+ subject
54
+ end
55
+ end
56
+ end
57
+ end
data/spec/spec_helper.rb CHANGED
@@ -20,6 +20,7 @@ require 'active_record'
20
20
  require 'elasticsearch/model'
21
21
  require 'elasticsearch/rails'
22
22
  require 'rails/railtie'
23
+ require 'rails/version'
23
24
  require 'elasticsearch/rails/instrumentation'
24
25
 
25
26
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0.pre
4
+ version: 8.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic Client Library Maintainers
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-04-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
@@ -240,8 +239,8 @@ email:
240
239
  executables: []
241
240
  extensions: []
242
241
  extra_rdoc_files:
243
- - README.md
244
242
  - LICENSE.txt
243
+ - README.md
245
244
  files:
246
245
  - ".gitignore"
247
246
  - CHANGELOG.md
@@ -275,6 +274,7 @@ files:
275
274
  - lib/rails/templates/searchable.dsl.rb
276
275
  - lib/rails/templates/searchable.rb
277
276
  - lib/rails/templates/seeds.rb
277
+ - spec/instrumentation/log_subscriber_spec.rb
278
278
  - spec/instrumentation_spec.rb
279
279
  - spec/lograge_spec.rb
280
280
  - spec/spec_helper.rb
@@ -286,7 +286,6 @@ metadata:
286
286
  changelog_uri: https://github.com/elastic/elasticsearch-rails/blob/main/CHANGELOG.md
287
287
  source_code_uri: https://github.com/elastic/elasticsearch-rails/
288
288
  bug_tracker_uri: https://github.com/elastic/elasticsearch-rails/issues
289
- post_install_message:
290
289
  rdoc_options:
291
290
  - "--charset=UTF-8"
292
291
  require_paths:
@@ -302,11 +301,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
302
301
  - !ruby/object:Gem::Version
303
302
  version: '0'
304
303
  requirements: []
305
- rubygems_version: 3.5.3
306
- signing_key:
304
+ rubygems_version: 3.7.1
307
305
  specification_version: 4
308
306
  summary: Ruby on Rails integrations for Elasticsearch.
309
307
  test_files:
308
+ - spec/instrumentation/log_subscriber_spec.rb
310
309
  - spec/instrumentation_spec.rb
311
310
  - spec/lograge_spec.rb
312
311
  - spec/spec_helper.rb