redis-objects-periodical 0.4.1 → 0.5.0

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
  SHA256:
3
- metadata.gz: 3aec4e9399f53e559f5ba5cb679c4e241bc6a4658f3eb3a88ad02e6b6be479c2
4
- data.tar.gz: 232eac099ff37e6751e5335a2312b90103e9eb27f5171d4868c46263ceef66c0
3
+ metadata.gz: e51d6f427d67ed6b1295dc800494c8db45657bb0bc95ef495d198305c4458dc3
4
+ data.tar.gz: eaeda9b6bced5155ff0e8889b4ba65153c7b4792c9496542a0bb08e3689ad032
5
5
  SHA512:
6
- metadata.gz: c0b7f4c767fed43ac27a8c42adff62c56f91940428804e5f768054f2267300e39067c63c44e06da66ef460caef1c57d1df621d3a5288acb7163f0deb25727521
7
- data.tar.gz: 659fb95d1099602eb52d256c43d9d2f703666a56d631e6ee7fd7afbba8ff5faa2ef56640bdfaac6a5723dfd1114b7095a5471f3475e8c6e5d0f84a68d6ab679b
6
+ metadata.gz: 3b01d3bac963a358028ce4eadaf414ff8f310ac161413bbc16ffd9d58a870c0af1344990d4eab4f3376e95914a2ab93cb92a62524b3c86049877c8bd7b1c8831
7
+ data.tar.gz: c0a3ba3f9cc311ab2f212b7c5c0997b3e8d2a01fdc43aa8687067b0c9a0c54819c5d45e3a3afc3460c3b70d929d0370439ec8c06206b375347cf2274a52ad8e4
data/.rubocop.yml CHANGED
@@ -14,7 +14,6 @@ Layout/LineLength:
14
14
  Metrics/BlockLength:
15
15
  Exclude:
16
16
  - "spec/**/*"
17
- - "redis-objects-daily-counter.gemspec"
18
17
  - "redis-objects-periodical.gemspec"
19
18
 
20
19
  Metrics/MethodLength:
data/CHANGELOG.md CHANGED
@@ -1,38 +1,66 @@
1
1
  # Change log
2
2
 
3
+ ## v0.5.0 (Sep 29, 2022)
4
+
5
+ ### Feature
6
+
7
+ - [#34](https://github.com/ryz310/redis-object-daily-counter/pull/34) Enhanced type casting from Time to Date ([@ryz310](https://github.com/ryz310))
8
+
9
+ Enhances casting from `Time` to `Date`.
10
+
11
+ #### Before
12
+
13
+ ```rb
14
+ homepage = Homepage.new
15
+ homepage.daily_active_users[Date.new(2021, 4, 1)] # OK
16
+ homepage.daily_active_users[Time.local(2021, 4, 1, 0, 0, 0)] # Error!
17
+ ```
18
+
19
+ #### After
20
+
21
+ ```rb
22
+ homepage = Homepage.new
23
+ homepage.daily_active_users[Date.new(2021, 4, 1)] # OK
24
+ homepage.daily_active_users[Time.local(2021, 4, 1, 0, 0, 0)] # OK
25
+ ```
26
+
27
+ ### Misc
28
+
29
+ - [#25](https://github.com/ryz310/redis-object-daily-counter/pull/25) Remove needless files ([@ryz310](https://github.com/ryz310))
30
+
3
31
  ## v0.4.1 (Jul 27, 2022)
4
32
 
5
33
  ### Misc
6
34
 
7
- - [#22](https://github.com/ryz310/redis-object-periodical/pull/22) Rename from redis-object-daily-counter to redis-object-periodical ([@ryz310](https://github.com/ryz310))
35
+ - [#22](https://github.com/ryz310/redis-objects-periodical/pull/22) Rename from redis-object-daily-counter to redis-objects-periodical ([@ryz310](https://github.com/ryz310))
8
36
 
9
37
  ## v0.4.0 (Jul 26, 2022)
10
38
 
11
39
  ### Feature
12
40
 
13
- - [#17](https://github.com/ryz310/redis-object-periodical/pull/17) Support `Redis::HashKey` as a recurring object ([@ryz310](https://github.com/ryz310))
41
+ - [#17](https://github.com/ryz310/redis-objects-periodical/pull/17) Support `Redis::HashKey` as a recurring object ([@ryz310](https://github.com/ryz310))
14
42
 
15
43
  ### Breaking Change
16
44
 
17
- - [#18](https://github.com/ryz310/redis-object-periodical/pull/18) Bump up Ruby 3.1 and drop support Ruby 2.6 ([@ryz310](https://github.com/ryz310))
45
+ - [#18](https://github.com/ryz310/redis-objects-periodical/pull/18) Bump up Ruby 3.1 and drop support Ruby 2.6 ([@ryz310](https://github.com/ryz310))
18
46
 
19
47
  ### Dependabot
20
48
 
21
- - [#16](https://github.com/ryz310/redis-object-periodical/pull/16) Bump yard from 0.9.26 to 0.9.28 ([@ryz310](https://github.com/ryz310))
22
- - [#15](https://github.com/ryz310/redis-object-periodical/pull/15) Bump rspec_junit_formatter from 0.4.1 to 0.5.1 ([@ryz310](https://github.com/ryz310))
23
- - [#13](https://github.com/ryz310/redis-object-periodical/pull/13) Bump rspec from 3.10.0 to 3.11.0 ([@ryz310](https://github.com/ryz310))
24
- - [#14](https://github.com/ryz310/redis-object-periodical/pull/14) Bump timecop from 0.9.4 to 0.9.5 ([@ryz310](https://github.com/ryz310))
25
- - [#12](https://github.com/ryz310/redis-object-periodical/pull/12) Bump redis-objects from 1.5.1 to 1.7.0 ([@ryz310](https://github.com/ryz310))
49
+ - [#16](https://github.com/ryz310/redis-objects-periodical/pull/16) Bump yard from 0.9.26 to 0.9.28 ([@ryz310](https://github.com/ryz310))
50
+ - [#15](https://github.com/ryz310/redis-objects-periodical/pull/15) Bump rspec_junit_formatter from 0.4.1 to 0.5.1 ([@ryz310](https://github.com/ryz310))
51
+ - [#13](https://github.com/ryz310/redis-objects-periodical/pull/13) Bump rspec from 3.10.0 to 3.11.0 ([@ryz310](https://github.com/ryz310))
52
+ - [#14](https://github.com/ryz310/redis-objects-periodical/pull/14) Bump timecop from 0.9.4 to 0.9.5 ([@ryz310](https://github.com/ryz310))
53
+ - [#12](https://github.com/ryz310/redis-objects-periodical/pull/12) Bump redis-objects from 1.5.1 to 1.7.0 ([@ryz310](https://github.com/ryz310))
26
54
 
27
55
  ### Misc
28
56
 
29
- - [#19](https://github.com/ryz310/redis-object-periodical/pull/19) Reduce similar source codes with meta programming ([@ryz310](https://github.com/ryz310))
57
+ - [#19](https://github.com/ryz310/redis-objects-periodical/pull/19) Reduce similar source codes with meta programming ([@ryz310](https://github.com/ryz310))
30
58
 
31
59
  ## v0.3.0 (Sep 23, 2021)
32
60
 
33
61
  ### Feature
34
62
 
35
- - [#7](https://github.com/ryz310/redis-object-periodical/pull/7) Add daily set ([@ryz310](https://github.com/ryz310))
63
+ - [#7](https://github.com/ryz310/redis-objects-periodical/pull/7) Add daily set ([@ryz310](https://github.com/ryz310))
36
64
 
37
65
  > You can use `daily_set` in addition to the standard features of Redis::Objects.
38
66
  >
@@ -75,7 +103,7 @@
75
103
 
76
104
  ### Breaking Change
77
105
 
78
- - [#7](https://github.com/ryz310/redis-object-periodical/pull/7) Add daily set ([@ryz310](https://github.com/ryz310))
106
+ - [#7](https://github.com/ryz310/redis-objects-periodical/pull/7) Add daily set ([@ryz310](https://github.com/ryz310))
79
107
 
80
108
  > Rename the method from #delete to #delete_at a73251f
81
109
  >
data/Gemfile CHANGED
@@ -3,7 +3,7 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in redis-objects-periodical.gemspec
6
- gemspec name: 'redis-objects-periodical'
6
+ gemspec
7
7
 
8
8
  gem 'bundler', '>= 2.0'
9
9
  gem 'pry-byebug'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-objects-periodical (0.4.1)
4
+ redis-objects-periodical (0.5.0)
5
5
  redis-objects
6
6
 
7
7
  GEM
@@ -10,24 +10,28 @@ GEM
10
10
  ast (2.4.2)
11
11
  byebug (11.1.3)
12
12
  coderay (1.1.3)
13
+ connection_pool (2.3.0)
13
14
  diff-lcs (1.5.0)
14
15
  docile (1.4.0)
15
16
  method_source (1.0.0)
16
17
  parallel (1.22.1)
17
- parser (3.1.2.0)
18
+ parser (3.1.2.1)
18
19
  ast (~> 2.4.1)
19
- pry (0.13.1)
20
+ pry (0.14.1)
20
21
  coderay (~> 1.1)
21
22
  method_source (~> 1.0)
22
- pry-byebug (3.9.0)
23
+ pry-byebug (3.10.1)
23
24
  byebug (~> 11.0)
24
- pry (~> 0.13.0)
25
+ pry (>= 0.13, < 0.15)
25
26
  rainbow (3.1.1)
26
27
  rake (13.0.6)
27
- redis (4.7.1)
28
+ redis (5.0.5)
29
+ redis-client (>= 0.9.0)
30
+ redis-client (0.9.0)
31
+ connection_pool
28
32
  redis-objects (1.7.0)
29
33
  redis
30
- regexp_parser (2.5.0)
34
+ regexp_parser (2.6.0)
31
35
  rexml (3.2.5)
32
36
  rspec (3.11.0)
33
37
  rspec-core (~> 3.11.0)
@@ -35,14 +39,14 @@ GEM
35
39
  rspec-mocks (~> 3.11.0)
36
40
  rspec-core (3.11.0)
37
41
  rspec-support (~> 3.11.0)
38
- rspec-expectations (3.11.0)
42
+ rspec-expectations (3.11.1)
39
43
  diff-lcs (>= 1.2.0, < 2.0)
40
44
  rspec-support (~> 3.11.0)
41
45
  rspec-mocks (3.11.1)
42
46
  diff-lcs (>= 1.2.0, < 2.0)
43
47
  rspec-support (~> 3.11.0)
44
- rspec-support (3.11.0)
45
- rspec_junit_formatter (0.5.1)
48
+ rspec-support (3.11.1)
49
+ rspec_junit_formatter (0.6.0)
46
50
  rspec-core (>= 2, < 4, != 2.12.0)
47
51
  rubocop (0.93.1)
48
52
  parallel (~> 1.10)
@@ -53,7 +57,7 @@ GEM
53
57
  rubocop-ast (>= 0.6.0)
54
58
  ruby-progressbar (~> 1.7)
55
59
  unicode-display_width (>= 1.4.0, < 2.0)
56
- rubocop-ast (1.19.1)
60
+ rubocop-ast (1.21.0)
57
61
  parser (>= 3.1.1.0)
58
62
  rubocop-performance (1.10.2)
59
63
  rubocop (>= 0.90.0, < 2.0)
data/Rakefile CHANGED
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_helper'
4
-
5
- Bundler::GemHelper.install_tasks(name: 'redis-objects-periodical')
6
-
3
+ require 'bundler/gem_tasks'
7
4
  require 'rspec/core/rake_task'
8
5
 
9
6
  RSpec::Core::RakeTask.new(:spec)
@@ -3,7 +3,7 @@
3
3
  class Redis
4
4
  module Objects
5
5
  module Periodical
6
- VERSION = '0.4.1'
6
+ VERSION = '0.5.0'
7
7
  end
8
8
  end
9
9
  end
@@ -5,13 +5,13 @@ class Redis
5
5
  module Annual
6
6
  private
7
7
 
8
- def redis_daily_field_key(date_or_time)
8
+ def redis_periodical_field_key(date_or_time)
9
9
  date_key = date_or_time.strftime('%Y')
10
10
  [original_key, date_key].flatten.join(':')
11
11
  end
12
12
 
13
- def next_key(date, length = 1)
14
- date.next_year(length)
13
+ def next_key(date_or_time, length = 1)
14
+ date_or_time.to_date.next_year(length)
15
15
  end
16
16
  end
17
17
  end
@@ -5,13 +5,13 @@ class Redis
5
5
  module Daily
6
6
  private
7
7
 
8
- def redis_daily_field_key(date_or_time)
8
+ def redis_periodical_field_key(date_or_time)
9
9
  date_key = date_or_time.strftime('%Y-%m-%d')
10
10
  [original_key, date_key].flatten.join(':')
11
11
  end
12
12
 
13
- def next_key(date, length = 1)
14
- date + length
13
+ def next_key(date_or_time, length = 1)
14
+ date_or_time.to_date + length
15
15
  end
16
16
  end
17
17
  end
@@ -5,7 +5,7 @@ class Redis
5
5
  module Hourly
6
6
  private
7
7
 
8
- def redis_daily_field_key(time)
8
+ def redis_periodical_field_key(time)
9
9
  time_key = time.strftime('%Y-%m-%dT%H')
10
10
  [original_key, time_key].flatten.join(':')
11
11
  end
@@ -5,7 +5,7 @@ class Redis
5
5
  module Minutely
6
6
  private
7
7
 
8
- def redis_daily_field_key(time)
8
+ def redis_periodical_field_key(time)
9
9
  time_key = time.strftime('%Y-%m-%dT%H:%M')
10
10
  [original_key, time_key].flatten.join(':')
11
11
  end
@@ -5,13 +5,13 @@ class Redis
5
5
  module Monthly
6
6
  private
7
7
 
8
- def redis_daily_field_key(date_or_time)
8
+ def redis_periodical_field_key(date_or_time)
9
9
  date_key = date_or_time.strftime('%Y-%m')
10
10
  [original_key, date_key].flatten.join(':')
11
11
  end
12
12
 
13
- def next_key(date, length = 1)
14
- date.next_month(length)
13
+ def next_key(date_or_time, length = 1)
14
+ date_or_time.to_date.next_month(length)
15
15
  end
16
16
  end
17
17
  end
@@ -5,13 +5,13 @@ class Redis
5
5
  module Weekly
6
6
  private
7
7
 
8
- def redis_daily_field_key(date_or_time)
8
+ def redis_periodical_field_key(date_or_time)
9
9
  date_key = date_or_time.strftime('%YW%W')
10
10
  [original_key, date_key].flatten.join(':')
11
11
  end
12
12
 
13
- def next_key(date, length = 1)
14
- date + 7 * length
13
+ def next_key(date_or_time, length = 1)
14
+ date_or_time.to_date + 7 * length
15
15
  end
16
16
  end
17
17
  end
@@ -4,7 +4,7 @@ class Redis
4
4
  module RecurringAtIntervals
5
5
  def initialize(key, *args)
6
6
  @original_key = key
7
- super(redis_daily_field_key(current_time), *args)
7
+ super(redis_periodical_field_key(current_time), *args)
8
8
  end
9
9
 
10
10
  attr_reader :original_key
@@ -19,23 +19,23 @@ class Redis
19
19
  when -1 then nil # Ruby does this (a bit weird)
20
20
  end
21
21
  else
22
- get_value_from_redis(redis_daily_field_key(date_or_time))
22
+ get_value_from_redis(redis_periodical_field_key(date_or_time))
23
23
  end
24
24
  end
25
25
  alias slice []
26
26
 
27
27
  def delete_at(date_or_time)
28
- delete_from_redis(redis_daily_field_key(date_or_time))
28
+ delete_from_redis(redis_periodical_field_key(date_or_time))
29
29
  end
30
30
 
31
31
  def range(start_date_or_time, end_date_or_time)
32
32
  keys = []
33
- date_or_time = start_date_or_time
33
+ date_or_time = normalize(start_date_or_time)
34
34
 
35
35
  loop do
36
- break if date_or_time > end_date_or_time
36
+ break if date_or_time > normalize(end_date_or_time)
37
37
 
38
- keys << redis_daily_field_key(date_or_time)
38
+ keys << redis_periodical_field_key(date_or_time)
39
39
  date_or_time = next_key(date_or_time)
40
40
  end
41
41
 
@@ -43,7 +43,7 @@ class Redis
43
43
  end
44
44
 
45
45
  def at(date_or_time)
46
- get_redis_object(redis_daily_field_key(date_or_time))
46
+ get_redis_object(redis_periodical_field_key(date_or_time))
47
47
  end
48
48
 
49
49
  def current_time
@@ -68,12 +68,16 @@ class Redis
68
68
  raise 'not implemented'
69
69
  end
70
70
 
71
- def redis_daily_field_key(_date_or_time)
71
+ def redis_periodical_field_key(_date_or_time)
72
72
  raise 'not implemented'
73
73
  end
74
74
 
75
- def next_key(_date, _length = 1)
75
+ def next_key(_date_or_time, _length = 1)
76
76
  raise 'not implemented'
77
77
  end
78
+
79
+ def normalize(date_or_time)
80
+ next_key(date_or_time, 0)
81
+ end
78
82
  end
79
83
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-objects-periodical
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryz310
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-26 00:00:00.000000000 Z
11
+ date: 2022-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-objects
@@ -68,7 +68,6 @@ files:
68
68
  - lib/redis/recurring_at_intervals/minutely.rb
69
69
  - lib/redis/recurring_at_intervals/monthly.rb
70
70
  - lib/redis/recurring_at_intervals/weekly.rb
71
- - redis-objects-daily-counter.gemspec
72
71
  - redis-objects-periodical.gemspec
73
72
  homepage: https://github.com/ryz310/redis-objects-periodical
74
73
  licenses:
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = 'redis-objects-daily-counter'
5
- spec.version = '0.4.1'
6
- spec.authors = ['ryz310']
7
- spec.email = ['ryz310@gmail.com']
8
-
9
- spec.summary = 'Daily counter within Redis::Objects'
10
- spec.description = 'Daily counter within Redis::Objects. Works with any class or ORM.'
11
- spec.post_install_message = 'The redis-objects-daily-counter gem has been deprecated and has '\
12
- 'been replaced by redis-objects-periodical. Please switch to '\
13
- 'redis-objects-periodical as soon as possible.'
14
- spec.homepage = 'https://github.com/ryz310/redis-objects-daily-counter'
15
- spec.license = 'MIT'
16
-
17
- spec.metadata['homepage_uri'] = spec.homepage
18
- spec.metadata['source_code_uri'] = 'https://github.com/ryz310/redis-objects-daily-counter'
19
- spec.metadata['changelog_uri'] = 'https://github.com/ryz310/redis-objects-daily-counter/blob/master/CHANGELOG.md'
20
-
21
- # Specify which files should be added to the gem when it is released.
22
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
- end
26
- spec.bindir = 'exe'
27
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
- spec.require_paths = ['lib']
29
-
30
- spec.required_ruby_version = '>= 2.7.0'
31
-
32
- spec.add_dependency 'redis-objects'
33
-
34
- # For more information and examples about making a new gem, checkout our
35
- # guide at: https://bundler.io/guides/creating_gem.html
36
- end