nazrin 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +22 -0
- data/lib/generators/nazrin/templates/nazrin_config.rb +1 -1
- data/lib/nazrin/config.rb +1 -0
- data/lib/nazrin/document_client.rb +4 -2
- data/lib/nazrin/search_client.rb +6 -0
- data/lib/nazrin/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 524d0d3e179dce958e889f80d845acca4c4f9eb3
|
4
|
+
data.tar.gz: ee8bf324ef3f1d2a6af74f8f52f7a7454fc70756
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2d02c1413b55ba7face169e538fe71b069ee2f84f1f0da72cfaa0e38e9008f07d10f7db22d6bb888840c549ba010e962b4cc4a7680c9d02950008c165d33a79
|
7
|
+
data.tar.gz: 322b95b0772eb59c1c446e4bf9616d5d9bbb3052a69e5b80d4a683422ed8197157509ea85a751df78eb314d8c6fdc7c08ac54ea7c9f10e3474185298d64a4681
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
|
+
## [2.1.0](https://github.com/tsuwatch/nazrin/compare/v2.0.0...v2.1.0)
|
2
|
+
|
3
|
+
### Breaking changes:
|
4
|
+
|
5
|
+
* Deprecated `Nazrin.config.debug_mode` [#11](https://github.com/tsuwatch/nazrin/pull/11)
|
6
|
+
|
7
|
+
### Features:
|
8
|
+
|
9
|
+
* Implement sandbox mode [#11](https://github.com/tsuwatch/nazrin/pull/11)
|
10
|
+
|
11
|
+
## [2.0.0](https://github.com/tsuwatch/nazrin/compare/v2.0.0.rc1...v2.0.0)
|
12
|
+
|
13
|
+
### Fixes:
|
14
|
+
|
15
|
+
* Add activesupport to dependencies ([#9](https://github.com/tsuwatch/nazrin/pull/9))
|
16
|
+
|
1
17
|
## [2.0.0.rc1](https://github.com/tsuwatch/nazrin/compare/v1.0.1...v2.0.0.rc1)
|
2
18
|
|
19
|
+
### Breaking changes:
|
20
|
+
|
3
21
|
* Extracted Kaminari support to nazrin-kaminari gem ([#7](https://github.com/tsuwatch/nazrin/pull/7))
|
4
22
|
|
5
23
|
* Extracted will_paginate support to nazrin-will_paginate gem ([#7](https://github.com/tsuwatch/nazrin/pull/7))
|
data/README.md
CHANGED
@@ -33,6 +33,7 @@ $ bundle exec rails g nazrin:config # execute before including nazrin to model
|
|
33
33
|
|
34
34
|
Nazrin.configure do |config|
|
35
35
|
config.debug_mode = false
|
36
|
+
config.mode = 'production'
|
36
37
|
config.search_endpoint = ''
|
37
38
|
config.document_endpoint = ''
|
38
39
|
config.region = ''
|
@@ -61,6 +62,27 @@ Post.search(where: :foo, includes: :bar).size(1).start(0).query("(and 'content')
|
|
61
62
|
=> [#<Post id: 1, content: "content">]
|
62
63
|
```
|
63
64
|
|
65
|
+
### Supported pagination libraries
|
66
|
+
If you want to use other supported pagination libraries, for example, `nazrin-kaminari` generates `Kaminari::PaginatableArray` instead of `Nazrin::PaginatedArray`.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
gem 'nazrin-kaminari'
|
70
|
+
```
|
71
|
+
|
72
|
+
Currently supported libraries
|
73
|
+
|
74
|
+
- kaminari: [nazrin-kaminari](https://github.com/tsuwatch/nazrin-kaminari)
|
75
|
+
|
76
|
+
### Sandbox mode
|
77
|
+
|
78
|
+
When there is no instance for development and you don't want to request to CloudSearch
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
Nazrion.config.mode = 'sandbox'
|
82
|
+
```
|
83
|
+
|
84
|
+
"sandbox" mode where it does nothing with any requests and just returns an empty collection for any searches.
|
85
|
+
|
64
86
|
## Development
|
65
87
|
|
66
88
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/nazrin/config.rb
CHANGED
@@ -11,7 +11,8 @@ module Nazrin
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def add_document(id, field_data)
|
14
|
-
return nil if Nazrin.config.debug_mode
|
14
|
+
ActiveSupport::Deprecation.warn 'config.debug_mode is deprecated. Use config.mode = \'sandbox\' instead.' and return nil if Nazrin.config.debug_mode
|
15
|
+
return nil if Nazrin.config.mode = 'sandbox'
|
15
16
|
client.upload_documents(
|
16
17
|
documents: [
|
17
18
|
{
|
@@ -24,7 +25,8 @@ module Nazrin
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def delete_document(id)
|
27
|
-
return nil if Nazrin.config.debug_mode
|
28
|
+
ActiveSupport::Deprecation.warn 'config.debug_mode is deprecated. Use config.mode = \'sandbox\' instead.' and return nil if Nazrin.config.debug_mode
|
29
|
+
return nil if Nazrin.config.mode = 'sandbox'
|
28
30
|
client.upload_documents(
|
29
31
|
documents: [
|
30
32
|
{
|
data/lib/nazrin/search_client.rb
CHANGED
@@ -109,11 +109,13 @@ module Nazrin
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def search
|
112
|
+
return fake_response if Nazrin.config.mode == 'sandbox'
|
112
113
|
fail SearchClientError if deep_page?
|
113
114
|
@client.search(@parameters)
|
114
115
|
end
|
115
116
|
|
116
117
|
def execute
|
118
|
+
return fake_response if Nazrin.config.mode == 'sandbox'
|
117
119
|
if data_accessor
|
118
120
|
data_accessor.results(self)
|
119
121
|
else
|
@@ -133,5 +135,9 @@ module Nazrin
|
|
133
135
|
end
|
134
136
|
false
|
135
137
|
end
|
138
|
+
|
139
|
+
def fake_response
|
140
|
+
Nazrin::PaginationGenerator.generate([], { current_page: 1, per_page: 1, total_count: 0 })
|
141
|
+
end
|
136
142
|
end
|
137
143
|
end
|
data/lib/nazrin/version.rb
CHANGED