redis-objects-daily-counter 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +23 -20
  3. data/.github/dependabot.yml +19 -0
  4. data/.rubocop.yml +4 -4
  5. data/CHANGELOG.md +38 -16
  6. data/Dockerfile +1 -1
  7. data/Gemfile +1 -1
  8. data/Gemfile.lock +30 -27
  9. data/README.md +81 -33
  10. data/bin/console +1 -2
  11. data/lib/redis/base_counter_object.rb +4 -0
  12. data/lib/redis/base_hash_key_object.rb +40 -0
  13. data/lib/redis/base_set_object.rb +4 -0
  14. data/lib/redis/objects/daily-counter/version.rb +1 -1
  15. data/lib/redis/objects/periodical_counters.rb +40 -0
  16. data/lib/redis/objects/periodical_hashes.rb +50 -0
  17. data/lib/redis/objects/periodical_sets.rb +50 -0
  18. data/lib/redis/periodical_counter.rb +15 -0
  19. data/lib/redis/periodical_hash_key.rb +15 -0
  20. data/lib/redis/periodical_set.rb +15 -0
  21. data/lib/redis/recurring_at_intervals.rb +1 -1
  22. data/lib/redis-objects-daily-counter.rb +16 -38
  23. data/redis-objects-daily-counter.gemspec +1 -1
  24. metadata +12 -28
  25. data/lib/redis/annual_counter.rb +0 -13
  26. data/lib/redis/annual_set.rb +0 -13
  27. data/lib/redis/daily_counter.rb +0 -13
  28. data/lib/redis/daily_set.rb +0 -13
  29. data/lib/redis/hourly_counter.rb +0 -13
  30. data/lib/redis/hourly_set.rb +0 -13
  31. data/lib/redis/minutely_counter.rb +0 -13
  32. data/lib/redis/minutely_set.rb +0 -13
  33. data/lib/redis/monthly_counter.rb +0 -13
  34. data/lib/redis/monthly_set.rb +0 -13
  35. data/lib/redis/objects/annual_counters.rb +0 -41
  36. data/lib/redis/objects/annual_sets.rb +0 -49
  37. data/lib/redis/objects/daily_counters.rb +0 -41
  38. data/lib/redis/objects/daily_sets.rb +0 -49
  39. data/lib/redis/objects/hourly_counters.rb +0 -41
  40. data/lib/redis/objects/hourly_sets.rb +0 -49
  41. data/lib/redis/objects/minutely_counters.rb +0 -41
  42. data/lib/redis/objects/minutely_sets.rb +0 -49
  43. data/lib/redis/objects/monthly_counters.rb +0 -41
  44. data/lib/redis/objects/monthly_sets.rb +0 -49
  45. data/lib/redis/objects/weekly_counters.rb +0 -41
  46. data/lib/redis/objects/weekly_sets.rb +0 -49
  47. data/lib/redis/weekly_counter.rb +0 -13
  48. data/lib/redis/weekly_set.rb +0 -13
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'redis/hourly_counter'
4
- class Redis
5
- module Objects
6
- module HourlyCounters
7
- class << self
8
- def included(klass)
9
- klass.extend ClassMethods
10
- end
11
- end
12
-
13
- module ClassMethods
14
- def hourly_counter(name, options = {}) # rubocop:disable Metrics/MethodLength
15
- options[:start] ||= 0
16
- options[:type] ||= (options[:start]).zero? ? :increment : :decrement
17
- redis_objects[name.to_sym] = options.merge(type: :counter)
18
-
19
- mod = Module.new do
20
- define_method(name) do
21
- Redis::HourlyCounter.new(
22
- redis_field_key(name), redis_field_redis(name), redis_options(name)
23
- )
24
- end
25
- end
26
-
27
- if options[:global]
28
- extend mod
29
-
30
- # dispatch to class methods
31
- define_method(name) do
32
- self.class.public_send(name)
33
- end
34
- else
35
- include mod
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'redis/hourly_set'
4
- class Redis
5
- module Objects
6
- module HourlySets
7
- def self.included(klass)
8
- klass.extend ClassMethods
9
- end
10
-
11
- # Class methods that appear in your class when you include Redis::Objects.
12
- module ClassMethods
13
- # Define a new list. It will function like a regular instance
14
- # method, so it can be used alongside ActiveRecord, DataMapper, etc.
15
- def hourly_set(name, options = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
16
- redis_objects[name.to_sym] = options.merge(type: :set)
17
-
18
- mod = Module.new do
19
- define_method(name) do
20
- Redis::HourlySet.new(
21
- redis_field_key(name), redis_field_redis(name), redis_options(name)
22
- )
23
- end
24
-
25
- define_method(:"#{name}=") do |values|
26
- set = public_send(name)
27
-
28
- redis.pipelined do
29
- set.clear
30
- set.merge(*values)
31
- end
32
- end
33
- end
34
-
35
- if options[:global]
36
- extend mod
37
-
38
- # dispatch to class methods
39
- define_method(name) do
40
- self.class.public_send(name)
41
- end
42
- else
43
- include mod
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'redis/minutely_counter'
4
- class Redis
5
- module Objects
6
- module MinutelyCounters
7
- class << self
8
- def included(klass)
9
- klass.extend ClassMethods
10
- end
11
- end
12
-
13
- module ClassMethods
14
- def minutely_counter(name, options = {}) # rubocop:disable Metrics/MethodLength
15
- options[:start] ||= 0
16
- options[:type] ||= (options[:start]).zero? ? :increment : :decrement
17
- redis_objects[name.to_sym] = options.merge(type: :counter)
18
-
19
- mod = Module.new do
20
- define_method(name) do
21
- Redis::MinutelyCounter.new(
22
- redis_field_key(name), redis_field_redis(name), redis_options(name)
23
- )
24
- end
25
- end
26
-
27
- if options[:global]
28
- extend mod
29
-
30
- # dispatch to class methods
31
- define_method(name) do
32
- self.class.public_send(name)
33
- end
34
- else
35
- include mod
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'redis/minutely_set'
4
- class Redis
5
- module Objects
6
- module MinutelySets
7
- def self.included(klass)
8
- klass.extend ClassMethods
9
- end
10
-
11
- # Class methods that appear in your class when you include Redis::Objects.
12
- module ClassMethods
13
- # Define a new list. It will function like a regular instance
14
- # method, so it can be used alongside ActiveRecord, DataMapper, etc.
15
- def minutely_set(name, options = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
16
- redis_objects[name.to_sym] = options.merge(type: :set)
17
-
18
- mod = Module.new do
19
- define_method(name) do
20
- Redis::MinutelySet.new(
21
- redis_field_key(name), redis_field_redis(name), redis_options(name)
22
- )
23
- end
24
-
25
- define_method(:"#{name}=") do |values|
26
- set = public_send(name)
27
-
28
- redis.pipelined do
29
- set.clear
30
- set.merge(*values)
31
- end
32
- end
33
- end
34
-
35
- if options[:global]
36
- extend mod
37
-
38
- # dispatch to class methods
39
- define_method(name) do
40
- self.class.public_send(name)
41
- end
42
- else
43
- include mod
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'redis/daily_counter'
4
- class Redis
5
- module Objects
6
- module MonthlyCounters
7
- class << self
8
- def included(klass)
9
- klass.extend ClassMethods
10
- end
11
- end
12
-
13
- module ClassMethods
14
- def monthly_counter(name, options = {}) # rubocop:disable Metrics/MethodLength
15
- options[:start] ||= 0
16
- options[:type] ||= (options[:start]).zero? ? :increment : :decrement
17
- redis_objects[name.to_sym] = options.merge(type: :counter)
18
-
19
- mod = Module.new do
20
- define_method(name) do
21
- Redis::MonthlyCounter.new(
22
- redis_field_key(name), redis_field_redis(name), redis_options(name)
23
- )
24
- end
25
- end
26
-
27
- if options[:global]
28
- extend mod
29
-
30
- # dispatch to class methods
31
- define_method(name) do
32
- self.class.public_send(name)
33
- end
34
- else
35
- include mod
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'redis/monthly_set'
4
- class Redis
5
- module Objects
6
- module MonthlySets
7
- def self.included(klass)
8
- klass.extend ClassMethods
9
- end
10
-
11
- # Class methods that appear in your class when you include Redis::Objects.
12
- module ClassMethods
13
- # Define a new list. It will function like a regular instance
14
- # method, so it can be used alongside ActiveRecord, DataMapper, etc.
15
- def monthly_set(name, options = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
16
- redis_objects[name.to_sym] = options.merge(type: :set)
17
-
18
- mod = Module.new do
19
- define_method(name) do
20
- Redis::MonthlySet.new(
21
- redis_field_key(name), redis_field_redis(name), redis_options(name)
22
- )
23
- end
24
-
25
- define_method(:"#{name}=") do |values|
26
- set = public_send(name)
27
-
28
- redis.pipelined do
29
- set.clear
30
- set.merge(*values)
31
- end
32
- end
33
- end
34
-
35
- if options[:global]
36
- extend mod
37
-
38
- # dispatch to class methods
39
- define_method(name) do
40
- self.class.public_send(name)
41
- end
42
- else
43
- include mod
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'redis/weekly_counter'
4
- class Redis
5
- module Objects
6
- module WeeklyCounters
7
- class << self
8
- def included(klass)
9
- klass.extend ClassMethods
10
- end
11
- end
12
-
13
- module ClassMethods
14
- def weekly_counter(name, options = {}) # rubocop:disable Metrics/MethodLength
15
- options[:start] ||= 0
16
- options[:type] ||= (options[:start]).zero? ? :increment : :decrement
17
- redis_objects[name.to_sym] = options.merge(type: :counter)
18
-
19
- mod = Module.new do
20
- define_method(name) do
21
- Redis::WeeklyCounter.new(
22
- redis_field_key(name), redis_field_redis(name), redis_options(name)
23
- )
24
- end
25
- end
26
-
27
- if options[:global]
28
- extend mod
29
-
30
- # dispatch to class methods
31
- define_method(name) do
32
- self.class.public_send(name)
33
- end
34
- else
35
- include mod
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'redis/weekly_set'
4
- class Redis
5
- module Objects
6
- module WeeklySets
7
- def self.included(klass)
8
- klass.extend ClassMethods
9
- end
10
-
11
- # Class methods that appear in your class when you include Redis::Objects.
12
- module ClassMethods
13
- # Define a new list. It will function like a regular instance
14
- # method, so it can be used alongside ActiveRecord, DataMapper, etc.
15
- def weekly_set(name, options = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
16
- redis_objects[name.to_sym] = options.merge(type: :set)
17
-
18
- mod = Module.new do
19
- define_method(name) do
20
- Redis::WeeklySet.new(
21
- redis_field_key(name), redis_field_redis(name), redis_options(name)
22
- )
23
- end
24
-
25
- define_method(:"#{name}=") do |values|
26
- set = public_send(name)
27
-
28
- redis.pipelined do
29
- set.clear
30
- set.merge(*values)
31
- end
32
- end
33
- end
34
-
35
- if options[:global]
36
- extend mod
37
-
38
- # dispatch to class methods
39
- define_method(name) do
40
- self.class.public_send(name)
41
- end
42
- else
43
- include mod
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "#{File.dirname(__FILE__)}/recurring_at_intervals"
4
- require "#{File.dirname(__FILE__)}/base_counter_object"
5
- require "#{File.dirname(__FILE__)}/recurring_at_intervals/weekly"
6
-
7
- class Redis
8
- class WeeklyCounter < Counter
9
- include RecurringAtIntervals
10
- include BaseCounterObject
11
- include Weekly
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "#{File.dirname(__FILE__)}/recurring_at_intervals"
4
- require "#{File.dirname(__FILE__)}/base_set_object"
5
- require "#{File.dirname(__FILE__)}/recurring_at_intervals/weekly"
6
-
7
- class Redis
8
- class WeeklySet < Set
9
- include RecurringAtIntervals
10
- include BaseSetObject
11
- include Weekly
12
- end
13
- end