elasticsearch-persistence 5.0.2 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +5 -5
  2. data/.rspec +2 -0
  3. data/Gemfile +9 -0
  4. data/README.md +206 -338
  5. data/Rakefile +15 -12
  6. data/elasticsearch-persistence.gemspec +6 -7
  7. data/examples/notes/application.rb +3 -4
  8. data/lib/elasticsearch/persistence.rb +2 -110
  9. data/lib/elasticsearch/persistence/repository.rb +212 -53
  10. data/lib/elasticsearch/persistence/repository/dsl.rb +94 -0
  11. data/lib/elasticsearch/persistence/repository/find.rb +27 -10
  12. data/lib/elasticsearch/persistence/repository/response/results.rb +21 -8
  13. data/lib/elasticsearch/persistence/repository/search.rb +30 -18
  14. data/lib/elasticsearch/persistence/repository/serialize.rb +65 -7
  15. data/lib/elasticsearch/persistence/repository/store.rb +38 -44
  16. data/lib/elasticsearch/persistence/version.rb +1 -1
  17. data/spec/repository/find_spec.rb +179 -0
  18. data/spec/repository/response/results_spec.rb +128 -0
  19. data/spec/repository/search_spec.rb +181 -0
  20. data/spec/repository/serialize_spec.rb +53 -0
  21. data/spec/repository/store_spec.rb +327 -0
  22. data/spec/repository_spec.rb +723 -0
  23. data/spec/spec_helper.rb +32 -0
  24. metadata +26 -104
  25. data/examples/music/album.rb +0 -54
  26. data/examples/music/artist.rb +0 -70
  27. data/examples/music/artists/_form.html.erb +0 -8
  28. data/examples/music/artists/artists_controller.rb +0 -67
  29. data/examples/music/artists/artists_controller_test.rb +0 -53
  30. data/examples/music/artists/index.html.erb +0 -60
  31. data/examples/music/artists/show.html.erb +0 -54
  32. data/examples/music/assets/application.css +0 -257
  33. data/examples/music/assets/autocomplete.css +0 -48
  34. data/examples/music/assets/blank_artist.png +0 -0
  35. data/examples/music/assets/blank_cover.png +0 -0
  36. data/examples/music/assets/form.css +0 -113
  37. data/examples/music/index_manager.rb +0 -73
  38. data/examples/music/search/index.html.erb +0 -95
  39. data/examples/music/search/search_controller.rb +0 -41
  40. data/examples/music/search/search_controller_test.rb +0 -12
  41. data/examples/music/search/search_helper.rb +0 -15
  42. data/examples/music/suggester.rb +0 -69
  43. data/examples/music/template.rb +0 -430
  44. data/examples/music/vendor/assets/jquery-ui-1.10.4.custom.min.css +0 -7
  45. data/examples/music/vendor/assets/jquery-ui-1.10.4.custom.min.js +0 -6
  46. data/examples/music/vendor/assets/stylesheets/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  47. data/lib/elasticsearch/persistence/client.rb +0 -51
  48. data/lib/elasticsearch/persistence/model.rb +0 -135
  49. data/lib/elasticsearch/persistence/model/base.rb +0 -87
  50. data/lib/elasticsearch/persistence/model/errors.rb +0 -8
  51. data/lib/elasticsearch/persistence/model/find.rb +0 -180
  52. data/lib/elasticsearch/persistence/model/rails.rb +0 -47
  53. data/lib/elasticsearch/persistence/model/store.rb +0 -254
  54. data/lib/elasticsearch/persistence/model/utils.rb +0 -0
  55. data/lib/elasticsearch/persistence/repository/class.rb +0 -71
  56. data/lib/elasticsearch/persistence/repository/naming.rb +0 -115
  57. data/lib/rails/generators/elasticsearch/model/model_generator.rb +0 -21
  58. data/lib/rails/generators/elasticsearch/model/templates/model.rb.tt +0 -9
  59. data/lib/rails/generators/elasticsearch_generator.rb +0 -2
  60. data/test/integration/model/model_basic_test.rb +0 -233
  61. data/test/integration/repository/custom_class_test.rb +0 -85
  62. data/test/integration/repository/customized_class_test.rb +0 -82
  63. data/test/integration/repository/default_class_test.rb +0 -116
  64. data/test/integration/repository/virtus_model_test.rb +0 -118
  65. data/test/test_helper.rb +0 -55
  66. data/test/unit/model_base_test.rb +0 -72
  67. data/test/unit/model_find_test.rb +0 -153
  68. data/test/unit/model_gateway_test.rb +0 -101
  69. data/test/unit/model_rails_test.rb +0 -112
  70. data/test/unit/model_store_test.rb +0 -576
  71. data/test/unit/persistence_test.rb +0 -32
  72. data/test/unit/repository_class_test.rb +0 -51
  73. data/test/unit/repository_client_test.rb +0 -32
  74. data/test/unit/repository_find_test.rb +0 -388
  75. data/test/unit/repository_indexing_test.rb +0 -37
  76. data/test/unit/repository_module_test.rb +0 -146
  77. data/test/unit/repository_naming_test.rb +0 -146
  78. data/test/unit/repository_response_results_test.rb +0 -98
  79. data/test/unit/repository_search_test.rb +0 -117
  80. data/test/unit/repository_serialize_test.rb +0 -57
  81. data/test/unit/repository_store_test.rb +0 -303
@@ -1,53 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ArtistsControllerTest < ActionController::TestCase
4
- setup do
5
- IndexManager.create_index force: true
6
- @artist = Artist.create(id: 1, name: 'TEST')
7
- Artist.gateway.refresh_index!
8
- end
9
-
10
- test "should get index" do
11
- get :index
12
- assert_response :success
13
- assert_not_nil assigns(:artists)
14
- end
15
-
16
- test "should get new" do
17
- get :new
18
- assert_response :success
19
- end
20
-
21
- test "should create artist" do
22
- assert_difference('Artist.count') do
23
- post :create, artist: { name: @artist.name }
24
- Artist.gateway.refresh_index!
25
- end
26
-
27
- assert_redirected_to artist_path(assigns(:artist))
28
- end
29
-
30
- test "should show artist" do
31
- get :show, id: @artist
32
- assert_response :success
33
- end
34
-
35
- test "should get edit" do
36
- get :edit, id: @artist
37
- assert_response :success
38
- end
39
-
40
- test "should update artist" do
41
- patch :update, id: @artist, artist: { name: @artist.name }
42
- assert_redirected_to artist_path(assigns(:artist))
43
- end
44
-
45
- test "should destroy artist" do
46
- assert_difference('Artist.count', -1) do
47
- delete :destroy, id: @artist
48
- Artist.gateway.refresh_index!
49
- end
50
-
51
- assert_redirected_to artists_path
52
- end
53
- end
@@ -1,60 +0,0 @@
1
- <header>
2
- <h1>
3
- Artists
4
- <%= button_to 'New Artist', new_artist_path, method: 'get', tabindex: 5 %>
5
- </h1>
6
- </header>
7
-
8
- <section id="searchbox">
9
- <%= form_tag search_path, method: 'get' do %>
10
- <input type="text" name="q" value="<%= params[:q] %>" id="q" autofocus="autofocus" placeholder="start typing to search..." tabindex="0" />
11
- <% end %>
12
- </section>
13
-
14
- <section class="artists">
15
- <% @artists.each do |artist| %>
16
- <%= div_for artist, class: 'result clearfix' do %>
17
- <h2>
18
- <%= image_tag "http://ruby.elastic.co.s3-website-us-east-1.amazonaws.com/demo/music/bands/#{artist.id}.jpeg", height: '50px', class: 'band' %>
19
- <%= link_to artist do %>
20
- <span class="name"><%= artist.name %></span>
21
- <small><%= pluralize artist.album_count, 'album' %></small>
22
- <% end %>
23
- </h2>
24
- <div class="actions clearfix">
25
- <%= button_to 'Edit', edit_artist_path(artist), method: 'get' %>
26
- <%= button_to 'Destroy', artist, method: :delete, data: { confirm: 'Are you sure?' } %>
27
- </div>
28
- <% end %>
29
- <% end %>
30
- </section>
31
-
32
- <% if @artists.empty? %>
33
- <section class="no-results">
34
- <p>The search hasn't returned any results...</p>
35
- </section>
36
- <% end %>
37
-
38
- <script>
39
- $.widget( "custom.suggest", $.ui.autocomplete, {
40
- _renderMenu: function( ul, items ) {
41
- $.each( items, function( index, item ) {
42
- var category = ul.append( "<li class='ui-autocomplete-category'>" + item.label + "</li>" );
43
-
44
- $.each( item.value, function( index, item ) {
45
- var li = $('<li class="ui-autocomplete-item"><a href="<%= Rails.application.config.relative_url_root %>'+ item.url +'">'+ item.text +'</a></li>').data('ui-autocomplete-item', item )
46
- category.append(li)
47
- } )
48
- });
49
- }
50
- });
51
-
52
- $( "#q" ).suggest({
53
- source: '<%= suggest_path %>',
54
- select: function(event, ui) {
55
- document.location.href = '<%= Rails.application.config.relative_url_root %>'+ui.item.url
56
- }
57
- });
58
- </script>
59
-
60
- <script>$('img.band').error(function(){ $(this).attr('src', '/images/blank_artist.png'); });</script>
@@ -1,54 +0,0 @@
1
- <div class="artist">
2
- <header>
3
- <h1>
4
- <span class="back"><%= link_to "〈".html_safe, artists_path, title: "Back" %></span>
5
- <%= image_tag "http://ruby.elastic.co.s3-website-us-east-1.amazonaws.com/demo/music/bands/#{@artist.id}.jpeg", height: '50px', class: 'band' %>
6
- <%= @artist.name %>
7
- <%= button_to 'Edit', edit_artist_path(@artist), method: 'get' %>
8
- </h1>
9
- </header>
10
-
11
- <p id="notice"><%= notice %></p>
12
-
13
- <section class="artist-info">
14
- <span><%= @artist.members.to_sentence last_word_connector: ' and ' %></span> |
15
- <span><%= pluralize @albums.size, 'album' %></span>
16
- <p class="artist-profile"><%= @artist.profile %></p>
17
- </section>
18
-
19
- <section class="albums">
20
- <% @albums.each do |album| %>
21
- <%= div_for album, class: 'clearfix' do %>
22
- <h3>
23
- <span class="title"><%= album.title %></span>
24
- <div class="info">
25
- <small><%= album.meta.formats.join(', ') %></small>
26
- <small><%= album.released %></small>
27
- </div>
28
- </h3>
29
-
30
- <div class="cover">
31
- <%= image_tag "http://ruby.elastic.co.s3-website-us-east-1.amazonaws.com/demo/music/covers/#{album.id}.jpeg", width: '100px', class: 'cover' %>
32
- </div>
33
-
34
- <div class="content">
35
- <% album.tracklist.in_groups_of(album.tracklist.size/2+1).each_with_index do |half, g| %>
36
- <ul class=<%= cycle 'first', 'second' %> start="<%= g < 1 ? 1 : album.tracklist.size/2+2 %>">
37
- <% half.compact.each_with_index do |track, i| %>
38
- <li>
39
- <i class="counter"><%= g < 1 ? i+1 : i+(g*album.tracklist.size/2+2) %></i>
40
- <%= track['title'] %>
41
- <small><%= track['duration'] %></small>
42
- </li>
43
- <% end %>
44
- </ul>
45
- <% end %>
46
- </div>
47
- <% end %>
48
-
49
- <% end %>
50
-
51
- <script>$('img').error(function(){ $(this).attr('src', '/images/blank_cover.png'); });</script>
52
- <script>$(document.location.hash).effect('highlight', 1500)</script>
53
- </section>
54
- </div>
@@ -1,257 +0,0 @@
1
- /*
2
- *= require_tree .
3
- *= require_self
4
- *= require ui-lightness/jquery-ui-1.10.4.custom.min.css
5
- */
6
-
7
- .clearfix {
8
- *zoom: 1;
9
- }
10
-
11
- .clearfix:before,
12
- .clearfix:after {
13
- display: table;
14
- line-height: 0;
15
- content: "";
16
- }
17
-
18
- .clearfix:after {
19
- clear: both;
20
- }
21
-
22
- body {
23
- font-family: 'Helvetica Neue', Helvetica, sans-serif !important;
24
- margin: 2em 4em;
25
- }
26
-
27
- header {
28
- margin: 0;
29
- padding: 0 0 1em 0;
30
- border-bottom: 1px solid #666;
31
- }
32
-
33
- header h1 {
34
- color: #999;
35
- font-weight: 100;
36
- text-transform: uppercase;
37
- margin: 0; padding: 0;
38
- }
39
-
40
- header a {
41
- color: #0b6aff;
42
- text-decoration: none;
43
- }
44
-
45
- header .back {
46
- font-size: 100%;
47
- margin: 0 0.5em 0 -0.5em;
48
- }
49
-
50
- h1 form {
51
- float: right;
52
- }
53
-
54
- #searchbox {
55
- border-bottom: 1px solid #666;
56
- }
57
-
58
- #searchbox input {
59
- color: #444;
60
- font-size: 100%;
61
- font-weight: 100;
62
- border: none;
63
- padding: 1em 0 1em 0;
64
- width: 100%;
65
- }
66
-
67
- #searchbox input:focus {
68
- outline-width: 0;
69
- }
70
-
71
- .actions form {
72
- float: right;
73
- position: relative;
74
- top: 0.2em;
75
- }
76
-
77
- .no-results {
78
- font-weight: 200;
79
- font-size: 200%;
80
- }
81
-
82
- .result,
83
- .artist {
84
- padding: 1em 0 1em 0;
85
- margin: 0;
86
- border-bottom: 1px solid #999;
87
- }
88
-
89
- .result:hover,
90
- .artist:hover {
91
- background: #f9f9f9;
92
- }
93
-
94
- .result h2,
95
- .artist h2 {
96
- color: #444;
97
- margin: 0;
98
- padding: 0;
99
- }
100
-
101
- .artist h2 {
102
- float: left;
103
- margin-left: 50px;
104
- }
105
-
106
- .artist.search.result h2 {
107
- float: none;
108
- }
109
-
110
- .artist h1 .back {
111
- margin-right: 65px;
112
- }
113
-
114
- .artist h1 img.band {
115
- left: 120px;
116
- top: 50px;
117
- }
118
-
119
- .result h2 a,
120
- .artist h2 a {
121
- color: #444;
122
- }
123
-
124
- .result h2 small,
125
- .artist h2 small {
126
- font-size: 70%;
127
- font-weight: 100;
128
- margin-left: 0.5em;
129
- }
130
-
131
- .result h2 a,
132
- .artist h2 a {
133
- text-decoration: none;
134
- }
135
-
136
- .result h2 a:hover name,
137
- .artist h2 a:hover .name {
138
- text-decoration: underline;
139
- }
140
-
141
- .result .highlight.small {
142
- font-size: 90%;
143
- font-weight: 200;
144
- padding: 0;
145
- margin: 0.25em 0 0.25em 50px;
146
- }
147
-
148
- .result .small .label {
149
- color: #999;
150
- font-size: 80%;
151
- /*min-width: 5em;*/
152
- display: inline-block;
153
- }
154
-
155
- .artist-info {
156
- color: #5f5f5f;
157
- text-transform: uppercase;
158
- font-weight: 200;
159
- border-bottom: 1px solid #666;
160
- padding: 0 0 1em 0;
161
- margin: 0 0 1em 0;
162
- }
163
-
164
- .artist-profile {
165
- color: #999;
166
- font-size: 95%;
167
- font-weight: 100;
168
- text-transform: none;
169
- padding: 0;
170
- margin: 0.25em 0 0 0;
171
- }
172
-
173
- .artist img.band {
174
- position: absolute;
175
- left: 85px;
176
- margin-top: 14px;
177
- transform: translate(-50%,-50%);
178
- clip-path: circle(20px at center);
179
- }
180
-
181
- .album {
182
- margin: 0 0 4em 0;
183
- }
184
-
185
- .album.search.result {
186
- margin: 0;
187
- }
188
-
189
- .album .cover {
190
- float: left;
191
- width: 150px;
192
- }
193
-
194
- .album.search.result .cover {
195
- width: 40px;
196
- margin-right: 10px;
197
- }
198
-
199
- .album .cover img {
200
- border: 1px solid rgba(0,0,0,0.15);
201
- box-shadow: 0px 0px 1px 0px rgba(0,0,0,0.05);
202
- }
203
-
204
- .album .content {
205
- float: left;
206
- margin-left: 25px;
207
- }
208
-
209
- .album .content ul {
210
- float: left;
211
- margin: 0 2em 0 0;
212
- padding: 0;
213
- min-width: 18em;
214
- }
215
-
216
- .album .content ul li {
217
- line-height: 1.5em;
218
- padding: 0.5em 0 0.5em 0;
219
- border-bottom:1px solid #f8f8f8;
220
- list-style: none;
221
- }
222
-
223
- .album .content ul li .counter {
224
- color: #999;
225
- font-style: normal;
226
- font-size: 80%;
227
- font-weight: 100;
228
- margin-right: 0.5em;
229
- }
230
-
231
- .album h3 {
232
- margin: 0; padding: 0;
233
- border-bottom: 2px solid #e0e0e0;
234
- padding: 0 0 0.5em 0;
235
- margin: 0 0 1em 0;
236
- }
237
-
238
- .album h3 .title {
239
- text-transform: uppercase;
240
- font-weight: 200;
241
- }
242
-
243
- .album small {
244
- color: #a3a3a3;
245
- font-weight: 200;
246
- }
247
-
248
- .album .info {
249
- float: right;
250
- }
251
-
252
- em[class^=hl] {
253
- font-style: normal;
254
- background: #e6efff;
255
- padding: 0.15em 0.35em;
256
- border-radius: 5px;
257
- }
@@ -1,48 +0,0 @@
1
- .ui-autocomplete {
2
- font-family: 'Helvetica Neue', Helvetica, sans-serif !important;
3
- border: none !important;
4
- border-radius: 0 !important;
5
- background-color: #fff !important;
6
- margin: 0 !important;
7
- padding: 0 !important;
8
- box-shadow: 0px 3px 3px 0px rgba(0,0,0,0.75);
9
- }
10
-
11
- .ui-autocomplete-category {
12
- color: #fff;
13
- background: #222;
14
- font-size: 90%;
15
- font-weight: 300;
16
- text-transform: uppercase;
17
- margin: 0 !important;
18
- padding: 0.25em 0.5em 0.25em 0.5em;
19
- }
20
-
21
- .ui-autocomplete-item {
22
- border-bottom: 1px solid #000;
23
- margin: 0 !important;
24
- padding: 0 !important;
25
- }
26
-
27
- .ui-autocomplete-item:hover,
28
- .ui-autocomplete-item:focus {
29
- color: #fff !important;
30
- background: #0b6aff !important;
31
- }
32
-
33
- .ui-state-focus,
34
- .ui-state-focus a,
35
- .ui-state-active,
36
- .ui-state-active a,
37
- .ui-autocomplete-item:hover a {
38
- color: #fff !important;
39
- background: #0b6aff !important;
40
- outline: none !important;
41
- border: none !important;
42
- border-radius: 0 !important;
43
- }
44
-
45
- a.ui-state-focus,
46
- a.ui-state-active {
47
- margin: 0px !important;
48
- }