elastic_record 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'elastic_record'
5
- s.version = '0.9.1'
5
+ s.version = '0.9.2'
6
6
  s.summary = 'Use Elastic Search with your objects'
7
7
  s.description = 'Find your records with elastic search'
8
8
 
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.author = 'Matthew Higgins'
14
14
  s.email = 'developer@matthewhiggins.com'
15
- s.homepage = 'http://github.com/matthuhiggins/elastic_record'
15
+ s.homepage = 'http://github.com/infogroup/elastic_record'
16
16
 
17
17
  s.extra_rdoc_files = ['README.rdoc']
18
18
  s.files = `git ls-files`.split("\n")
@@ -30,21 +30,22 @@ module ElasticRecord
30
30
  end.join(' AND ')
31
31
  end
32
32
 
33
- def match_word(word, fields, &block)
34
- word = escape(word)
35
- if word =~ / /
36
- word = "\"#{word}\""
37
- else
38
- word = "#{word}*"
39
- end
33
+ private
34
+
35
+ def match_word(word, fields, &block)
36
+ if word =~ / / || word =~ ESCAPE_REGEX
37
+ word = "\"#{word}\""
38
+ else
39
+ word = "#{word}*"
40
+ end
40
41
 
41
- or_query = fields.map do |field|
42
- field = yield(field) if block_given?
43
- "#{field}:#{word}"
44
- end.join(' OR ')
42
+ or_query = fields.map do |field|
43
+ field = yield(field) if block_given?
44
+ "#{field}:#{word}"
45
+ end.join(' OR ')
45
46
 
46
- "(#{or_query})"
47
- end
47
+ "(#{or_query})"
48
+ end
48
49
  end
49
50
  end
50
51
  end
@@ -75,6 +75,11 @@ module ElasticRecord
75
75
  association
76
76
  end
77
77
 
78
+ def reload
79
+ super
80
+ searches_many_cache.clear
81
+ end
82
+
78
83
  private
79
84
  def searches_many_cache
80
85
  @searches_many_cache ||= {}
@@ -11,6 +11,7 @@ class ElasticRecord::LuceneTest < MiniTest::Spec
11
11
  assert_smart_escape nil, nil, ['name']
12
12
 
13
13
  assert_smart_escape '(name:foo*)', 'foo', ['name']
14
+ assert_smart_escape '(name:"foo-bar")', 'foo-bar', ['name']
14
15
  assert_smart_escape "(name:bob's*)", "bob's", ['name']
15
16
  assert_smart_escape '(name.analyzed:foo*)', 'foo', ['name'] { |f| "#{f}.analyzed" }
16
17
  assert_smart_escape '(name:foo* OR street:foo*)', 'foo', ['name', 'street']
@@ -62,4 +62,15 @@ class ElasticRecord::SearchesManyTest < MiniTest::Spec
62
62
  assert_equal "blue", widgets.first.color
63
63
  assert_equal "Toy", widgets.first.name
64
64
  end
65
+
66
+ def test_reload
67
+ warehouse = Warehouse.create
68
+ widget = Widget.create name: 'Toy', color: 'green', warehouse: warehouse
69
+ assert_equal [widget], warehouse.widgets
70
+ widget.destroy
71
+
72
+ warehouse.reload
73
+
74
+ assert_equal [], warehouse.widgets
75
+ end
65
76
  end
@@ -95,4 +95,7 @@ module TestModel
95
95
  def destroyed?
96
96
  @destroyed
97
97
  end
98
+
99
+ def reload
100
+ end
98
101
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-22 00:00:00.000000000 Z
12
+ date: 2012-11-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: arelastic
@@ -116,7 +116,7 @@ files:
116
116
  - test/support/models/test_model.rb
117
117
  - test/support/models/warehouse.rb
118
118
  - test/support/models/widget.rb
119
- homepage: http://github.com/matthuhiggins/elastic_record
119
+ homepage: http://github.com/infogroup/elastic_record
120
120
  licenses:
121
121
  - MIT
122
122
  post_install_message: