waistband 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -200,6 +200,13 @@ index.create!
200
200
 
201
201
  This creates the index `events__2013_01`, which in your application logic you could design to store all event data for Jan 2013. You'd do the same for Feb, etc., and when you no longer need one of the older ones, you could delete just that sub-index, instead of things getting more complicated.
202
202
 
203
+ We've also found quite a bit of usefulness in using index versioning, so you can add/remove fields to your object without much worry. Waistband accomodates this pattern as follows:
204
+
205
+ ```ruby
206
+ index = Waistband::Index.new('events', version: 1)
207
+ index.create!
208
+ ```
209
+
203
210
  ### Aliasing
204
211
 
205
212
  Part of subbing is gonna be creating the correct aliases that group up your sub-indexes.
@@ -211,7 +218,7 @@ index.alias('my_super_events_alias') # => true
211
218
  index.alias_exists?('my_super_events_alias') # => true
212
219
  ```
213
220
 
214
- The `alias` methods receives a param to define the alias name.
221
+ The `alias` methods receives a param to define the alias name. The same pattern can be used when using index versions.
215
222
 
216
223
  ## Contributing
217
224
 
@@ -12,9 +12,17 @@ module Waistband
12
12
  @index_name = index_name
13
13
  @stringify = config['stringify']
14
14
 
15
- # alias subs
16
- @subs = [options['subs']] if options['subs'].present?
17
- @subs = @subs.flatten if @subs.is_a?(Array)
15
+ # subindexes checks
16
+ if options['version'].present?
17
+ # version
18
+ @version = options['version']
19
+ @subs = ['version', @version]
20
+ elsif options['subs'].present?
21
+ # subs
22
+ @subs = [options['subs']] if options['subs'].present?
23
+ @subs = @subs.flatten if @subs.is_a?(Array)
24
+ end
25
+
18
26
  end
19
27
 
20
28
  def exists?
@@ -1,3 +1,3 @@
1
1
  module Waistband
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
@@ -116,38 +116,73 @@ describe Waistband::Index do
116
116
 
117
117
  describe 'subindexes' do
118
118
 
119
- let(:sharded_index) { Waistband::Index.new('events', subs: %w(2013 01)) }
119
+ describe 'version option' do
120
120
 
121
- it "permits subbing the index" do
122
- expect(sharded_index.send(:config_name)).to eql 'events_test__2013_01'
123
- end
121
+ let(:sharded_index) { Waistband::Index.new('events', version: 1) }
124
122
 
125
- it "permits sharding into singles" do
126
- index = Waistband::Index.new 'events', subs: '2013'
127
- expect(index.send(:config_name)).to eql 'events_test__2013'
128
- end
123
+ it 'behaves exactly like a subs specified subindex' do
124
+ expect(sharded_index.send(:config_name)).to eql 'events_test__version_1'
125
+ expect(sharded_index.instance_variable_get('@version')).to eql 1
126
+ end
129
127
 
130
- it "retains the same options from the parent index config" do
131
- config = sharded_index.send(:config)
128
+ it "retains the same options from the parent index config" do
129
+ config = sharded_index.send(:config)
132
130
 
133
- expect(sharded_index.send(:base_config_name)).to eql 'events_test'
134
- expect(config['stringify']).to be_true
135
- expect(config['settings']).to be_present
136
- end
131
+ expect(sharded_index.send(:base_config_name)).to eql 'events_test'
132
+ expect(config['stringify']).to be_true
133
+ expect(config['settings']).to be_present
134
+ end
137
135
 
138
- it "creates the sharded index with the same mappings as the parent" do
139
- sharded_index.delete!
136
+ it "creates the sharded index with the same mappings as the parent" do
137
+ sharded_index.delete
138
+
139
+ expect(Waistband::Index.new('events', version: 1).exists?).to be_false
140
+
141
+ expect {
142
+ sharded_index.create!
143
+ }.to_not raise_error
144
+
145
+ expect(Waistband::Index.new('events', version: 1).exists?).to be_true
146
+ end
140
147
 
141
- expect {
142
- sharded_index.create!
143
- }.to_not raise_error
144
148
  end
145
149
 
146
- describe 'no configged index name' do
150
+ describe 'subs option' do
151
+
152
+ let(:sharded_index) { Waistband::Index.new('events', subs: %w(2013 01)) }
153
+
154
+ it "permits subbing the index" do
155
+ expect(sharded_index.send(:config_name)).to eql 'events_test__2013_01'
156
+ end
157
+
158
+ it "permits sharding into singles" do
159
+ index = Waistband::Index.new 'events', subs: '2013'
160
+ expect(index.send(:config_name)).to eql 'events_test__2013'
161
+ end
162
+
163
+ it "retains the same options from the parent index config" do
164
+ config = sharded_index.send(:config)
165
+
166
+ expect(sharded_index.send(:base_config_name)).to eql 'events_test'
167
+ expect(config['stringify']).to be_true
168
+ expect(config['settings']).to be_present
169
+ end
170
+
171
+ it "creates the sharded index with the same mappings as the parent" do
172
+ sharded_index.delete
173
+
174
+ expect {
175
+ sharded_index.create!
176
+ }.to_not raise_error
177
+ end
178
+
179
+ describe 'no configged index name' do
180
+
181
+ it "gets a default name that makes sense for the index when not defined" do
182
+ index = Waistband::Index.new 'events_no_name', subs: %w(2013 01)
183
+ expect(index.send(:config_name)).to eql 'events_no_name_test__2013_01'
184
+ end
147
185
 
148
- it "gets a default name that makes sense for the index when not defined" do
149
- index = Waistband::Index.new 'events_no_name', subs: %w(2013 01)
150
- expect(index.send(:config_name)).to eql 'events_no_name_test__2013_01'
151
186
  end
152
187
 
153
188
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waistband
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - David Jairala
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-04-22 00:00:00.000000000 Z
12
+ date: 2014-05-20 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activesupport
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ! '>='
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ! '>='
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: elasticsearch
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: json
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ~>
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: bundler
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ~>
67
76
  - !ruby/object:Gem::Version
@@ -69,6 +78,7 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: rake
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ! '>='
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ! '>='
81
92
  - !ruby/object:Gem::Version
@@ -120,26 +131,27 @@ files:
120
131
  homepage: https://github.com/taskrabbit/waistband
121
132
  licenses:
122
133
  - MIT
123
- metadata: {}
124
134
  post_install_message:
125
135
  rdoc_options: []
126
136
  require_paths:
127
137
  - lib
128
138
  required_ruby_version: !ruby/object:Gem::Requirement
139
+ none: false
129
140
  requirements:
130
141
  - - ! '>='
131
142
  - !ruby/object:Gem::Version
132
143
  version: '0'
133
144
  required_rubygems_version: !ruby/object:Gem::Requirement
145
+ none: false
134
146
  requirements:
135
147
  - - ! '>='
136
148
  - !ruby/object:Gem::Version
137
149
  version: '0'
138
150
  requirements: []
139
151
  rubyforge_project:
140
- rubygems_version: 2.2.2
152
+ rubygems_version: 1.8.25
141
153
  signing_key:
142
- specification_version: 4
154
+ specification_version: 3
143
155
  summary: Configuration and sensible defaults for ElasticSearch on Ruby
144
156
  test_files:
145
157
  - spec/config/waistband/waistband.yml
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- Y2E0YjFjZWZiY2JjMzkyM2ZiODBkZjliYzM3OGI2NjE3NzNlOWJjZA==
5
- data.tar.gz: !binary |-
6
- ZDlmMWI3N2VmMDU2YTg4Yzc4ZmExOWIxOTZhNGEzZmQyZDlhMWEwYg==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- Y2U1YzE3Mjg3MzIzZDAyZWUyNzAyNzIwNmU3YmZhZjBkZTZiMzEyNDg5YzQ1
10
- YTAyOTI2YTcwZGVmNDNjMjVkMDNhZDA1ZjNiYTU4MTQzZDQxZGJmNGQxMTM2
11
- ZTExZmQxZjZjYjE4ODcwNjE4YWY5ODhkNDNlNzIxMDAyYTFmZDI=
12
- data.tar.gz: !binary |-
13
- MDlmNzY4NzgxYmVlN2M4NDkzNDQzMzJlNjA0ZDA2M2FiNTQ2ZGE0YjE3ZGZk
14
- YjljMTdhNTk0YzJjM2M4YmJkZDYzYzAxYWEwNDYzZTZlYmJhZDAzMzIyYzI2
15
- NzBhZjNjYzFhNjRiNzg0ZGU2ODEwYjQzYmYzNzc4YTgxYTQ1NDc=