Skip to content

Commit 99d906f

Browse files
committed
Rubocoping: whitespace and styling
1 parent 110b07b commit 99d906f

File tree

6 files changed

+5
-42
lines changed

6 files changed

+5
-42
lines changed

elasticsearch-model/lib/elasticsearch/model/adapter.rb

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
module Elasticsearch
1919
module Model
20-
2120
# Contains an adapter which provides OxM-specific implementations for common behaviour:
2221
#
2322
# * {Adapter::Adapter#records_mixin Fetching records from the database}
@@ -29,7 +28,6 @@ module Model
2928
# @see Elasticsearch::Model::Adapter::Mongoid
3029
#
3130
module Adapter
32-
3331
# Returns an adapter based on the Ruby class passed
3432
#
3533
# @example Create an adapter for an ActiveRecord-based model

elasticsearch-model/lib/elasticsearch/model/importing.rb

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@
1717

1818
module Elasticsearch
1919
module Model
20-
2120
# Provides support for easily and efficiently importing large amounts of
2221
# records from the including class into the index.
2322
#
2423
# @see ClassMethods#import
2524
#
2625
module Importing
27-
2826
# When included in a model, adds the importing methods.
2927
#
3028
# @example Import all records from the `Article` model
@@ -42,13 +40,12 @@ def self.included(base)
4240
end
4341

4442
module ClassMethods
45-
4643
# Import all model records into the index
4744
#
4845
# The method will pick up correct strategy based on the `Importing` module
4946
# defined in the corresponding adapter.
5047
#
51-
# @param options [Hash] Options passed to the underlying `__find_in_batches`method
48+
# @param options [Hash] Options passed to the underlying `__find_in_batches` method
5249
# @param block [Proc] Optional block to evaluate for each batch
5350
#
5451
# @yield [Hash] Gives the Hash with the Elasticsearch response to the block

elasticsearch-model/lib/elasticsearch/model/proxy.rb

-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
module Elasticsearch
1919
module Model
20-
2120
# This module provides a proxy interfacing between the including class and
2221
# `Elasticsearch::Model`, preventing the pollution of the including class namespace.
2322
#
@@ -45,17 +44,14 @@ module Model
4544
# # => true
4645
#
4746
module Proxy
48-
4947
# Define the `__elasticsearch__` class and instance methods in the including class
5048
# and register a callback for intercepting changes in the model.
5149
#
5250
# @note The callback is triggered only when `Elasticsearch::Model` is included in the
5351
# module and the functionality is accessible via the proxy.
5452
#
5553
def self.included(base)
56-
5754
base.class_eval do
58-
5955
# `ClassMethodsProxy` instance, accessed as `MyModel.__elasticsearch__`
6056
def self.__elasticsearch__ &block
6157
@__elasticsearch__ ||= ClassMethodsProxy.new(self)

elasticsearch-model/spec/elasticsearch/model/adapter_spec.rb

-11
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
require 'spec_helper'
1919

2020
describe Elasticsearch::Model::Adapter do
21-
2221
before(:all) do
2322
class ::DummyAdapterClass; end
2423
class ::DummyAdapterClassWithAdapter; end
@@ -37,14 +36,12 @@ class ::DummyAdapter
3736
end
3837

3938
describe '#from_class' do
40-
4139
it 'should return an Adapter instance' do
4240
expect(Elasticsearch::Model::Adapter.from_class(DummyAdapterClass)).to be_a(Elasticsearch::Model::Adapter::Adapter)
4341
end
4442
end
4543

4644
describe 'register' do
47-
4845
before do
4946
expect(Elasticsearch::Model::Adapter::Adapter).to receive(:register).and_call_original
5047
Elasticsearch::Model::Adapter.register(:foo, lambda { |c| false })
@@ -55,7 +52,6 @@ class ::DummyAdapter
5552
end
5653

5754
context 'when a specific adapter class is set' do
58-
5955
before do
6056
expect(Elasticsearch::Model::Adapter::Adapter).to receive(:register).and_call_original
6157
Elasticsearch::Model::Adapter::Adapter.register(DummyAdapter,
@@ -73,7 +69,6 @@ class ::DummyAdapter
7369
end
7470

7571
describe 'default adapter' do
76-
7772
let(:adapter) do
7873
Elasticsearch::Model::Adapter::Adapter.new(DummyAdapterClass)
7974
end
@@ -84,11 +79,9 @@ class ::DummyAdapter
8479
end
8580

8681
describe '#records_mixin' do
87-
8882
before do
8983
Elasticsearch::Model::Adapter::Adapter.register(DummyAdapter,
9084
lambda { |c| c == DummyAdapterClassWithAdapter })
91-
9285
end
9386

9487
let(:adapter) do
@@ -101,11 +94,9 @@ class ::DummyAdapter
10194
end
10295

10396
describe '#callbacks_mixin' do
104-
10597
before do
10698
Elasticsearch::Model::Adapter::Adapter.register(DummyAdapter,
10799
lambda { |c| c == DummyAdapterClassWithAdapter })
108-
109100
end
110101

111102
let(:adapter) do
@@ -118,11 +109,9 @@ class ::DummyAdapter
118109
end
119110

120111
describe '#importing_mixin' do
121-
122112
before do
123113
Elasticsearch::Model::Adapter::Adapter.register(DummyAdapter,
124114
lambda { |c| c == DummyAdapterClassWithAdapter })
125-
126115
end
127116

128117
let(:adapter) do

elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
describe 'Elasticsearch::Model::Adapter::ActiveRecord Importing' do
2121
before(:all) do
22-
ActiveRecord::Schema.define(:version => 1) do
22+
ActiveRecord::Schema.define(version: 1) do
2323
create_table :import_articles do |t|
2424
t.string :title
2525
t.integer :views
2626
t.string :numeric # For the sake of invalid data sent to Elasticsearch
27-
t.datetime :created_at, :default => 'NOW()'
27+
t.datetime :created_at, default: 'NOW()'
2828
end
2929
end
3030

elasticsearch-model/spec/elasticsearch/model/importing_spec.rb

+2-19
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,17 @@
1818
require 'spec_helper'
1919

2020
describe Elasticsearch::Model::Importing do
21-
2221
before(:all) do
2322
class DummyImportingModel
2423
end
2524

2625
module DummyImportingAdapter
2726
module ImportingMixin
28-
def __find_in_batches(options={}, &block)
27+
def __find_in_batches( options = {}, &block)
2928
yield if block_given?
3029
end
3130
def __transform
32-
lambda {|a|}
31+
lambda { |a| }
3332
end
3433
end
3534

@@ -49,15 +48,13 @@ def importing_mixin
4948
end
5049

5150
context 'when a model includes the Importing module' do
52-
5351
it 'provides importing methods' do
5452
expect(DummyImportingModel.respond_to?(:import)).to be(true)
5553
expect(DummyImportingModel.respond_to?(:__find_in_batches)).to be(true)
5654
end
5755
end
5856

5957
describe '#import' do
60-
6158
before do
6259
allow(DummyImportingModel).to receive(:index_name).and_return('foo')
6360
allow(DummyImportingModel).to receive(:document_type).and_return('foo')
@@ -75,7 +72,6 @@ def importing_mixin
7572
end
7673

7774
context 'when no options are provided' do
78-
7975
before do
8076
expect(DummyImportingModel).to receive(:client).and_return(client)
8177
allow(DummyImportingModel).to receive(:index_exists?).and_return(true)
@@ -87,7 +83,6 @@ def importing_mixin
8783
end
8884

8985
context 'when there is an error' do
90-
9186
before do
9287
expect(DummyImportingModel).to receive(:client).and_return(client)
9388
allow(DummyImportingModel).to receive(:index_exists?).and_return(true)
@@ -102,14 +97,12 @@ def importing_mixin
10297
end
10398

10499
context 'when the method is called with the option to return the errors' do
105-
106100
it 'returns the errors' do
107101
expect(DummyImportingModel.import(return: 'errors')).to eq([{ 'index' => { 'error' => 'FAILED' } }])
108102
end
109103
end
110104

111105
context 'when the method is called with a block' do
112-
113106
it 'yields the response to the block' do
114107
DummyImportingModel.import do |response|
115108
expect(response['items'].size).to eq(2)
@@ -119,7 +112,6 @@ def importing_mixin
119112
end
120113

121114
context 'when the index does not exist' do
122-
123115
before do
124116
allow(DummyImportingModel).to receive(:index_exists?).and_return(false)
125117
end
@@ -132,7 +124,6 @@ def importing_mixin
132124
end
133125

134126
context 'when the method is called with the force option' do
135-
136127
before do
137128
expect(DummyImportingModel).to receive(:create_index!).with(force: true, index: 'foo').and_return(true)
138129
expect(DummyImportingModel).to receive(:__find_in_batches).with(foo: 'bar').and_return(true)
@@ -144,7 +135,6 @@ def importing_mixin
144135
end
145136

146137
context 'when the method is called with the refresh option' do
147-
148138
before do
149139
expect(DummyImportingModel).to receive(:refresh_index!).with(index: 'foo').and_return(true)
150140
expect(DummyImportingModel).to receive(:__find_in_batches).with(foo: 'bar').and_return(true)
@@ -156,7 +146,6 @@ def importing_mixin
156146
end
157147

158148
context 'when a different index name is provided' do
159-
160149
before do
161150
expect(DummyImportingModel).to receive(:client).and_return(client)
162151
expect(client).to receive(:bulk).with(body: nil, index: 'my-new-index', type: 'foo').and_return(response)
@@ -168,7 +157,6 @@ def importing_mixin
168157
end
169158

170159
context 'when a different document type is provided' do
171-
172160
before do
173161
expect(DummyImportingModel).to receive(:client).and_return(client)
174162
expect(client).to receive(:bulk).with(body: nil, index: 'foo', type: 'my-new-type').and_return(response)
@@ -180,7 +168,6 @@ def importing_mixin
180168
end
181169

182170
context 'the transform method' do
183-
184171
before do
185172
expect(DummyImportingModel).to receive(:client).and_return(client)
186173
expect(DummyImportingModel).to receive(:__transform).and_return(transform)
@@ -197,9 +184,7 @@ def importing_mixin
197184
end
198185

199186
context 'when a transform is provided as an option' do
200-
201187
context 'when the transform option is not a lambda' do
202-
203188
let(:transform) do
204189
'not_callable'
205190
end
@@ -212,7 +197,6 @@ def importing_mixin
212197
end
213198

214199
context 'when the transform option is a lambda' do
215-
216200
before do
217201
expect(DummyImportingModel).to receive(:client).and_return(client)
218202
expect(DummyImportingModel).to receive(:__batch_to_bulk).with(anything, transform)
@@ -229,7 +213,6 @@ def importing_mixin
229213
end
230214

231215
context 'when a pipeline is provided as an options' do
232-
233216
before do
234217
expect(DummyImportingModel).to receive(:client).and_return(client)
235218
expect(client).to receive(:bulk).with(body: nil, index: 'foo', type: 'foo', pipeline: 'my-pipeline').and_return(response)

0 commit comments

Comments
 (0)