elasticsearch-persistence 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +238 -7
  4. data/elasticsearch-persistence.gemspec +4 -1
  5. data/examples/music/album.rb +34 -0
  6. data/examples/music/artist.rb +50 -0
  7. data/examples/music/artists/_form.html.erb +8 -0
  8. data/examples/music/artists/artists_controller.rb +67 -0
  9. data/examples/music/artists/artists_controller_test.rb +53 -0
  10. data/examples/music/artists/index.html.erb +57 -0
  11. data/examples/music/artists/show.html.erb +51 -0
  12. data/examples/music/assets/application.css +226 -0
  13. data/examples/music/assets/autocomplete.css +48 -0
  14. data/examples/music/assets/blank_cover.png +0 -0
  15. data/examples/music/assets/form.css +113 -0
  16. data/examples/music/index_manager.rb +60 -0
  17. data/examples/music/search/index.html.erb +93 -0
  18. data/examples/music/search/search_controller.rb +41 -0
  19. data/examples/music/search/search_controller_test.rb +9 -0
  20. data/examples/music/search/search_helper.rb +15 -0
  21. data/examples/music/suggester.rb +45 -0
  22. data/examples/music/template.rb +392 -0
  23. data/examples/music/vendor/assets/jquery-ui-1.10.4.custom.min.css +7 -0
  24. data/examples/music/vendor/assets/jquery-ui-1.10.4.custom.min.js +6 -0
  25. data/examples/{sinatra → notes}/.gitignore +0 -0
  26. data/examples/{sinatra → notes}/Gemfile +0 -0
  27. data/examples/{sinatra → notes}/README.markdown +0 -0
  28. data/examples/{sinatra → notes}/application.rb +0 -0
  29. data/examples/{sinatra → notes}/config.ru +0 -0
  30. data/examples/{sinatra → notes}/test.rb +0 -0
  31. data/lib/elasticsearch/persistence.rb +19 -0
  32. data/lib/elasticsearch/persistence/model.rb +129 -0
  33. data/lib/elasticsearch/persistence/model/base.rb +75 -0
  34. data/lib/elasticsearch/persistence/model/errors.rb +8 -0
  35. data/lib/elasticsearch/persistence/model/find.rb +171 -0
  36. data/lib/elasticsearch/persistence/model/rails.rb +39 -0
  37. data/lib/elasticsearch/persistence/model/store.rb +239 -0
  38. data/lib/elasticsearch/persistence/model/utils.rb +0 -0
  39. data/lib/elasticsearch/persistence/repository.rb +3 -1
  40. data/lib/elasticsearch/persistence/repository/search.rb +25 -0
  41. data/lib/elasticsearch/persistence/version.rb +1 -1
  42. data/lib/rails/generators/elasticsearch/model/model_generator.rb +21 -0
  43. data/lib/rails/generators/elasticsearch/model/templates/model.rb.tt +9 -0
  44. data/lib/rails/generators/elasticsearch_generator.rb +2 -0
  45. data/test/integration/model/model_basic_test.rb +157 -0
  46. data/test/integration/repository/default_class_test.rb +6 -0
  47. data/test/unit/model_base_test.rb +40 -0
  48. data/test/unit/model_find_test.rb +147 -0
  49. data/test/unit/model_gateway_test.rb +99 -0
  50. data/test/unit/model_rails_test.rb +88 -0
  51. data/test/unit/model_store_test.rb +493 -0
  52. data/test/unit/repository_search_test.rb +17 -0
  53. metadata +79 -9
@@ -92,6 +92,23 @@ class Elasticsearch::Persistence::RepositorySearchTest < Test::Unit::TestCase
92
92
  subject.search 123
93
93
  end
94
94
  end
95
+
96
+ should "return the number of domain objects" do
97
+ subject.expects(:search)
98
+ .returns(Elasticsearch::Persistence::Repository::Response::Results.new( subject, {'hits' => { 'total' => 1 }}))
99
+ assert_equal 1, subject.count
100
+ end
101
+
102
+ should "pass arguments from count to search" do
103
+ subject.expects(:search)
104
+ .with do |query_or_definition, options|
105
+ assert_equal 'bar', query_or_definition[:query][:match][:foo]
106
+ assert_equal true, options[:ignore_unavailable]
107
+ end
108
+ .returns(Elasticsearch::Persistence::Repository::Response::Results.new( subject, {'hits' => { 'total' => 1 }}))
109
+
110
+ subject.count( { query: { match: { foo: 'bar' } } }, { ignore_unavailable: true } )
111
+ end
95
112
  end
96
113
 
97
114
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-persistence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-31 00:00:00.000000000 Z
11
+ date: 2014-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ! '>'
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activemodel
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>'
60
+ - !ruby/object:Gem::Version
61
+ version: '3'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>'
67
+ - !ruby/object:Gem::Version
68
+ version: '3'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: hashie
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,20 @@ dependencies:
66
80
  - - ! '>='
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: virtus
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: bundler
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +137,7 @@ dependencies:
109
137
  - !ruby/object:Gem::Version
110
138
  version: '0'
111
139
  - !ruby/object:Gem::Dependency
112
- name: virtus
140
+ name: rails
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
143
  - - ! '>='
@@ -278,14 +306,41 @@ files:
278
306
  - README.md
279
307
  - Rakefile
280
308
  - elasticsearch-persistence.gemspec
281
- - examples/sinatra/.gitignore
282
- - examples/sinatra/Gemfile
283
- - examples/sinatra/README.markdown
284
- - examples/sinatra/application.rb
285
- - examples/sinatra/config.ru
286
- - examples/sinatra/test.rb
309
+ - examples/music/album.rb
310
+ - examples/music/artist.rb
311
+ - examples/music/artists/_form.html.erb
312
+ - examples/music/artists/artists_controller.rb
313
+ - examples/music/artists/artists_controller_test.rb
314
+ - examples/music/artists/index.html.erb
315
+ - examples/music/artists/show.html.erb
316
+ - examples/music/assets/application.css
317
+ - examples/music/assets/autocomplete.css
318
+ - examples/music/assets/blank_cover.png
319
+ - examples/music/assets/form.css
320
+ - examples/music/index_manager.rb
321
+ - examples/music/search/index.html.erb
322
+ - examples/music/search/search_controller.rb
323
+ - examples/music/search/search_controller_test.rb
324
+ - examples/music/search/search_helper.rb
325
+ - examples/music/suggester.rb
326
+ - examples/music/template.rb
327
+ - examples/music/vendor/assets/jquery-ui-1.10.4.custom.min.css
328
+ - examples/music/vendor/assets/jquery-ui-1.10.4.custom.min.js
329
+ - examples/notes/.gitignore
330
+ - examples/notes/Gemfile
331
+ - examples/notes/README.markdown
332
+ - examples/notes/application.rb
333
+ - examples/notes/config.ru
334
+ - examples/notes/test.rb
287
335
  - lib/elasticsearch/persistence.rb
288
336
  - lib/elasticsearch/persistence/client.rb
337
+ - lib/elasticsearch/persistence/model.rb
338
+ - lib/elasticsearch/persistence/model/base.rb
339
+ - lib/elasticsearch/persistence/model/errors.rb
340
+ - lib/elasticsearch/persistence/model/find.rb
341
+ - lib/elasticsearch/persistence/model/rails.rb
342
+ - lib/elasticsearch/persistence/model/store.rb
343
+ - lib/elasticsearch/persistence/model/utils.rb
289
344
  - lib/elasticsearch/persistence/repository.rb
290
345
  - lib/elasticsearch/persistence/repository/class.rb
291
346
  - lib/elasticsearch/persistence/repository/find.rb
@@ -295,11 +350,20 @@ files:
295
350
  - lib/elasticsearch/persistence/repository/serialize.rb
296
351
  - lib/elasticsearch/persistence/repository/store.rb
297
352
  - lib/elasticsearch/persistence/version.rb
353
+ - lib/rails/generators/elasticsearch/model/model_generator.rb
354
+ - lib/rails/generators/elasticsearch/model/templates/model.rb.tt
355
+ - lib/rails/generators/elasticsearch_generator.rb
356
+ - test/integration/model/model_basic_test.rb
298
357
  - test/integration/repository/custom_class_test.rb
299
358
  - test/integration/repository/customized_class_test.rb
300
359
  - test/integration/repository/default_class_test.rb
301
360
  - test/integration/repository/virtus_model_test.rb
302
361
  - test/test_helper.rb
362
+ - test/unit/model_base_test.rb
363
+ - test/unit/model_find_test.rb
364
+ - test/unit/model_gateway_test.rb
365
+ - test/unit/model_rails_test.rb
366
+ - test/unit/model_store_test.rb
303
367
  - test/unit/persistence_test.rb
304
368
  - test/unit/repository_class_test.rb
305
369
  - test/unit/repository_client_test.rb
@@ -337,11 +401,17 @@ signing_key:
337
401
  specification_version: 4
338
402
  summary: Persistence layer for Ruby models and Elasticsearch.
339
403
  test_files:
404
+ - test/integration/model/model_basic_test.rb
340
405
  - test/integration/repository/custom_class_test.rb
341
406
  - test/integration/repository/customized_class_test.rb
342
407
  - test/integration/repository/default_class_test.rb
343
408
  - test/integration/repository/virtus_model_test.rb
344
409
  - test/test_helper.rb
410
+ - test/unit/model_base_test.rb
411
+ - test/unit/model_find_test.rb
412
+ - test/unit/model_gateway_test.rb
413
+ - test/unit/model_rails_test.rb
414
+ - test/unit/model_store_test.rb
345
415
  - test/unit/persistence_test.rb
346
416
  - test/unit/repository_class_test.rb
347
417
  - test/unit/repository_client_test.rb