redis-ick 0.0.2 → 0.0.3

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: 7d2e7517bc9eba00b0c5744984d90717b87979b0
4
- data.tar.gz: 9879cc1f153d6a9d8ec52a2604a50b13178453cf
3
+ metadata.gz: 985bcc31664985af1016a12b0b45e015f6307b4c
4
+ data.tar.gz: f45617138cd637aeeafac5e6cc31fe3e103dc814
5
5
  SHA512:
6
- metadata.gz: 636ea109ba2dbcc8691ab1de0250c5487c13523fd1963698742a664f5e367a23757cdaa55d38614f15b0909425984cffc8db44bfd2cad35b2813e4ae5312938a
7
- data.tar.gz: f5f1c137aaa9f4663aeb9c844f6d39d50fb97ad1ed75e4850a10f43bcc43fce39630ff33ee922e18c1cc20fb6a50e8f1246fd1dfd4ee6647da958d409a00cda4
6
+ metadata.gz: ed52b22601623951ad500d91680910db9411829cf3792cbff8f435bd17536c2d5324285159f262b926f9d3be719b33d9293ed675f6ee10219a4d522d731356be
7
+ data.tar.gz: 6950898f2e07b6e678b1add4238cb66264c1f11740707fcd1dc0065b76d9e89a758c7c1eab36c2c31f7ae3dd5cf7ff2d8c2a37596136433be8e6b3ab8cf13575
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ inherit_from: .rubocop_todo.yml
2
+ AllCops:
3
+ Include:
4
+ - Rakefile
5
+ - Gemfile
6
+ - '*.gemspec'
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,296 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-08-29 15:15:59 -0700 using RuboCop version 0.49.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Cop supports --auto-correct.
11
+ Layout/EmptyLineAfterMagicComment:
12
+ Exclude:
13
+ - 'redis-ick.gemspec'
14
+
15
+ # Offense count: 6
16
+ # Cop supports --auto-correct.
17
+ # Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
18
+ Layout/EmptyLineBetweenDefs:
19
+ Exclude:
20
+ - 'test/redis/ick_test.rb'
21
+
22
+ # Offense count: 1
23
+ # Cop supports --auto-correct.
24
+ Layout/EmptyLines:
25
+ Exclude:
26
+ - 'lib/redis/ick.rb'
27
+
28
+ # Offense count: 2
29
+ # Cop supports --auto-correct.
30
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
31
+ # SupportedStyles: empty_lines, no_empty_lines
32
+ Layout/EmptyLinesAroundBlockBody:
33
+ Exclude:
34
+ - 'redis-ick.gemspec'
35
+
36
+ # Offense count: 4
37
+ # Cop supports --auto-correct.
38
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
39
+ # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
40
+ Layout/EmptyLinesAroundClassBody:
41
+ Exclude:
42
+ - 'lib/redis/ick.rb'
43
+ - 'test/redis/ick_test.rb'
44
+
45
+ # Offense count: 15
46
+ # Cop supports --auto-correct.
47
+ # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
48
+ Layout/ExtraSpacing:
49
+ Exclude:
50
+ - 'test/redis/ick_test.rb'
51
+
52
+ # Offense count: 1
53
+ # Cop supports --auto-correct.
54
+ Layout/LeadingCommentSpace:
55
+ Exclude:
56
+ - 'test/redis/ick_test.rb'
57
+
58
+ # Offense count: 276
59
+ # Cop supports --auto-correct.
60
+ Layout/SpaceAfterComma:
61
+ Exclude:
62
+ - 'lib/redis/ick.rb'
63
+ - 'test/redis/ick_test.rb'
64
+
65
+ # Offense count: 2
66
+ # Cop supports --auto-correct.
67
+ Layout/SpaceAfterNot:
68
+ Exclude:
69
+ - 'lib/redis/ick.rb'
70
+
71
+ # Offense count: 1
72
+ # Cop supports --auto-correct.
73
+ # Configuration parameters: EnforcedStyleInsidePipes, SupportedStylesInsidePipes.
74
+ # SupportedStylesInsidePipes: space, no_space
75
+ Layout/SpaceAroundBlockParameters:
76
+ Exclude:
77
+ - 'lib/redis/ick.rb'
78
+
79
+ # Offense count: 1
80
+ # Cop supports --auto-correct.
81
+ # Configuration parameters: SupportedStyles.
82
+ # SupportedStyles: space, no_space
83
+ Layout/SpaceAroundEqualsInParameterDefault:
84
+ EnforcedStyle: no_space
85
+
86
+ # Offense count: 5
87
+ # Cop supports --auto-correct.
88
+ # Configuration parameters: AllowForAlignment.
89
+ Layout/SpaceAroundOperators:
90
+ Exclude:
91
+ - 'test/redis/ick_test.rb'
92
+
93
+ # Offense count: 2
94
+ # Cop supports --auto-correct.
95
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
96
+ # SupportedStyles: space, no_space
97
+ Layout/SpaceBeforeBlockBraces:
98
+ Exclude:
99
+ - 'lib/redis/ick.rb'
100
+ - 'test/redis/ick_test.rb'
101
+
102
+ # Offense count: 4
103
+ # Cop supports --auto-correct.
104
+ # Configuration parameters: AllowForAlignment.
105
+ Layout/SpaceBeforeFirstArg:
106
+ Exclude:
107
+ - 'test/redis/ick_test.rb'
108
+
109
+ # Offense count: 4
110
+ # Cop supports --auto-correct.
111
+ # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters.
112
+ # SupportedStyles: space, no_space
113
+ # SupportedStylesForEmptyBraces: space, no_space
114
+ Layout/SpaceInsideBlockBraces:
115
+ Exclude:
116
+ - 'Gemfile'
117
+ - 'lib/redis/ick.rb'
118
+ - 'test/redis/ick_test.rb'
119
+
120
+ # Offense count: 10
121
+ # Cop supports --auto-correct.
122
+ Layout/SpaceInsideBrackets:
123
+ Exclude:
124
+ - 'lib/redis/ick.rb'
125
+ - 'test/redis/ick_test.rb'
126
+
127
+ # Offense count: 1
128
+ Lint/AmbiguousBlockAssociation:
129
+ Exclude:
130
+ - 'test/redis/ick_test.rb'
131
+
132
+ # Offense count: 18
133
+ Metrics/AbcSize:
134
+ Max: 318
135
+
136
+ # Offense count: 2
137
+ # Configuration parameters: CountComments.
138
+ Metrics/ClassLength:
139
+ Max: 609
140
+
141
+ # Offense count: 1
142
+ Metrics/CyclomaticComplexity:
143
+ Max: 8
144
+
145
+ # Offense count: 3
146
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
147
+ # URISchemes: http, https
148
+ Metrics/LineLength:
149
+ Max: 81
150
+
151
+ # Offense count: 19
152
+ # Configuration parameters: CountComments.
153
+ Metrics/MethodLength:
154
+ Max: 175
155
+
156
+ # Offense count: 1
157
+ Metrics/PerceivedComplexity:
158
+ Max: 8
159
+
160
+ # Offense count: 1
161
+ # Cop supports --auto-correct.
162
+ Performance/TimesMap:
163
+ Exclude:
164
+ - 'test/redis/ick_test.rb'
165
+
166
+ # Offense count: 2
167
+ # Cop supports --auto-correct.
168
+ # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
169
+ # SupportedStyles: line_count_based, semantic, braces_for_chaining
170
+ # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
171
+ # FunctionalMethods: let, let!, subject, watch
172
+ # IgnoredMethods: lambda, proc, it
173
+ Style/BlockDelimiters:
174
+ Exclude:
175
+ - 'lib/redis/ick.rb'
176
+
177
+ # Offense count: 1
178
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
179
+ # SupportedStyles: nested, compact
180
+ Style/ClassAndModuleChildren:
181
+ Exclude:
182
+ - 'test/redis/ick_test.rb'
183
+
184
+ # Offense count: 2
185
+ Style/ClassVars:
186
+ Exclude:
187
+ - 'test/redis/ick_test.rb'
188
+
189
+ # Offense count: 1
190
+ Style/Documentation:
191
+ Exclude:
192
+ - 'spec/**/*'
193
+ - 'test/**/*'
194
+ - 'lib/redis/ick.rb'
195
+
196
+ # Offense count: 1
197
+ # Cop supports --auto-correct.
198
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
199
+ # SupportedStyles: format, sprintf, percent
200
+ Style/FormatString:
201
+ Exclude:
202
+ - 'test/redis/ick_test.rb'
203
+
204
+ # Offense count: 1
205
+ # Configuration parameters: MinBodyLength.
206
+ Style/GuardClause:
207
+ Exclude:
208
+ - 'lib/redis/ick.rb'
209
+
210
+ # Offense count: 3
211
+ # Cop supports --auto-correct.
212
+ # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
213
+ # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
214
+ Style/HashSyntax:
215
+ Exclude:
216
+ - 'Rakefile'
217
+ - 'test/redis/ick_test.rb'
218
+
219
+ # Offense count: 3
220
+ # Cop supports --auto-correct.
221
+ # Configuration parameters: MaxLineLength.
222
+ Style/IfUnlessModifier:
223
+ Exclude:
224
+ - 'lib/redis/ick.rb'
225
+
226
+ # Offense count: 6
227
+ # Configuration parameters: SupportedStyles.
228
+ # SupportedStyles: snake_case, camelCase
229
+ Style/MethodName:
230
+ EnforcedStyle: snake_case
231
+
232
+ # Offense count: 1
233
+ # Cop supports --auto-correct.
234
+ Style/MutableConstant:
235
+ Exclude:
236
+ - 'lib/redis/ick/version.rb'
237
+
238
+ # Offense count: 15
239
+ # Cop supports --auto-correct.
240
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
241
+ # SupportedStyles: both, prefix, postfix
242
+ Style/NegatedIf:
243
+ Exclude:
244
+ - 'lib/redis/ick.rb'
245
+ - 'test/redis/ick_test.rb'
246
+
247
+ # Offense count: 1
248
+ # Cop supports --auto-correct.
249
+ # Configuration parameters: AllowMultipleReturnValues.
250
+ Style/RedundantReturn:
251
+ Exclude:
252
+ - 'lib/redis/ick.rb'
253
+
254
+ # Offense count: 1
255
+ # Cop supports --auto-correct.
256
+ # Configuration parameters: AllowAsExpressionSeparator.
257
+ Style/Semicolon:
258
+ Exclude:
259
+ - 'test/redis/ick_test.rb'
260
+
261
+ # Offense count: 28
262
+ # Cop supports --auto-correct.
263
+ # Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
264
+ # SupportedStyles: single_quotes, double_quotes
265
+ Style/StringLiterals:
266
+ Exclude:
267
+ - 'Gemfile'
268
+ - 'Rakefile'
269
+ - 'bin/console'
270
+ - 'lib/redis/ick.rb'
271
+ - 'redis-ick.gemspec'
272
+ - 'test/redis/ick_test.rb'
273
+ - 'test/test_helper.rb'
274
+
275
+ # Offense count: 1
276
+ # Cop supports --auto-correct.
277
+ # Configuration parameters: MinSize, SupportedStyles.
278
+ # SupportedStyles: percent, brackets
279
+ Style/SymbolArray:
280
+ EnforcedStyle: brackets
281
+
282
+ # Offense count: 1
283
+ # Cop supports --auto-correct.
284
+ # Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment.
285
+ # SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
286
+ Style/TernaryParentheses:
287
+ Exclude:
288
+ - 'lib/redis/ick.rb'
289
+
290
+ # Offense count: 11
291
+ # Cop supports --auto-correct.
292
+ # Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline.
293
+ # SupportedStylesForMultiline: comma, consistent_comma, no_comma
294
+ Style/TrailingCommaInLiteral:
295
+ Exclude:
296
+ - 'test/redis/ick_test.rb'
data/.travis.yml CHANGED
@@ -1,10 +1,12 @@
1
- sudo: false
1
+ sudo: false
2
2
  language: ruby
3
- rvm:
4
- - 2.1.6
5
3
  before_install:
6
4
  - gem install bundler -v 1.14.6
5
+ - gem install rubocop
7
6
  services:
8
7
  - redis-server
8
+ rvm:
9
+ - 2.1.6
9
10
  script:
11
+ - rubocop
10
12
  - bundle exec env REDIS_URL=redis://localhost:6379 rake test
@@ -1,17 +1,21 @@
1
1
  class Redis
2
2
  class Ick
3
3
  #
4
- # Version plan:
4
+ # Version plan/history:
5
5
  #
6
- # 0.0.1 - still in Prosperworks/ALI/vendor/gems/redis-ick
6
+ # 0.0.1 - Still in Prosperworks/ALI/vendor/gems/redis-ick.
7
7
  #
8
- # 0.0.2 - broke out into Prosperworks/redis-ick
8
+ # 0.0.2 - Broke out into Prosperworks/redis-ick, make public.
9
9
  #
10
- # 0.1.0 - big README.md and Rdoc update, open repo
10
+ # 0.0.3 - Got .travis.yml working with a live redis-server, some
11
+ # cleanup, runtime dependency on redis-script_manager for
12
+ # Ick._eval, added Rubocop.
11
13
  #
12
- # 0.2.0 - solicit and incorporate initial feedback from select
13
- # beta external users
14
+ # 0.1.0 - (future) Big README.md and Rdoc update, solicit feedback
15
+ # from select external beta users.
14
16
  #
15
- VERSION = "0.0.2" # broken into standalone repo, not polished
17
+ # 0.2.0 - (future) Incorporate feedback, announce.
18
+ #
19
+ VERSION = '0.0.3'
16
20
  end
17
21
  end
data/lib/redis/ick.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  require 'redis/ick/version'
2
+ require 'redis/script_manager'
2
3
 
3
4
  class Redis
4
5
  class Ick
5
6
 
6
- # TODO: test *everything* in pipelines
7
- # TODO: redis-script_manager for eval
8
7
  # TODO: rubocop
9
8
  # TODO: rdoc
10
9
 
@@ -86,7 +85,7 @@ class Redis
86
85
  end
87
86
  _statsd_increment('profile.ick.ickdel.calls')
88
87
  _statsd_time('profile.ick.ickdel.time') do
89
- Ick._eval(redis,LUA_ICKDEL,ick_key)
88
+ _eval(LUA_ICKDEL,ick_key)
90
89
  end
91
90
  end
92
91
 
@@ -106,7 +105,7 @@ class Redis
106
105
  _statsd_increment('profile.ick.ickstats.calls')
107
106
  raw_ickstats_results = nil
108
107
  _statsd_time('profile.ick.time.ickstats') do
109
- raw_ickstats_results = Ick._eval(redis,LUA_ICKSTATS,ick_key)
108
+ raw_ickstats_results = _eval(LUA_ICKSTATS,ick_key)
110
109
  end
111
110
  if raw_ickstats_results.is_a?(Redis::Future)
112
111
  #
@@ -195,7 +194,7 @@ class Redis
195
194
  _statsd_increment('profile.ick.ickadd.calls')
196
195
  _statsd_timing('profile.ick.ickadd.pairs',score_member_pairs.size / 2)
197
196
  _statsd_time('profile.ick.time.ickadd') do
198
- Ick._eval(redis,LUA_ICKADD,ick_key,*score_member_pairs)
197
+ _eval(LUA_ICKADD,ick_key,*score_member_pairs)
199
198
  end
200
199
  end
201
200
 
@@ -242,20 +241,36 @@ class Redis
242
241
  end
243
242
  _statsd_increment('profile.ick.ickreserve.calls')
244
243
  _statsd_timing('profile.ick.ickreserve.max_size',max_size)
245
- results = nil
244
+ raw_ickreserve_results = nil
246
245
  _statsd_time('profile.ick.time.ickreserve') do
247
- results =
248
- Ick._eval(
249
- redis,
246
+ raw_ickreserve_results =
247
+ _eval(
250
248
  LUA_ICKRESERVE,
251
249
  ick_key,
252
250
  max_size
253
- ).each_slice(2).map { |p|
254
- [ p[0], Ick._floatify(p[1]) ]
251
+ )
252
+ end
253
+ if raw_ickreserve_results.is_a?(Redis::Future)
254
+ #
255
+ # We extend the Redis::Future with a continuation so we can
256
+ # add our own post-processing.
257
+ #
258
+ class << raw_ickreserve_results
259
+ alias_method :original_value, :value
260
+ def value
261
+ original_value.each_slice(2).map { |p|
262
+ [ p[0], ::Redis::Ick._floatify(p[1]) ]
263
+ }
264
+ end
265
+ end
266
+ raw_ickreserve_results
267
+ else
268
+ results = raw_ickreserve_results.each_slice(2).map { |p|
269
+ [ p[0], ::Redis::Ick._floatify(p[1]) ]
255
270
  }
271
+ _statsd_timing('profile.ick.ickreserve.num_results',results.size)
272
+ results
256
273
  end
257
- _statsd_timing('profile.ick.ickreserve.num_results',results.size)
258
- results
259
274
  end
260
275
 
261
276
  # Removes the indicated members from the producer set, if present.
@@ -283,7 +298,7 @@ class Redis
283
298
  _statsd_increment('profile.ick.ickcommit.calls')
284
299
  _statsd_timing('profile.ick.ickcommit.members',members.size)
285
300
  _statsd_time('profile.ick.time.ickcommit') do
286
- Ick._eval(redis,LUA_ICKCOMMIT,ick_key,*members)
301
+ _eval(LUA_ICKCOMMIT,ick_key,*members)
287
302
  end
288
303
  end
289
304
 
@@ -304,14 +319,14 @@ class Redis
304
319
 
305
320
  # Runs the specified lua in the redis against the specifified Ick.
306
321
  #
307
- def self._eval(redis,lua,ick_key,*args)
322
+ def _eval(lua,ick_key,*args)
308
323
  if !lua.is_a?(String)
309
324
  raise ArgumentError, "bogus non-String lua #{lua}"
310
325
  end
311
326
  if !ick_key.is_a?(String)
312
327
  raise ArgumentError, "bogus non-String ick_key #{ick_key}"
313
328
  end
314
- redis.eval(lua,[ick_key],args)
329
+ Redis::ScriptManager.eval_gently(redis,lua,[ick_key],args)
315
330
  end
316
331
 
317
332
  #######################################################################
data/redis-ick.gemspec CHANGED
@@ -22,9 +22,11 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_development_dependency 'bundler', '~> 1.14'
26
- spec.add_development_dependency 'rake', '~> 10.0'
27
- spec.add_development_dependency 'minitest', '~> 5.0'
28
- spec.add_development_dependency 'redis', '~> 3.2'
25
+ spec.add_development_dependency 'bundler', '~> 1.14'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'minitest', '~> 5.0'
28
+ spec.add_development_dependency 'redis', '~> 3.2'
29
+
30
+ spec.add_runtime_dependency 'redis-script_manager', '~> 0.0.2'
29
31
 
30
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-ick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jhwillett
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: redis-script_manager
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.0.2
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.0.2
69
83
  description:
70
84
  email:
71
85
  - jhw@prosperworks.com
@@ -74,6 +88,8 @@ extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
76
90
  - ".gitignore"
91
+ - ".rubocop.yml"
92
+ - ".rubocop_todo.yml"
77
93
  - ".travis.yml"
78
94
  - Gemfile
79
95
  - LICENSE