redis-objects-daily-counter 0.3.0 → 0.4.0
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 +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
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'redis/periodical_hash_key'
|
4
|
+
|
5
|
+
Redis::PERIODICALS.each do |periodical| # rubocop:disable Metrics/BlockLength
|
6
|
+
new_module = Module.new
|
7
|
+
new_module.module_eval <<~RUBY, __FILE__, __LINE__ + 1
|
8
|
+
def self.included(klass)
|
9
|
+
klass.extend ClassMethods
|
10
|
+
end
|
11
|
+
|
12
|
+
# Class methods that appear in your class when you include Redis::Objects.
|
13
|
+
module ClassMethods
|
14
|
+
# Define a new hash key. It will function like a regular instance
|
15
|
+
# method, so it can be used alongside ActiveRecord, DataMapper, etc.
|
16
|
+
def #{periodical}_hash_key(name, options = {})
|
17
|
+
redis_objects[name.to_sym] = options.merge(type: :dict)
|
18
|
+
|
19
|
+
mod = Module.new do
|
20
|
+
define_method(name) do
|
21
|
+
Redis::#{periodical.capitalize}HashKey.new(
|
22
|
+
redis_field_key(name), redis_field_redis(name), redis_options(name)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
define_method(:"#\{name\}=") do |values|
|
27
|
+
hash_key = public_send(name)
|
28
|
+
|
29
|
+
redis.pipelined do
|
30
|
+
hash_key.clear
|
31
|
+
hash_key.bulk_set(values)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
if options[:global]
|
37
|
+
extend mod
|
38
|
+
|
39
|
+
# dispatch to class methods
|
40
|
+
define_method(name) do
|
41
|
+
self.class.public_send(name)
|
42
|
+
end
|
43
|
+
else
|
44
|
+
include mod
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
RUBY
|
49
|
+
Redis::Objects.const_set("#{periodical.capitalize}Hashes", new_module)
|
50
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'redis/periodical_set'
|
4
|
+
|
5
|
+
Redis::PERIODICALS.each do |periodical| # rubocop:disable Metrics/BlockLength
|
6
|
+
new_module = Module.new
|
7
|
+
new_module.module_eval <<~RUBY, __FILE__, __LINE__ + 1
|
8
|
+
def self.included(klass)
|
9
|
+
klass.extend ClassMethods
|
10
|
+
end
|
11
|
+
|
12
|
+
# Class methods that appear in your class when you include Redis::Objects.
|
13
|
+
module ClassMethods
|
14
|
+
# Define a new list. It will function like a regular instance
|
15
|
+
# method, so it can be used alongside ActiveRecord, DataMapper, etc.
|
16
|
+
def #{periodical}_set(name, options = {})
|
17
|
+
redis_objects[name.to_sym] = options.merge(type: :set)
|
18
|
+
|
19
|
+
mod = Module.new do
|
20
|
+
define_method(name) do
|
21
|
+
Redis::#{periodical.capitalize}Set.new(
|
22
|
+
redis_field_key(name), redis_field_redis(name), redis_options(name)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
define_method(:"#\{name\}=") do |values|
|
27
|
+
set = public_send(name)
|
28
|
+
|
29
|
+
redis.pipelined do
|
30
|
+
set.clear
|
31
|
+
set.merge(*values)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
if options[:global]
|
37
|
+
extend mod
|
38
|
+
|
39
|
+
# dispatch to class methods
|
40
|
+
define_method(name) do
|
41
|
+
self.class.public_send(name)
|
42
|
+
end
|
43
|
+
else
|
44
|
+
include mod
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
RUBY
|
49
|
+
Redis::Objects.const_set("#{periodical.capitalize}Sets", new_module)
|
50
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "#{File.dirname(__FILE__)}/recurring_at_intervals"
|
4
|
+
require "#{File.dirname(__FILE__)}/base_counter_object"
|
5
|
+
|
6
|
+
Redis::PERIODICALS.each do |periodical|
|
7
|
+
require "#{File.dirname(__FILE__)}/recurring_at_intervals/#{periodical}"
|
8
|
+
|
9
|
+
new_class = Class.new(Redis::Counter) do
|
10
|
+
include Redis::RecurringAtIntervals
|
11
|
+
include Redis::BaseCounterObject
|
12
|
+
include const_get("Redis::RecurringAtIntervals::#{periodical.capitalize}")
|
13
|
+
end
|
14
|
+
Redis.const_set("#{periodical.capitalize}Counter", new_class)
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "#{File.dirname(__FILE__)}/recurring_at_intervals"
|
4
|
+
require "#{File.dirname(__FILE__)}/base_hash_key_object"
|
5
|
+
|
6
|
+
Redis::PERIODICALS.each do |periodical|
|
7
|
+
require "#{File.dirname(__FILE__)}/recurring_at_intervals/#{periodical}"
|
8
|
+
|
9
|
+
new_class = Class.new(Redis::HashKey) do
|
10
|
+
include Redis::RecurringAtIntervals
|
11
|
+
include Redis::BaseHashKeyObject
|
12
|
+
include const_get("Redis::RecurringAtIntervals::#{periodical.capitalize}")
|
13
|
+
end
|
14
|
+
Redis.const_set("#{periodical.capitalize}HashKey", new_class)
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "#{File.dirname(__FILE__)}/recurring_at_intervals"
|
4
|
+
require "#{File.dirname(__FILE__)}/base_set_object"
|
5
|
+
|
6
|
+
Redis::PERIODICALS.each do |periodical|
|
7
|
+
require "#{File.dirname(__FILE__)}/recurring_at_intervals/#{periodical}"
|
8
|
+
|
9
|
+
new_class = Class.new(Redis::Set) do
|
10
|
+
include Redis::RecurringAtIntervals
|
11
|
+
include Redis::BaseSetObject
|
12
|
+
include const_get("Redis::RecurringAtIntervals::#{periodical.capitalize}")
|
13
|
+
end
|
14
|
+
Redis.const_set("#{periodical.capitalize}Set", new_class)
|
15
|
+
end
|
@@ -3,34 +3,20 @@
|
|
3
3
|
require 'redis-objects'
|
4
4
|
|
5
5
|
class Redis
|
6
|
-
|
7
|
-
autoload :WeeklyCounter, 'redis/weekly_counter'
|
8
|
-
autoload :MonthlyCounter, 'redis/monthly_counter'
|
9
|
-
autoload :AnnualCounter, 'redis/annual_counter'
|
10
|
-
autoload :HourlyCounter, 'redis/hourly_counter'
|
11
|
-
autoload :MinutelyCounter, 'redis/minutely_counter'
|
6
|
+
PERIODICALS = %w[daily weekly monthly annual hourly minutely].freeze
|
12
7
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
autoload :MinutelySet, 'redis/minutely_set'
|
8
|
+
PERIODICALS.each do |periodical|
|
9
|
+
autoload :"#{periodical.capitalize}Counter", 'redis/periodical_counter'
|
10
|
+
autoload :"#{periodical.capitalize}HashKey", 'redis/periodical_hash_key'
|
11
|
+
autoload :"#{periodical.capitalize}Set", 'redis/periodical_set'
|
12
|
+
end
|
19
13
|
|
20
14
|
module Objects
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
autoload :MinutelyCounters, 'redis/objects/minutely_counters'
|
27
|
-
|
28
|
-
autoload :DailySets, 'redis/objects/daily_sets'
|
29
|
-
autoload :WeeklySets, 'redis/objects/weekly_sets'
|
30
|
-
autoload :MonthlySets, 'redis/objects/monthly_sets'
|
31
|
-
autoload :AnnualSets, 'redis/objects/annual_sets'
|
32
|
-
autoload :HourlySets, 'redis/objects/hourly_sets'
|
33
|
-
autoload :MinutelySets, 'redis/objects/minutely_sets'
|
15
|
+
PERIODICALS.each do |periodical|
|
16
|
+
autoload :"#{periodical.capitalize}Counters", 'redis/objects/periodical_counters'
|
17
|
+
autoload :"#{periodical.capitalize}Hashes", 'redis/objects/periodical_hashes'
|
18
|
+
autoload :"#{periodical.capitalize}Sets", 'redis/objects/periodical_sets'
|
19
|
+
end
|
34
20
|
|
35
21
|
class << self
|
36
22
|
alias original_included included
|
@@ -39,19 +25,11 @@ class Redis
|
|
39
25
|
original_included(klass)
|
40
26
|
|
41
27
|
# Pull in each object type
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
klass.send :include, Redis::Objects::MinutelyCounters
|
48
|
-
|
49
|
-
klass.send :include, Redis::Objects::DailySets
|
50
|
-
klass.send :include, Redis::Objects::WeeklySets
|
51
|
-
klass.send :include, Redis::Objects::MonthlySets
|
52
|
-
klass.send :include, Redis::Objects::AnnualSets
|
53
|
-
klass.send :include, Redis::Objects::HourlySets
|
54
|
-
klass.send :include, Redis::Objects::MinutelySets
|
28
|
+
PERIODICALS.each do |periodical|
|
29
|
+
klass.send :include, const_get("Redis::Objects::#{periodical.capitalize}Counters")
|
30
|
+
klass.send :include, const_get("Redis::Objects::#{periodical.capitalize}Hashes")
|
31
|
+
klass.send :include, const_get("Redis::Objects::#{periodical.capitalize}Sets")
|
32
|
+
end
|
55
33
|
end
|
56
34
|
end
|
57
35
|
end
|
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ['lib']
|
28
28
|
|
29
|
-
spec.required_ruby_version = '>= 2.
|
29
|
+
spec.required_ruby_version = '>= 2.7.0'
|
30
30
|
|
31
31
|
spec.add_dependency 'redis-objects'
|
32
32
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-objects-daily-counter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ryz310
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-objects
|
@@ -33,6 +33,7 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- ".circleci/config.yml"
|
35
35
|
- ".gem_comet.yml"
|
36
|
+
- ".github/dependabot.yml"
|
36
37
|
- ".gitignore"
|
37
38
|
- ".rspec"
|
38
39
|
- ".rubocop.yml"
|
@@ -49,31 +50,16 @@ files:
|
|
49
50
|
- bin/setup
|
50
51
|
- docker-compose.yml
|
51
52
|
- lib/redis-objects-daily-counter.rb
|
52
|
-
- lib/redis/annual_counter.rb
|
53
|
-
- lib/redis/annual_set.rb
|
54
53
|
- lib/redis/base_counter_object.rb
|
54
|
+
- lib/redis/base_hash_key_object.rb
|
55
55
|
- lib/redis/base_set_object.rb
|
56
|
-
- lib/redis/daily_counter.rb
|
57
|
-
- lib/redis/daily_set.rb
|
58
|
-
- lib/redis/hourly_counter.rb
|
59
|
-
- lib/redis/hourly_set.rb
|
60
|
-
- lib/redis/minutely_counter.rb
|
61
|
-
- lib/redis/minutely_set.rb
|
62
|
-
- lib/redis/monthly_counter.rb
|
63
|
-
- lib/redis/monthly_set.rb
|
64
|
-
- lib/redis/objects/annual_counters.rb
|
65
|
-
- lib/redis/objects/annual_sets.rb
|
66
56
|
- lib/redis/objects/daily-counter/version.rb
|
67
|
-
- lib/redis/objects/
|
68
|
-
- lib/redis/objects/
|
69
|
-
- lib/redis/objects/
|
70
|
-
- lib/redis/
|
71
|
-
- lib/redis/
|
72
|
-
- lib/redis/
|
73
|
-
- lib/redis/objects/monthly_counters.rb
|
74
|
-
- lib/redis/objects/monthly_sets.rb
|
75
|
-
- lib/redis/objects/weekly_counters.rb
|
76
|
-
- lib/redis/objects/weekly_sets.rb
|
57
|
+
- lib/redis/objects/periodical_counters.rb
|
58
|
+
- lib/redis/objects/periodical_hashes.rb
|
59
|
+
- lib/redis/objects/periodical_sets.rb
|
60
|
+
- lib/redis/periodical_counter.rb
|
61
|
+
- lib/redis/periodical_hash_key.rb
|
62
|
+
- lib/redis/periodical_set.rb
|
77
63
|
- lib/redis/recurring_at_intervals.rb
|
78
64
|
- lib/redis/recurring_at_intervals/annual.rb
|
79
65
|
- lib/redis/recurring_at_intervals/daily.rb
|
@@ -81,8 +67,6 @@ files:
|
|
81
67
|
- lib/redis/recurring_at_intervals/minutely.rb
|
82
68
|
- lib/redis/recurring_at_intervals/monthly.rb
|
83
69
|
- lib/redis/recurring_at_intervals/weekly.rb
|
84
|
-
- lib/redis/weekly_counter.rb
|
85
|
-
- lib/redis/weekly_set.rb
|
86
70
|
- redis-objects-daily-counter.gemspec
|
87
71
|
homepage: https://github.com/ryz310/redis-objects-daily-counter
|
88
72
|
licenses:
|
@@ -99,14 +83,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
83
|
requirements:
|
100
84
|
- - ">="
|
101
85
|
- !ruby/object:Gem::Version
|
102
|
-
version: 2.
|
86
|
+
version: 2.7.0
|
103
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
88
|
requirements:
|
105
89
|
- - ">="
|
106
90
|
- !ruby/object:Gem::Version
|
107
91
|
version: '0'
|
108
92
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
93
|
+
rubygems_version: 3.3.11
|
110
94
|
signing_key:
|
111
95
|
specification_version: 4
|
112
96
|
summary: Daily counter within Redis::Objects
|
data/lib/redis/annual_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/annual"
|
6
|
-
|
7
|
-
class Redis
|
8
|
-
class AnnualCounter < Counter
|
9
|
-
include RecurringAtIntervals
|
10
|
-
include BaseCounterObject
|
11
|
-
include Annual
|
12
|
-
end
|
13
|
-
end
|
data/lib/redis/annual_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/annual"
|
6
|
-
|
7
|
-
class Redis
|
8
|
-
class AnnualSet < Set
|
9
|
-
include RecurringAtIntervals
|
10
|
-
include BaseSetObject
|
11
|
-
include Annual
|
12
|
-
end
|
13
|
-
end
|
data/lib/redis/daily_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/daily"
|
6
|
-
|
7
|
-
class Redis
|
8
|
-
class DailyCounter < Counter
|
9
|
-
include RecurringAtIntervals
|
10
|
-
include BaseCounterObject
|
11
|
-
include Daily
|
12
|
-
end
|
13
|
-
end
|
data/lib/redis/daily_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/daily"
|
6
|
-
|
7
|
-
class Redis
|
8
|
-
class DailySet < Set
|
9
|
-
include RecurringAtIntervals
|
10
|
-
include BaseSetObject
|
11
|
-
include Daily
|
12
|
-
end
|
13
|
-
end
|
data/lib/redis/hourly_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/hourly"
|
6
|
-
|
7
|
-
class Redis
|
8
|
-
class HourlyCounter < Counter
|
9
|
-
include RecurringAtIntervals
|
10
|
-
include BaseCounterObject
|
11
|
-
include Hourly
|
12
|
-
end
|
13
|
-
end
|
data/lib/redis/hourly_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/hourly"
|
6
|
-
|
7
|
-
class Redis
|
8
|
-
class HourlySet < Set
|
9
|
-
include RecurringAtIntervals
|
10
|
-
include BaseSetObject
|
11
|
-
include Hourly
|
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_counter_object"
|
5
|
-
require "#{File.dirname(__FILE__)}/recurring_at_intervals/minutely"
|
6
|
-
|
7
|
-
class Redis
|
8
|
-
class MinutelyCounter < Counter
|
9
|
-
include RecurringAtIntervals
|
10
|
-
include BaseCounterObject
|
11
|
-
include Minutely
|
12
|
-
end
|
13
|
-
end
|
data/lib/redis/minutely_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/minutely"
|
6
|
-
|
7
|
-
class Redis
|
8
|
-
class MinutelySet < Set
|
9
|
-
include RecurringAtIntervals
|
10
|
-
include BaseSetObject
|
11
|
-
include Minutely
|
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_counter_object"
|
5
|
-
require "#{File.dirname(__FILE__)}/recurring_at_intervals/monthly"
|
6
|
-
|
7
|
-
class Redis
|
8
|
-
class MonthlyCounter < Counter
|
9
|
-
include RecurringAtIntervals
|
10
|
-
include BaseCounterObject
|
11
|
-
include Monthly
|
12
|
-
end
|
13
|
-
end
|
data/lib/redis/monthly_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/monthly"
|
6
|
-
|
7
|
-
class Redis
|
8
|
-
class MonthlySet < Set
|
9
|
-
include RecurringAtIntervals
|
10
|
-
include BaseSetObject
|
11
|
-
include Monthly
|
12
|
-
end
|
13
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'redis/annual_counter'
|
4
|
-
class Redis
|
5
|
-
module Objects
|
6
|
-
module AnnualCounters
|
7
|
-
class << self
|
8
|
-
def included(klass)
|
9
|
-
klass.extend ClassMethods
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module ClassMethods
|
14
|
-
def annual_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::AnnualCounter.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/annual_set'
|
4
|
-
class Redis
|
5
|
-
module Objects
|
6
|
-
module AnnualSets
|
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 annual_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::AnnualSet.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 DailyCounters
|
7
|
-
class << self
|
8
|
-
def included(klass)
|
9
|
-
klass.extend ClassMethods
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module ClassMethods
|
14
|
-
def daily_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::DailyCounter.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/daily_set'
|
4
|
-
class Redis
|
5
|
-
module Objects
|
6
|
-
module DailySets
|
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 daily_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::DailySet.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
|