chewy 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6bfe79b7a76d86426e6b1f67389d386e85ee33bc
4
- data.tar.gz: 65102eba1137183f68dc167ef1c91f77abae9758
3
+ metadata.gz: f677d05031da075087c0fb9942f31741766ce341
4
+ data.tar.gz: 5759eead057c0e533a988ce96e5dd1c77ab9ccd2
5
5
  SHA512:
6
- metadata.gz: 6b366d1a609fdd330e46e5f4937187e3fdbc697c65869927deb578d7bb58ea170c3e4fcb6bf3a178fba0a29fe8c5c560e3229314da70b2b180ee19eed9084b9c
7
- data.tar.gz: 7e76c1cc833e2884b1c48d3c1dbb197a8bae08a90b099ea87aea5ffb36249a51f08ca37bb1f575f3b6786551c3897b9cb4e443764cc46bd86904e096ad4f3126
6
+ metadata.gz: 76d493cea3e5fd380fc455e53fe886a16e48a1d1050f619668617f719d7721dd3cd93ae1b815bec5785142a5bf7f3d327e3dbc2e4db3a8a8cee521ed61ee93fc
7
+ data.tar.gz: 3091372369882b60d33b5b2ca8928a81ff1b9e7f5c7d8ff38fb0518bbb4a8d4e431746594e78d34a193c58c4aebff0bc245bc6be2ee27f046ca863e2988027a8
@@ -1,5 +1,9 @@
1
1
  # master
2
2
 
3
+ # Version 0.4.1
4
+
5
+ * config/chewy.yml ERB support.
6
+
3
7
  # Version 0.4.0
4
8
 
5
9
  * Changed `update_index` matcher behavior. Now it compare array attributes position-independantly.
data/README.md CHANGED
@@ -7,8 +7,6 @@ Chewy is ODM and wrapper for official elasticsearch client (https://github.com/e
7
7
 
8
8
  ## Why chewy?
9
9
 
10
-
11
-
12
10
  * Multi-model indexes.
13
11
 
14
12
  Index classes are independant from ORM/ODM models. Now implementing, e.g. cross-model autocomplete is much easier. You can just define index and work with it in object-oriented style. You can define several types for index - one per indexed model.
@@ -64,7 +62,7 @@ The result config merges both hashes. Client options are passed as is to Elastic
64
62
 
65
63
  ```ruby
66
64
  Chewy.configuration = {prefix: 'testing'}
67
- UsersIndex.index_name # => 'testing_users'
65
+ UsersIndex.index_name # => 'test_users'
68
66
  ```
69
67
 
70
68
  Also logger might be set explicitly:
@@ -73,6 +71,8 @@ Also logger might be set explicitly:
73
71
  Chewy.logger = Logger.new
74
72
  ```
75
73
 
74
+ See [config.rb](lib/chewy/config.rb) for more details.
75
+
76
76
  ### Index definition
77
77
 
78
78
  1. Create `/app/chewy/users_index.rb`
@@ -229,7 +229,9 @@ See [actions.rb](lib/chewy/index/actions.rb) for more details.
229
229
 
230
230
  ### Observing strategies
231
231
 
232
- There are 3 strategies for index updating: do not update index at all, update right after save and cummulative update. The first is by default.
232
+ There are 3 strategies for index updating: do not update index at all, update right after save and cumulative update. The first is by default.
233
+
234
+ **WARN: It is preferred to use `Chewy.atomic` block in most cases due to performance restrictions of the urgent updates!**
233
235
 
234
236
  #### Updating index on-demand
235
237
 
@@ -63,6 +63,49 @@ module Chewy
63
63
  #
64
64
  repository :char_filter
65
65
 
66
+ # Chewy core configurations. There is two ways to set it up:
67
+ # use `Chewy.configuration=` method or, for Rails application,
68
+ # create `config/chewy.yml` file. Btw, `config/chewy.yml` supports
69
+ # ERB the same way as ActiveRecord's config.
70
+ #
71
+ # Configuration options:
72
+ #
73
+ # 1. Chewy client options. All the options Elasticsearch::Client
74
+ # supports.
75
+ #
76
+ # test:
77
+ # host: 'localhost:9250'
78
+ #
79
+ # 2. Chewy self-configuration:
80
+ #
81
+ # :prefix - used as prefix for any index created.
82
+ #
83
+ # test:
84
+ # host: 'localhost:9250'
85
+ # prefix: test<%= ENV['TEST_ENV_NUMBER'] %>
86
+ #
87
+ # Then UsersIndex.index_name will be "test42_users"
88
+ # in case TEST_ENV_NUMBER=42
89
+ #
90
+ # :wait_for_status - if this option set - chewy actions such
91
+ # as creating or deleting index, importing data will wait for
92
+ # the status specified. Extremely useful for tests under havy
93
+ # indexes manipulations.
94
+ #
95
+ # test:
96
+ # host: 'localhost:9250'
97
+ # wait_for_status: green
98
+ #
99
+ # 3. Index settings. All the possible ElasticSearch index settings.
100
+ # Will be merged as defaults with index settings on every index
101
+ # creation.
102
+ #
103
+ # test: &test
104
+ # host: 'localhost:9250'
105
+ # index:
106
+ # number_of_shards: 1
107
+ # number_of_replicas: 0
108
+ #
66
109
  def configuration
67
110
  options = @configuration.deep_symbolize_keys.merge(yaml_options)
68
111
  options.merge!(logger: logger) if logger
@@ -105,7 +148,10 @@ module Chewy
105
148
  @yaml_options ||= begin
106
149
  if defined?(Rails)
107
150
  file = Rails.root.join(*%w(config chewy.yml))
108
- YAML.load_file(file)[Rails.env].try(:deep_symbolize_keys) if File.exists?(file)
151
+ if File.exists?(file)
152
+ yaml = ERB.new(File.read(file)).result
153
+ YAML.load(yaml)[Rails.env].try(:deep_symbolize_keys)
154
+ end
109
155
  end || {}
110
156
  end
111
157
  end
@@ -1,3 +1,3 @@
1
1
  module Chewy
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chewy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - pyromaniac
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-10 00:00:00.000000000 Z
11
+ date: 2014-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake