elasticsearch-model 0.1.0.rc1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -16,5 +16,5 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
 
19
- gemfiles/3.gemfile.lock
20
- gemfiles/4.gemfile.lock
19
+ gemfiles/3.0.gemfile.lock
20
+ gemfiles/4.0.gemfile.lock
data/README.md CHANGED
@@ -13,7 +13,7 @@ The library is compatible with Ruby 1.9.3 and higher.
13
13
 
14
14
  Install the package from [Rubygems](https://rubygems.org):
15
15
 
16
- gem install elasticsearch-model --pre
16
+ gem install elasticsearch-model
17
17
 
18
18
  To use an unreleased version, either add it to your `Gemfile` for [Bundler](http://bundler.io):
19
19
 
@@ -21,7 +21,8 @@ Gem::Specification.new do |s|
21
21
  s.extra_rdoc_files = [ "README.md", "LICENSE.txt" ]
22
22
  s.rdoc_options = [ "--charset=UTF-8" ]
23
23
 
24
- s.add_dependency "elasticsearch", '~> 0.4'
24
+ s.add_dependency "elasticsearch", '> 0.4'
25
+ s.add_dependency "activesupport", '> 3'
25
26
  s.add_dependency "hashie"
26
27
 
27
28
  s.add_development_dependency "bundler", "~> 1.3"
@@ -30,12 +31,12 @@ Gem::Specification.new do |s|
30
31
  s.add_development_dependency "elasticsearch-extensions"
31
32
 
32
33
  s.add_development_dependency "sqlite3"
33
- s.add_development_dependency "activesupport", "> 3.0"
34
34
  s.add_development_dependency "activemodel", "> 3.0"
35
35
  s.add_development_dependency "activerecord", "> 4.0"
36
36
 
37
37
  s.add_development_dependency "oj"
38
38
  s.add_development_dependency "kaminari"
39
+ # NOTE: Do not add Mongoid here, keep only in 3/4 files
39
40
 
40
41
  s.add_development_dependency "shoulda-context"
41
42
  s.add_development_dependency "mocha"
@@ -3,6 +3,11 @@
3
3
  #
4
4
  # https://github.com/rails/rails/tree/master/activerecord
5
5
  # http://guides.rubyonrails.org/association_basics.html
6
+ #
7
+ # Run me with:
8
+ #
9
+ # ruby -I lib examples/activerecord_associations.rb
10
+ #
6
11
 
7
12
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
8
13
 
@@ -81,6 +86,8 @@ class Article < ActiveRecord::Base
81
86
  has_many :comments
82
87
  end
83
88
 
89
+ class Article < ActiveRecord::Base; delegate :size, to: :comments, prefix: true; end
90
+
84
91
  class Comment < ActiveRecord::Base
85
92
  belongs_to :article, touch: true
86
93
  end
@@ -0,0 +1,12 @@
1
+ # Usage:
2
+ #
3
+ # $ BUNDLE_GEMFILE=./gemfiles/3.0.gemfile bundle install
4
+ # $ BUNDLE_GEMFILE=./gemfiles/3.0.gemfile bundle exec rake test:integration
5
+
6
+ source 'https://rubygems.org'
7
+
8
+ gemspec path: '../'
9
+
10
+ gem 'activemodel', '>= 3.0'
11
+ gem 'activerecord', '~> 3.2'
12
+ gem 'mongoid', '>= 3.0'
@@ -0,0 +1,12 @@
1
+ # Usage:
2
+ #
3
+ # $ BUNDLE_GEMFILE=./gemfiles/4.0.gemfile bundle install
4
+ # $ BUNDLE_GEMFILE=./gemfiles/4.0.gemfile bundle exec rake test:integration
5
+
6
+ source 'https://rubygems.org'
7
+
8
+ gemspec path: '../'
9
+
10
+ gem 'activemodel', '~> 4'
11
+ gem 'activerecord', '~> 4'
12
+ gem 'mongoid', '~> 4.0.0.beta1'
@@ -1,10 +1,10 @@
1
- require 'forwardable'
2
-
3
1
  require 'elasticsearch'
4
2
 
5
3
  require 'hashie'
6
4
 
7
- require 'elasticsearch/model/support/forwardable'
5
+ require 'active_support/core_ext/module/delegation'
6
+
7
+ require 'elasticsearch/model/version'
8
8
 
9
9
  require 'elasticsearch/model/client'
10
10
 
@@ -29,7 +29,7 @@ require 'elasticsearch/model/response/results'
29
29
  require 'elasticsearch/model/response/records'
30
30
  require 'elasticsearch/model/response/pagination'
31
31
 
32
- require 'elasticsearch/model/version'
32
+ require 'elasticsearch/model/ext/active_record'
33
33
 
34
34
  if defined?(::Kaminari)
35
35
  Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
@@ -103,14 +103,15 @@ module Elasticsearch
103
103
 
104
104
  # Delegate important methods to the `__elasticsearch__` proxy, unless they are defined already
105
105
  #
106
- extend Support::Forwardable
107
- forward :'self.__elasticsearch__', :search unless respond_to?(:search)
108
- forward :'self.__elasticsearch__', :mapping unless respond_to?(:mapping)
109
- forward :'self.__elasticsearch__', :mappings unless respond_to?(:mappings)
110
- forward :'self.__elasticsearch__', :settings unless respond_to?(:settings)
111
- forward :'self.__elasticsearch__', :index_name unless respond_to?(:index_name)
112
- forward :'self.__elasticsearch__', :document_type unless respond_to?(:document_type)
113
- forward :'self.__elasticsearch__', :import unless respond_to?(:import)
106
+ class << self
107
+ delegate :search, to: :__elasticsearch__ unless respond_to?(:search)
108
+ delegate :mapping, to: :__elasticsearch__ unless respond_to?(:mapping)
109
+ delegate :mappings, to: :__elasticsearch__ unless respond_to?(:mappings)
110
+ delegate :settings, to: :__elasticsearch__ unless respond_to?(:settings)
111
+ delegate :index_name, to: :__elasticsearch__ unless respond_to?(:index_name)
112
+ delegate :document_type, to: :__elasticsearch__ unless respond_to?(:document_type)
113
+ delegate :import, to: :__elasticsearch__ unless respond_to?(:import)
114
+ end
114
115
 
115
116
  # Mix the importing module into the proxy
116
117
  #
@@ -13,7 +13,7 @@ module Elasticsearch
13
13
  # Returns an `ActiveRecord::Relation` instance
14
14
  #
15
15
  def records
16
- sql_records = klass.where(id: ids)
16
+ sql_records = klass.where(klass.primary_key => ids)
17
17
 
18
18
  # Re-order records based on the order from Elasticsearch hits
19
19
  # by redefining `to_a`, unless the user has called `order()`
@@ -0,0 +1,14 @@
1
+ # Prevent `MyModel.inspect` failing with `ActiveRecord::ConnectionNotEstablished`
2
+ # (triggered by elasticsearch-model/lib/elasticsearch/model.rb:79:in `included')
3
+ #
4
+ ActiveRecord::Base.instance_eval do
5
+ class << self
6
+ def inspect_with_rescue
7
+ inspect_without_rescue
8
+ rescue ActiveRecord::ConnectionNotEstablished
9
+ "#{self}(no database connection)"
10
+ end
11
+
12
+ alias_method_chain :inspect, :rescue
13
+ end
14
+ end if defined?(ActiveRecord) && ActiveRecord::VERSION::STRING < '4'
@@ -60,20 +60,24 @@ module Elasticsearch
60
60
  #
61
61
  # Article.import refresh: true
62
62
  #
63
+ # @example Import the records into a different index/type than the default one
64
+ #
65
+ # Article.import index: 'my-new-index', type: 'my-other-type'
63
66
  #
64
67
  def import(options={}, &block)
65
- errors = 0
68
+ errors = 0
69
+ refresh = options.delete(:refresh) || false
70
+ target_index = options.delete(:index) || index_name
71
+ target_type = options.delete(:type) || document_type
66
72
 
67
73
  if options.delete(:force)
68
- self.create_index! force: true
74
+ self.create_index! force: true, index: target_index
69
75
  end
70
76
 
71
- refresh = options.delete(:refresh) || false
72
-
73
77
  __find_in_batches(options) do |batch|
74
78
  response = client.bulk \
75
- index: index_name,
76
- type: document_type,
79
+ index: target_index,
80
+ type: target_type,
77
81
  body: batch
78
82
 
79
83
  yield response if block_given?
@@ -175,15 +175,21 @@ module Elasticsearch
175
175
  #
176
176
  # Article.__elasticsearch__.create_index! force: true
177
177
  #
178
+ # @example Pass a specific index name
179
+ #
180
+ # Article.__elasticsearch__.create_index! index: 'my-index'
181
+ #
178
182
  def create_index!(options={})
179
- delete_index!(options) if options[:force]
183
+ target_index = options.delete(:index) || self.index_name
184
+
185
+ delete_index!(options.merge index: target_index) if options[:force]
180
186
 
181
- unless ( self.client.indices.exists(index: self.index_name) rescue false )
187
+ unless ( self.client.indices.exists(index: target_index) rescue false )
182
188
  begin
183
- self.client.indices.create index: self.index_name,
184
- body: {
185
- settings: self.settings.to_hash,
186
- mappings: self.mappings.to_hash }
189
+ self.client.indices.create index: target_index,
190
+ body: {
191
+ settings: self.settings.to_hash,
192
+ mappings: self.mappings.to_hash }
187
193
  rescue Exception => e
188
194
  unless e.class.to_s =~ /NotFound/ && options[:force]
189
195
  STDERR.puts "[!!!] Error when creating the index: #{e.class}", "#{e.message}"
@@ -199,9 +205,15 @@ module Elasticsearch
199
205
  #
200
206
  # Article.__elasticsearch__.delete_index!
201
207
  #
208
+ # @example Pass a specific index name
209
+ #
210
+ # Article.__elasticsearch__.delete_index! index: 'my-index'
211
+ #
202
212
  def delete_index!(options={})
213
+ target_index = options.delete(:index) || self.index_name
214
+
203
215
  begin
204
- self.client.indices.delete index: self.index_name
216
+ self.client.indices.delete index: target_index
205
217
  rescue Exception => e
206
218
  unless e.class.to_s =~ /NotFound/ && options[:force]
207
219
  STDERR.puts "[!!!] Error when deleting the index: #{e.class}", "#{e.message}"
@@ -215,11 +227,17 @@ module Elasticsearch
215
227
  #
216
228
  # Article.__elasticsearch__.refresh_index!
217
229
  #
230
+ # @example Pass a specific index name
231
+ #
232
+ # Article.__elasticsearch__.refresh_index! index: 'my-index'
233
+ #
218
234
  # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-refresh.html
219
235
  #
220
236
  def refresh_index!(options={})
237
+ target_index = options.delete(:index) || self.index_name
238
+
221
239
  begin
222
- self.client.indices.refresh index: self.index_name
240
+ self.client.indices.refresh index: target_index
223
241
  rescue Exception => e
224
242
  unless e.class.to_s =~ /NotFound/ && options[:force]
225
243
  STDERR.puts "[!!!] Error when refreshing the index: #{e.class}", "#{e.message}"
@@ -14,9 +14,8 @@ module Elasticsearch
14
14
  :took, :timed_out, :shards
15
15
 
16
16
  include Enumerable
17
- extend Support::Forwardable
18
17
 
19
- forward :results, :each, :empty?, :size, :slice, :[], :to_ary
18
+ delegate :each, :empty?, :size, :slice, :[], :to_ary, to: :results
20
19
 
21
20
  def initialize(klass, search, options={})
22
21
  @klass = klass
@@ -20,8 +20,8 @@ module Elasticsearch
20
20
  Elasticsearch::Model::Response::Results.__send__ :include, ::Kaminari::PageScopeMethods
21
21
  Elasticsearch::Model::Response::Records.__send__ :include, ::Kaminari::PageScopeMethods
22
22
 
23
- Elasticsearch::Model::Response::Results.__send__ :forward, :response, :limit_value, :offset_value, :total_count
24
- Elasticsearch::Model::Response::Records.__send__ :forward, :response, :limit_value, :offset_value, :total_count
23
+ Elasticsearch::Model::Response::Results.__send__ :delegate, :limit_value, :offset_value, :total_count, to: :response
24
+ Elasticsearch::Model::Response::Records.__send__ :delegate, :limit_value, :offset_value, :total_count, to: :response
25
25
 
26
26
  base.class_eval <<-RUBY, __FILE__, __LINE__ + 1
27
27
  # Define the `page` Kaminari method
@@ -10,8 +10,7 @@ module Elasticsearch
10
10
  class Records
11
11
  include Enumerable
12
12
 
13
- extend Support::Forwardable
14
- forward :records, :each, :empty?, :size, :slice, :[], :to_a, :to_ary
13
+ delegate :each, :empty?, :size, :slice, :[], :to_a, :to_ary, to: :records
15
14
 
16
15
  include Base
17
16
 
@@ -10,8 +10,7 @@ module Elasticsearch
10
10
  include Base
11
11
  include Enumerable
12
12
 
13
- extend Support::Forwardable
14
- forward :results, :each, :empty?, :size, :slice, :[], :to_a, :to_ary
13
+ delegate :each, :empty?, :size, :slice, :[], :to_a, :to_ary, to: :results
15
14
 
16
15
  # @see Base#initialize
17
16
  #
@@ -95,7 +95,7 @@ module Elasticsearch
95
95
  # Article.search '{"query" : { "match_all" : {} }}'
96
96
  #
97
97
  def search(query_or_payload, options={})
98
- search = SearchRequest.new(self, query_or_payload, options={})
98
+ search = SearchRequest.new(self, query_or_payload, options)
99
99
 
100
100
  Response::Response.new(self, search)
101
101
  end
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module Model
3
- VERSION = "0.1.0.rc1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -1,17 +1,18 @@
1
1
  require 'test_helper'
2
2
 
3
3
  begin
4
- require "mongoid"
4
+ require 'mongoid'
5
5
  session = Moped::Connection.new("localhost", 27017, 0.5)
6
6
  session.connect
7
7
  ENV["MONGODB_AVAILABLE"] = 'yes'
8
8
  rescue LoadError, Moped::Errors::ConnectionFailure => e
9
+ $stderr.puts "MongoDB not installed or running: #{e}"
9
10
  end
10
11
 
11
12
  if ENV["MONGODB_AVAILABLE"]
12
- puts "Mongoid #{Mongoid::VERSION}", '-'*80
13
+ $stderr.puts "Mongoid #{Mongoid::VERSION}", '-'*80
13
14
 
14
- logger = ::Logger.new(STDERR)
15
+ logger = ::Logger.new($stderr)
15
16
  logger.formatter = lambda { |s, d, p, m| " #{m.ansi(:faint, :cyan)}\n" }
16
17
  logger.level = ::Logger::DEBUG
17
18
 
@@ -49,7 +49,7 @@ module Elasticsearch
49
49
  tracer = ::Logger.new(STDERR)
50
50
  tracer.formatter = lambda { |s, d, p, m| "#{m.gsub(/^.*$/) { |n| ' ' + n }.ansi(:faint)}\n" }
51
51
 
52
- Elasticsearch::Model.client = Elasticsearch::Client.new host: 'localhost:9250',
52
+ Elasticsearch::Model.client = Elasticsearch::Client.new host: "localhost:#{(ENV['TEST_CLUSTER_PORT'] || 9250)}",
53
53
  tracer: (ENV['QUIET'] ? nil : tracer)
54
54
  end
55
55
  end
@@ -23,6 +23,7 @@ class Elasticsearch::Model::AdapterActiveRecordTest < Test::Unit::TestCase
23
23
  setup do
24
24
  @records = [ stub(id: 1, inspect: '<Model-1>'), stub(id: 2, inspect: '<Model-2>') ]
25
25
  @records.stubs(:load).returns(true)
26
+ @records.stubs(:exec_queries).returns(true)
26
27
  end
27
28
 
28
29
  should "have the register condition" do
@@ -39,7 +40,7 @@ class Elasticsearch::Model::AdapterActiveRecordTest < Test::Unit::TestCase
39
40
  assert_instance_of Module, Elasticsearch::Model::Adapter::ActiveRecord::Records
40
41
 
41
42
  instance = DummyClassForActiveRecord.new
42
- instance.expects(:klass).returns(mock('class', where: @records))
43
+ instance.expects(:klass).returns(mock('class', primary_key: :some_key, where: @records)).at_least_once
43
44
 
44
45
  assert_equal @records, instance.records
45
46
  end
@@ -54,7 +55,7 @@ class Elasticsearch::Model::AdapterActiveRecordTest < Test::Unit::TestCase
54
55
  @records.instance_variable_set(:@records, @records)
55
56
 
56
57
  instance = DummyClassForActiveRecord.new
57
- instance.expects(:klass).returns(mock('class', where: @records))
58
+ instance.expects(:klass).returns(mock('class', primary_key: :some_key, where: @records)).at_least_once
58
59
 
59
60
  assert_equal [1, 2], @records. to_a.map(&:id)
60
61
  assert_equal [2, 1], instance.records.to_a.map(&:id)
@@ -64,7 +65,7 @@ class Elasticsearch::Model::AdapterActiveRecordTest < Test::Unit::TestCase
64
65
  @records.instance_variable_set(:@records, @records)
65
66
 
66
67
  instance = DummyClassForActiveRecord.new
67
- instance.expects(:klass).returns(stub('class', where: @records)).at_least_once
68
+ instance.expects(:klass).returns(stub('class', primary_key: :some_key, where: @records)).at_least_once
68
69
  instance.records.expects(:order).returns(@records)
69
70
 
70
71
  assert_equal [2, 1], instance.records. to_a.map(&:id)
@@ -91,7 +91,33 @@ class Elasticsearch::Model::ImportingTest < Test::Unit::TestCase
91
91
  assert_equal true, options[:force]
92
92
  end
93
93
 
94
+ DummyImportingModel.expects(:index_name).returns('foo')
95
+ DummyImportingModel.expects(:document_type).returns('foo')
96
+
94
97
  DummyImportingModel.import force: true, foo: 'bar'
95
98
  end
99
+
100
+ should "allow passing a different index / type" do
101
+ Elasticsearch::Model::Adapter.expects(:from_class)
102
+ .with(DummyImportingModel)
103
+ .returns(DummyImportingAdapter)
104
+
105
+ DummyImportingModel.__send__ :include, Elasticsearch::Model::Importing
106
+
107
+ client = mock('client')
108
+
109
+ client
110
+ .expects(:bulk)
111
+ .with do |options|
112
+ assert_equal 'my-new-index', options[:index]
113
+ assert_equal 'my-other-type', options[:type]
114
+ true
115
+ end
116
+ .returns({'items' => [ {'index' => {} }]})
117
+
118
+ DummyImportingModel.stubs(:client).returns(client)
119
+
120
+ DummyImportingModel.import index: 'my-new-index', type: 'my-other-type'
121
+ end
96
122
  end
97
123
  end
@@ -358,6 +358,43 @@ class Elasticsearch::Model::IndexingTest < Test::Unit::TestCase
358
358
  DummyIndexingModelForRecreate.refresh_index!
359
359
  end
360
360
  end
361
+
362
+ context "with a custom index name" do
363
+ setup do
364
+ @client = stub('client')
365
+ @indices = stub('indices')
366
+ @client.stubs(:indices).returns(@indices)
367
+ DummyIndexingModelForRecreate.expects(:client).returns(@client).at_least_once
368
+ end
369
+
370
+ should "create the custom index" do
371
+ @indices.expects(:exists).with do |arguments|
372
+ assert_equal 'custom-foo', arguments[:index]
373
+ end
374
+
375
+ @indices.expects(:create).with do |arguments|
376
+ assert_equal 'custom-foo', arguments[:index]
377
+ end
378
+
379
+ DummyIndexingModelForRecreate.create_index! index: 'custom-foo'
380
+ end
381
+
382
+ should "delete the custom index" do
383
+ @indices.expects(:delete).with do |arguments|
384
+ assert_equal 'custom-foo', arguments[:index]
385
+ end
386
+
387
+ DummyIndexingModelForRecreate.delete_index! index: 'custom-foo'
388
+ end
389
+
390
+ should "refresh the custom index" do
391
+ @indices.expects(:refresh).with do |arguments|
392
+ assert_equal 'custom-foo', arguments[:index]
393
+ end
394
+
395
+ DummyIndexingModelForRecreate.refresh_index! index: 'custom-foo'
396
+ end
397
+ end
361
398
  end
362
399
 
363
400
  end
@@ -20,7 +20,7 @@ class Elasticsearch::Model::RecordsTest < Test::Unit::TestCase
20
20
  end
21
21
  end
22
22
 
23
- RESPONSE = { 'hits' => { 'total' => 123, 'max_score' => 456, 'hits' => [{'foo' => 'bar'}] } }
23
+ RESPONSE = { 'hits' => { 'total' => 123, 'max_score' => 456, 'hits' => [{'_id' => '1', 'foo' => 'bar'}] } }
24
24
  RESULTS = Elasticsearch::Model::Response::Results.new DummyModel, RESPONSE
25
25
 
26
26
  setup do
@@ -28,7 +28,7 @@ class Elasticsearch::Model::RecordsTest < Test::Unit::TestCase
28
28
  search.stubs(:execute!).returns RESPONSE
29
29
 
30
30
  response = Elasticsearch::Model::Response::Response.new DummyModel, search
31
- @records = Elasticsearch::Model::Response::Records.new DummyModel, response
31
+ @records = Elasticsearch::Model::Response::Records.new DummyModel, response
32
32
  end
33
33
 
34
34
  should "access the records" do
@@ -58,6 +58,10 @@ class Elasticsearch::Model::RecordsTest < Test::Unit::TestCase
58
58
  assert_equal ['FOO---bar'], @records.map_with_hit { |record, hit| "#{record}---#{hit.foo}" }
59
59
  end
60
60
 
61
+ should "return the IDs" do
62
+ assert_equal ['1'], @records.ids
63
+ end
64
+
61
65
  context "with adapter" do
62
66
  module DummyAdapter
63
67
  module RecordsMixin
@@ -23,10 +23,11 @@ class Elasticsearch::Model::SearchingTest < Test::Unit::TestCase
23
23
  .expects(:new).with do |klass, query, options|
24
24
  assert_equal DummySearchingModel, klass
25
25
  assert_equal 'foo', query
26
+ assert_equal({default_operator: 'AND'}, options)
26
27
  end
27
28
  .returns( stub('search') )
28
29
 
29
- DummySearchingModel.search 'foo'
30
+ DummySearchingModel.search 'foo', default_operator: 'AND'
30
31
  end
31
32
 
32
33
  should "not execute the search" do
metadata CHANGED
@@ -1,22 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.rc1
5
- prerelease: 6
4
+ version: 0.1.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Karel Minarik
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-20 00:00:00.000000000 Z
12
+ date: 2014-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: elasticsearch
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>'
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0.4'
22
22
  type: :runtime
@@ -24,9 +24,25 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>'
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0.4'
30
+ - !ruby/object:Gem::Dependency
31
+ name: activesupport
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>'
36
+ - !ruby/object:Gem::Version
37
+ version: '3'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>'
44
+ - !ruby/object:Gem::Version
45
+ version: '3'
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: hashie
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -107,22 +123,6 @@ dependencies:
107
123
  - - ! '>='
108
124
  - !ruby/object:Gem::Version
109
125
  version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: activesupport
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ! '>'
116
- - !ruby/object:Gem::Version
117
- version: '3.0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>'
124
- - !ruby/object:Gem::Version
125
- version: '3.0'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: activemodel
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -385,8 +385,8 @@ files:
385
385
  - examples/mongoid_article.rb
386
386
  - examples/ohm_article.rb
387
387
  - examples/riak_article.rb
388
- - gemfiles/3.gemfile
389
- - gemfiles/4.gemfile
388
+ - gemfiles/3.0.gemfile
389
+ - gemfiles/4.0.gemfile
390
390
  - lib/elasticsearch/model.rb
391
391
  - lib/elasticsearch/model/adapter.rb
392
392
  - lib/elasticsearch/model/adapters/active_record.rb
@@ -394,6 +394,7 @@ files:
394
394
  - lib/elasticsearch/model/adapters/mongoid.rb
395
395
  - lib/elasticsearch/model/callbacks.rb
396
396
  - lib/elasticsearch/model/client.rb
397
+ - lib/elasticsearch/model/ext/active_record.rb
397
398
  - lib/elasticsearch/model/importing.rb
398
399
  - lib/elasticsearch/model/indexing.rb
399
400
  - lib/elasticsearch/model/naming.rb
@@ -406,7 +407,6 @@ files:
406
407
  - lib/elasticsearch/model/response/results.rb
407
408
  - lib/elasticsearch/model/searching.rb
408
409
  - lib/elasticsearch/model/serializing.rb
409
- - lib/elasticsearch/model/support/forwardable.rb
410
410
  - lib/elasticsearch/model/version.rb
411
411
  - test/integration/active_record_associations_parent_child.rb
412
412
  - test/integration/active_record_associations_test.rb
@@ -453,9 +453,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
453
453
  required_rubygems_version: !ruby/object:Gem::Requirement
454
454
  none: false
455
455
  requirements:
456
- - - ! '>'
456
+ - - ! '>='
457
457
  - !ruby/object:Gem::Version
458
- version: 1.3.1
458
+ version: '0'
459
459
  requirements: []
460
460
  rubyforge_project:
461
461
  rubygems_version: 1.8.23
@@ -1,11 +0,0 @@
1
- # Usage:
2
- #
3
- # $ BUNDLE_GEMFILE=./gemfiles/3.gemfile bundle install
4
- # $ BUNDLE_GEMFILE=./gemfiles/3.gemfile bundle exec rake test:integration
5
-
6
- source 'https://rubygems.org'
7
-
8
- gem 'activerecord', '~> 3.2'
9
- gem 'mongoid', '>= 3.0'
10
-
11
- gemspec path: '../'
@@ -1,11 +0,0 @@
1
- # Usage:
2
- #
3
- # $ BUNDLE_GEMFILE=./gemfiles/4.gemfile bundle install
4
- # $ BUNDLE_GEMFILE=./gemfiles/4.gemfile bundle exec rake test:integration
5
-
6
- source 'https://rubygems.org'
7
-
8
- gem 'activerecord', '~> 4'
9
- gem 'mongoid', '~> 4.0.0.alpha1'
10
-
11
- gemspec path: '../'
@@ -1,44 +0,0 @@
1
- module Elasticsearch
2
- module Model
3
- module Support
4
-
5
- # Lightweight wrapper around "forwardable.rb" interface,
6
- # to allow easy implementation changes in the future.
7
- #
8
- # Cf. https://github.com/mongoid/origin/blob/master/lib/origin/forwardable.rb
9
- #
10
- module Forwardable
11
- def self.extended(base)
12
- base.__send__ :extend, ::Forwardable
13
- base.__send__ :extend, ::SingleForwardable
14
- end
15
-
16
- # Forwards specific method(s) to the provided receiver
17
- #
18
- # @example Forward the `each` method to `results` object
19
- #
20
- # MyClass.forward(:results, :each)
21
- #
22
- # @example Forward the `include?` method to `ancestors` class method
23
- #
24
- # MyClass.forward(:'self.ancestors', :include?)
25
- #
26
- # @param [ Symbol ] receiver The name of the receiver method
27
- # @param [ Symbol, Array ] methods The forwarded methods
28
- #
29
- # @api private
30
- #
31
- def forward(receiver, *methods)
32
- methods = Array(methods).flatten
33
- target = self.__send__ :eval, receiver.to_s rescue nil
34
-
35
- if target
36
- single_delegate methods => receiver
37
- else
38
- instance_delegate methods => receiver
39
- end
40
- end; module_function :forward
41
- end
42
- end
43
- end
44
- end