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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3bfaa1a5511735ae1e5a0d3f5fad4248ffa2aacf
4
- data.tar.gz: 190b427df48d68bc0433d62d62ce5395116eb21e
3
+ metadata.gz: 524d0d3e179dce958e889f80d845acca4c4f9eb3
4
+ data.tar.gz: ee8bf324ef3f1d2a6af74f8f52f7a7454fc70756
5
5
  SHA512:
6
- metadata.gz: 19a71b2281e25acd4df909598b705cea8cc29ebcec76a56f42351d4c8cbe4395a94853df489cf7a400e177065ebbdc8f75b3af1b329e268096b3ef2596d9bc03
7
- data.tar.gz: 95641e5817ce4ffaefd7db2aea3bd483967db8f9db20ed61359ccd19736704720341fa4f716a8d728339e33c5f5b7e3b3e3fc791ae9f770f1648042e4c9d574c
6
+ metadata.gz: d2d02c1413b55ba7face169e538fe71b069ee2f84f1f0da72cfaa0e38e9008f07d10f7db22d6bb888840c549ba010e962b4cc4a7680c9d02950008c165d33a79
7
+ data.tar.gz: 322b95b0772eb59c1c446e4bf9616d5d9bbb3052a69e5b80d4a683422ed8197157509ea85a751df78eb314d8c6fdc7c08ac54ea7c9f10e3474185298d64a4681
@@ -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.
@@ -1,5 +1,5 @@
1
1
  Nazrin.configure do |config|
2
- config.debug_mode = false
2
+ config.mode = :production # or sandbox (It does nothing with any requests to CloudSearch)
3
3
  config.search_endpoint = ''
4
4
  config.document_endpoint = ''
5
5
  config.region = ''
@@ -12,6 +12,7 @@ module Nazrin
12
12
  class Configuration
13
13
  include ActiveSupport::Configurable
14
14
  config_accessor :debug_mode
15
+ config_accessor :mode
15
16
  config_accessor :search_endpoint
16
17
  config_accessor :document_endpoint
17
18
  config_accessor :region
@@ -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
  {
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Nazrin
2
- VERSION = '2.0.0'
2
+ VERSION = '2.1.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nazrin
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomohiro Suwa