tire_async_index 0.2.0 → 0.2.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
  SHA1:
3
- metadata.gz: e1afa186dedd7fe80f38bb488bf077e1ff2e85b5
4
- data.tar.gz: 9432299f7e026815033fc47893283e3fee927236
3
+ metadata.gz: ee879c3935e505e60740944e6c5b2227eaeff745
4
+ data.tar.gz: ae62e2506ff7edd585553ea10320c12c1683b11f
5
5
  SHA512:
6
- metadata.gz: 8a2647253801a63bcc58e39e73c31a2684da461f2f9f15b9191a11c6887bc3b831ad1ea2f024ef301bee17caf74e6f263410d0106d2ec66cf75b218201f9a8c9
7
- data.tar.gz: fd6514f0d283ab6c9addd3286fc411755a69f6395bfe80b4a4b320010587a512a28d85f485f645d315b10aa8fb336026f63eafea0d666c6ed605bbd4ca3f2b74
6
+ metadata.gz: 1a60f3de5dc39526a7128dbd38e76618db72c629ee1d71ca27453e95663a7d41ee7e3b461a300ac80cf49871df94586850c9b5f1367eaf2f7c324e6ba130b7a6
7
+ data.tar.gz: 676449173b46273ffa10fd6839cc4514b8aedefcb9c7bd5b363268fd8ecf5fea552f67294ed6ab59327563f3ae59bb9d19b9066d53c9b677dab9317e83c4da4e
@@ -1,3 +1,7 @@
1
+ ## 0.2.1
2
+
3
+ * added `find_class_const` for full suuport of rubies (@we4tech)
4
+
1
5
  ## 0.2.0
2
6
 
3
7
  * ActiveModel support
@@ -1,3 +1,3 @@
1
1
  module TireAsyncIndex
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -12,7 +12,7 @@ module TireAsyncIndex
12
12
  # id - Document id
13
13
  #
14
14
  def perform(action_type, class_name, id)
15
- klass = Kernel.const_get(class_name)
15
+ klass = find_class_const(class_name)
16
16
 
17
17
  case action_type.to_sym
18
18
  when :update
@@ -28,6 +28,16 @@ module TireAsyncIndex
28
28
  end
29
29
  end
30
30
  end
31
+
32
+ def find_class_const(class_name)
33
+ if defined?(RUBY_VERSION) && RUBY_VERSION.match(/^2\./)
34
+ Kernel.const_get(class_name)
35
+ else
36
+ class_name.split('::').reduce(Object) do |mod, const_name|
37
+ mod.const_get(const_name)
38
+ end
39
+ end
40
+ end
31
41
  end
32
42
  end
33
43
  end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+ require 'tire'
3
+ require 'sidekiq'
4
+ require 'resque'
5
+ require 'tire_async_index'
6
+
7
+ module Level1
8
+ module Level2
9
+ class Model
10
+ end
11
+ end
12
+ end
13
+
14
+ describe TireAsyncIndex::Workers::UpdateIndex do
15
+
16
+ describe '#perform' do
17
+ let(:instance) { described_class.new }
18
+
19
+ it 'resolves class constant' do
20
+ expect {
21
+ instance.perform(:nothing, 'Level1::Level2::Model', 123)
22
+ }.not_to raise_error
23
+ end
24
+ end
25
+
26
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tire_async_index
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Efremov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-26 00:00:00.000000000 Z
11
+ date: 2013-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tire
@@ -149,6 +149,7 @@ files:
149
149
  - spec/active_record_tire_async_index_spec.rb
150
150
  - spec/test_helper.rb
151
151
  - spec/test_schema.rb
152
+ - spec/update_index_spec.rb
152
153
  - tire_async_index.gemspec
153
154
  homepage: http://github.com/EvilFaeton/tire_async_index
154
155
  licenses:
@@ -179,3 +180,4 @@ test_files:
179
180
  - spec/active_record_tire_async_index_spec.rb
180
181
  - spec/test_helper.rb
181
182
  - spec/test_schema.rb
183
+ - spec/update_index_spec.rb