indices 0.0.1 → 4.0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. metadata +13 -185
  3. data/MIT-LICENSE +0 -20
  4. data/README.md +0 -245
  5. data/Rakefile +0 -19
  6. data/lib/generators/indices/index_generator.rb +0 -15
  7. data/lib/generators/indices/install_generator.rb +0 -15
  8. data/lib/generators/indices/templates/index.rb +0 -12
  9. data/lib/generators/indices/templates/initializer.rb +0 -10
  10. data/lib/indices.rb +0 -102
  11. data/lib/indices/collection.rb +0 -195
  12. data/lib/indices/concern.rb +0 -23
  13. data/lib/indices/configuration.rb +0 -39
  14. data/lib/indices/dsl/api.rb +0 -85
  15. data/lib/indices/dsl/mappings.rb +0 -14
  16. data/lib/indices/dsl/search.rb +0 -25
  17. data/lib/indices/dsl/serializer.rb +0 -17
  18. data/lib/indices/index.rb +0 -149
  19. data/lib/indices/pagination.rb +0 -33
  20. data/lib/indices/proxy.rb +0 -17
  21. data/lib/indices/railtie.rb +0 -15
  22. data/lib/indices/version.rb +0 -5
  23. data/lib/tasks/indices.rake +0 -11
  24. data/test/dsl_test.rb +0 -92
  25. data/test/dummy/Rakefile +0 -5
  26. data/test/dummy/app/assets/javascripts/application.js +0 -13
  27. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  28. data/test/dummy/app/controllers/application_controller.rb +0 -5
  29. data/test/dummy/app/helpers/application_helper.rb +0 -2
  30. data/test/dummy/app/indices/products_index.rb +0 -51
  31. data/test/dummy/app/indices/shops_index.rb +0 -28
  32. data/test/dummy/app/models/product.rb +0 -5
  33. data/test/dummy/app/models/shop.rb +0 -5
  34. data/test/dummy/app/views/layouts/application.html.erb +0 -12
  35. data/test/dummy/bin/bundle +0 -4
  36. data/test/dummy/bin/rails +0 -5
  37. data/test/dummy/bin/rake +0 -5
  38. data/test/dummy/bin/setup +0 -30
  39. data/test/dummy/config.ru +0 -4
  40. data/test/dummy/config/application.rb +0 -25
  41. data/test/dummy/config/boot.rb +0 -5
  42. data/test/dummy/config/database.yml +0 -7
  43. data/test/dummy/config/database.yml.travis +0 -3
  44. data/test/dummy/config/environment.rb +0 -5
  45. data/test/dummy/config/environments/development.rb +0 -41
  46. data/test/dummy/config/environments/production.rb +0 -79
  47. data/test/dummy/config/environments/test.rb +0 -42
  48. data/test/dummy/config/initializers/assets.rb +0 -11
  49. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  50. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  51. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  52. data/test/dummy/config/initializers/indices.rb +0 -67
  53. data/test/dummy/config/initializers/inflections.rb +0 -16
  54. data/test/dummy/config/initializers/mime_types.rb +0 -4
  55. data/test/dummy/config/initializers/session_store.rb +0 -3
  56. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  57. data/test/dummy/config/locales/en.yml +0 -23
  58. data/test/dummy/config/routes.rb +0 -56
  59. data/test/dummy/config/secrets.yml +0 -22
  60. data/test/dummy/db/migrate/20161104164148_create_products.rb +0 -12
  61. data/test/dummy/db/migrate/20161104182219_create_shops.rb +0 -7
  62. data/test/dummy/db/schema.rb +0 -36
  63. data/test/dummy/log/development.log +0 -156
  64. data/test/dummy/log/test.log +0 -10249
  65. data/test/dummy/public/404.html +0 -67
  66. data/test/dummy/public/422.html +0 -67
  67. data/test/dummy/public/500.html +0 -66
  68. data/test/dummy/public/favicon.ico +0 -0
  69. data/test/generators_test.rb +0 -25
  70. data/test/indices_test.rb +0 -46
  71. data/test/record_test.rb +0 -25
  72. data/test/search_test.rb +0 -164
  73. data/test/tasks_test.rb +0 -25
  74. data/test/test_helper.rb +0 -14
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/404.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The page you were looking for doesn't exist.</h1>
62
- <p>You may have mistyped the address or the page may have moved.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/422.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The change you wanted was rejected.</h1>
62
- <p>Maybe you tried to change something you didn't have access to.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,66 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/500.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>We're sorry, but something went wrong.</h1>
62
- </div>
63
- <p>If you are the application owner check the logs for more information.</p>
64
- </div>
65
- </body>
66
- </html>
File without changes
@@ -1,25 +0,0 @@
1
- require 'test_helper'
2
- require 'rails/generators'
3
- require 'generators/indices/install_generator'
4
- require 'generators/indices/index_generator'
5
-
6
- class GeneratorsTest < Rails::Generators::TestCase
7
- destination File.expand_path('../tmp', File.dirname(__FILE__))
8
-
9
- teardown do
10
- FileUtils.rm_rf self.destination_root
11
- end
12
-
13
- test 'install' do
14
- self.class.tests Indices::Generators::InstallGenerator
15
- run_generator
16
- assert_file 'config/initializers/indices.rb'
17
- end
18
-
19
- test 'index' do
20
- self.class.tests Indices::Generators::IndexGenerator
21
- run_generator %w(products)
22
- assert_file 'app/indices/products_index.rb'
23
- end
24
-
25
- end
@@ -1,46 +0,0 @@
1
- require 'test_helper'
2
-
3
- class IndicesTest < ActiveSupport::TestCase
4
-
5
- setup do
6
- Indices.build
7
- end
8
-
9
- teardown do
10
- Indices.destroy
11
- end
12
-
13
- test 'namespace' do
14
- assert_equal 'dummy_test', Indices.namespace
15
- end
16
-
17
- test 'find' do
18
- assert Indices.find(:products)
19
- end
20
-
21
- test 'exist' do
22
- assert Indices.exist?(:products)
23
- end
24
-
25
- test 'suggest' do
26
- shop = Shop.create
27
- ['Les Paul', 'Stratocaster'].each do |name|
28
- product = shop.products.create(name: name)
29
- product.run_callbacks :commit
30
- end
31
- sleep 2
32
-
33
- assert_equal [], suggest('', shop)
34
- assert_equal ['Les Paul'], suggest('les', shop)
35
- assert_equal ['Stratocaster'], suggest('str', shop)
36
- end
37
-
38
- private
39
-
40
- def suggest(term, shop)
41
- Indices.suggest(:products, term, shop: shop).map do |suggestion|
42
- suggestion[:text]
43
- end
44
- end
45
-
46
- end
@@ -1,25 +0,0 @@
1
- require 'test_helper'
2
-
3
- class RecordTest < ActiveSupport::TestCase
4
-
5
- setup do
6
- Indices.build
7
- end
8
-
9
- teardown do
10
- Indices.destroy
11
- end
12
-
13
- test 'indexing' do
14
- shop = Shop.create(name: 'Anderstons')
15
- product = shop.products.create(name: 'Les Paul', category: 'Gibson')
16
- product.run_callbacks :commit
17
- sleep 2
18
-
19
- assert_equal 1, Product.search.count
20
- product.destroy
21
- product.run_callbacks :commit
22
- assert_equal 0, Product.search.count
23
- end
24
-
25
- end
@@ -1,164 +0,0 @@
1
- require 'test_helper'
2
-
3
- class SearchTest < ActiveSupport::TestCase
4
-
5
- setup do
6
- Indices.build
7
- end
8
-
9
- teardown do
10
- Indices.destroy
11
- end
12
-
13
- test 'order' do
14
- shop = Shop.create
15
- shop.run_callbacks :commit
16
- (1..3).step do |id|
17
- product = shop.products.create(
18
- id: id,
19
- name: id,
20
- price: id,
21
- position: id,
22
- currency: 'UYU'
23
- )
24
- product.run_callbacks :commit
25
- product
26
- end
27
- sleep 2
28
-
29
- assert_equal [1, 2, 3], Product.search.order(id: :asc).map(&:id)
30
- assert_equal [3, 2, 1], Product.search.order(id: :desc).map(&:id)
31
-
32
- assert_equal [1, 2, 3], Product.search.order(name: :asc).map(&:id)
33
- assert_equal [3, 2, 1], Product.search.order(name: :desc).map(&:id)
34
-
35
- assert_equal [1, 2, 3], Product.search.order(price: :asc).map(&:id)
36
- assert_equal [3, 2, 1], Product.search.order(price: :desc).map(&:id)
37
-
38
- assert_equal [3, 2, 1], Product.search.order(position: :asc).map(&:id)
39
- assert_equal [3, 2, 1], Product.search.order(position: :desc).map(&:id)
40
- end
41
-
42
- test 'with and without' do
43
- (1..3).step do |id|
44
- shop = Shop.create(id: id)
45
- shop.run_callbacks :commit
46
- end
47
- Shop.create id: 4
48
- sleep 2
49
-
50
- assert_equal [4, 3], Shop.search(with: 4).page(1, length: 2).map(&:id)
51
- assert_equal [2, 1], Shop.search(without: 3).map(&:id)
52
- end
53
-
54
- test 'includes' do
55
- shop = Shop.create
56
- product = shop.products.create(name: 'Test')
57
- product.run_callbacks :commit
58
- sleep 2
59
-
60
- product = Product.search(includes: :shop).first
61
- Shop.expects(:connection).never
62
- assert_equal shop, product.shop
63
- end
64
-
65
- test 'pagination' do
66
- (1..5).step do |id|
67
- shop = Shop.create(id: id)
68
- shop.run_callbacks :commit
69
- end
70
- sleep 2
71
-
72
- collection = Shop.search.page(1, length: 2)
73
- assert_equal 1, collection.first_page
74
- assert_equal 3, collection.last_page
75
- assert_equal 3, collection.total_pages
76
- assert_equal 5, collection.total_count
77
- assert_equal 1, collection.current_page
78
- assert_equal 2, collection.page_length
79
- assert_equal 0, collection.padding
80
- assert_nil collection.previous_page
81
- assert_equal 2, collection.next_page
82
- assert_not collection.out_of_bounds?
83
- assert_equal [5, 4], collection.map(&:id)
84
-
85
- collection = Shop.search.page(2, length: 2)
86
- assert_equal 1, collection.first_page
87
- assert_equal 3, collection.last_page
88
- assert_equal 3, collection.total_pages
89
- assert_equal 5, collection.total_count
90
- assert_equal 2, collection.current_page
91
- assert_equal 2, collection.page_length
92
- assert_equal 0, collection.padding
93
- assert_equal 1, collection.previous_page
94
- assert_equal 3, collection.next_page
95
- assert_not collection.out_of_bounds?
96
- assert_equal [3, 2], collection.map(&:id)
97
-
98
- collection = Shop.search.page(3, length: 2)
99
- assert_equal 1, collection.first_page
100
- assert_equal 3, collection.last_page
101
- assert_equal 3, collection.total_pages
102
- assert_equal 5, collection.total_count
103
- assert_equal 3, collection.current_page
104
- assert_equal 2, collection.page_length
105
- assert_equal 0, collection.padding
106
- assert_equal 2, collection.previous_page
107
- assert_nil collection.next_page
108
- assert_not collection.out_of_bounds?
109
- assert_equal [1], collection.map(&:id)
110
-
111
- collection = Shop.search.page(4, length: 2)
112
- assert_equal 1, collection.first_page
113
- assert_equal 3, collection.last_page
114
- assert_equal 3, collection.total_pages
115
- assert_equal 5, collection.total_count
116
- assert_equal 4, collection.current_page
117
- assert_equal 2, collection.page_length
118
- assert_equal 0, collection.padding
119
- assert_equal 3, collection.previous_page
120
- assert_nil collection.next_page
121
- assert collection.out_of_bounds?
122
- assert_equal [], collection.to_a
123
-
124
- collection = Shop.search.page(1, length: 2, padding: 2)
125
- assert_equal 1, collection.first_page
126
- assert_equal 2, collection.last_page
127
- assert_equal 2, collection.total_pages
128
- assert_equal 3, collection.total_count
129
- assert_equal 1, collection.current_page
130
- assert_equal 2, collection.page_length
131
- assert_equal 2, collection.padding
132
- assert_nil collection.previous_page
133
- assert_equal 2, collection.next_page
134
- assert_not collection.out_of_bounds?
135
- assert_equal [3, 2], collection.map(&:id)
136
-
137
- collection = Shop.search.page(2, length: 2, padding: 2)
138
- assert_equal 1, collection.first_page
139
- assert_equal 2, collection.last_page
140
- assert_equal 2, collection.total_pages
141
- assert_equal 3, collection.total_count
142
- assert_equal 2, collection.current_page
143
- assert_equal 2, collection.page_length
144
- assert_equal 2, collection.padding
145
- assert_equal 1, collection.previous_page
146
- assert_nil collection.next_page
147
- assert_not collection.out_of_bounds?
148
- assert_equal [1], collection.map(&:id)
149
-
150
- collection = Shop.search.page(3, length: 2, padding: 2)
151
- assert_equal 1, collection.first_page
152
- assert_equal 2, collection.last_page
153
- assert_equal 2, collection.total_pages
154
- assert_equal 3, collection.total_count
155
- assert_equal 3, collection.current_page
156
- assert_equal 2, collection.page_length
157
- assert_equal 2, collection.padding
158
- assert_equal 2, collection.previous_page
159
- assert_nil collection.next_page
160
- assert collection.out_of_bounds?
161
- assert_equal [], collection.to_a
162
- end
163
-
164
- end