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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +23 -20
- data/.github/dependabot.yml +19 -0
- data/.rubocop.yml +4 -4
- data/CHANGELOG.md +38 -16
- data/Dockerfile +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +30 -27
- data/README.md +81 -33
- data/bin/console +1 -2
- data/lib/redis/base_counter_object.rb +4 -0
- data/lib/redis/base_hash_key_object.rb +40 -0
- data/lib/redis/base_set_object.rb +4 -0
- data/lib/redis/objects/daily-counter/version.rb +1 -1
- data/lib/redis/objects/periodical_counters.rb +40 -0
- data/lib/redis/objects/periodical_hashes.rb +50 -0
- data/lib/redis/objects/periodical_sets.rb +50 -0
- data/lib/redis/periodical_counter.rb +15 -0
- data/lib/redis/periodical_hash_key.rb +15 -0
- data/lib/redis/periodical_set.rb +15 -0
- data/lib/redis/recurring_at_intervals.rb +1 -1
- data/lib/redis-objects-daily-counter.rb +16 -38
- data/redis-objects-daily-counter.gemspec +1 -1
- metadata +12 -28
- data/lib/redis/annual_counter.rb +0 -13
- data/lib/redis/annual_set.rb +0 -13
- data/lib/redis/daily_counter.rb +0 -13
- data/lib/redis/daily_set.rb +0 -13
- data/lib/redis/hourly_counter.rb +0 -13
- data/lib/redis/hourly_set.rb +0 -13
- data/lib/redis/minutely_counter.rb +0 -13
- data/lib/redis/minutely_set.rb +0 -13
- data/lib/redis/monthly_counter.rb +0 -13
- data/lib/redis/monthly_set.rb +0 -13
- data/lib/redis/objects/annual_counters.rb +0 -41
- data/lib/redis/objects/annual_sets.rb +0 -49
- data/lib/redis/objects/daily_counters.rb +0 -41
- data/lib/redis/objects/daily_sets.rb +0 -49
- data/lib/redis/objects/hourly_counters.rb +0 -41
- data/lib/redis/objects/hourly_sets.rb +0 -49
- data/lib/redis/objects/minutely_counters.rb +0 -41
- data/lib/redis/objects/minutely_sets.rb +0 -49
- data/lib/redis/objects/monthly_counters.rb +0 -41
- data/lib/redis/objects/monthly_sets.rb +0 -49
- data/lib/redis/objects/weekly_counters.rb +0 -41
- data/lib/redis/objects/weekly_sets.rb +0 -49
- data/lib/redis/weekly_counter.rb +0 -13
- 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
|
data/lib/redis/weekly_counter.rb
DELETED
@@ -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
|
data/lib/redis/weekly_set.rb
DELETED
@@ -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
|