rrule 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.rubocop.yml +4 -1
- data/.travis.yml +33 -5
- data/Appraisals +27 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile +1 -1
- data/gemfiles/activesupport_2.3_LTS.gemfile +16 -0
- data/gemfiles/activesupport_3.gemfile +16 -0
- data/gemfiles/activesupport_4.gemfile +15 -0
- data/gemfiles/activesupport_5.gemfile +15 -0
- data/gemfiles/activesupport_6.gemfile +15 -0
- data/gemfiles/activesupport_7.gemfile +15 -0
- data/lib/rrule/filters/by_week_day.rb +3 -3
- data/lib/rrule/generators/generator.rb +2 -0
- data/lib/rrule/rule.rb +24 -5
- data/lib/rrule/version.rb +1 -1
- data/lib/rrule/weekday.rb +1 -1
- data/rrule.gemspec +3 -2
- metadata +30 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 102a445f4ce73b7678d2ba5ce981dd97265cd96eaba985a1a88fc65bef7dd6f5
|
4
|
+
data.tar.gz: 436d7cf84a7e8673e3909a6b0dc6b629c348ca1b0a2df83b133201e7e46413b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b59c32ff4f679d3f7d1e8944b87e460d1a2ea5aa0bd7c38d3039cd62fb60af56dbc41e23eef63b42add7c3136e4af4ab62ef166e1c1cb643cff89e9a4784d9c
|
7
|
+
data.tar.gz: 8040ef1e6d6c127e33352032e0bb146a46a1ba22c01237fac1a14343bac6f751803cd2582ec7058dd1d32cf0e319aa8e439be5f312ff189a755b28c48efaa985
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,8 +1,36 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
3
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
-
|
7
|
-
-
|
8
|
-
|
4
|
+
- 2.6.5
|
5
|
+
- 2.7.0
|
6
|
+
- 3.0.0
|
7
|
+
- 3.1.0
|
8
|
+
|
9
|
+
gemfile:
|
10
|
+
- gemfiles/activesupport_2.3_LTS.gemfile
|
11
|
+
- gemfiles/activesupport_3.gemfile
|
12
|
+
- gemfiles/activesupport_4.gemfile
|
13
|
+
- gemfiles/activesupport_5.gemfile
|
14
|
+
- gemfiles/activesupport_6.gemfile
|
15
|
+
- gemfiles/activesupport_7.gemfile
|
16
|
+
|
17
|
+
jobs:
|
18
|
+
exclude:
|
19
|
+
- rvm: 2.6.5
|
20
|
+
gemfile: gemfiles/activesupport_7.gemfile
|
21
|
+
- rvm: 2.7.0
|
22
|
+
gemfile: gemfiles/activesupport_3.gemfile
|
23
|
+
- rvm: 2.7.0
|
24
|
+
gemfile: gemfiles/activesupport_4.gemfile
|
25
|
+
- rvm: 3.0.0
|
26
|
+
gemfile: gemfiles/activesupport_3.gemfile
|
27
|
+
- rvm: 3.0.0
|
28
|
+
gemfile: gemfiles/activesupport_4.gemfile
|
29
|
+
- rvm: 3.1.0
|
30
|
+
gemfile: gemfiles/activesupport_3.gemfile
|
31
|
+
- rvm: 3.1.0
|
32
|
+
gemfile: gemfiles/activesupport_4.gemfile
|
33
|
+
|
34
|
+
before_install:
|
35
|
+
- yes | gem update --system --force
|
36
|
+
- gem install bundler
|
data/Appraisals
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
appraise 'activesupport-2.3-LTS' do
|
4
|
+
gem 'rexml'
|
5
|
+
gem 'activesupport', '>= 2', git: 'https://github.com/makandra/rails.git', branch: '2-3-lts'
|
6
|
+
end
|
7
|
+
|
8
|
+
appraise 'activesupport-3' do
|
9
|
+
gem 'activesupport', '~> 3'
|
10
|
+
gem 'tzinfo', '~> 1.2'
|
11
|
+
end
|
12
|
+
|
13
|
+
appraise 'activesupport-4' do
|
14
|
+
gem 'activesupport', '~> 4'
|
15
|
+
end
|
16
|
+
|
17
|
+
appraise 'activesupport-5' do
|
18
|
+
gem 'activesupport', '~> 5'
|
19
|
+
end
|
20
|
+
|
21
|
+
appraise 'activesupport-6' do
|
22
|
+
gem 'activesupport', '~> 6'
|
23
|
+
end
|
24
|
+
|
25
|
+
appraise 'activesupport-7' do
|
26
|
+
gem 'activesupport', '~> 7'
|
27
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
Change Log
|
2
2
|
==========
|
3
3
|
|
4
|
+
Version 0.5.0 *(2022-03-14)*
|
5
|
+
----------------------------
|
6
|
+
Add #from method to Rule object
|
7
|
+
|
8
|
+
Version 0.4.4 *(2022-03-01)*
|
9
|
+
----------------------------
|
10
|
+
Remove constraint on ActiveSupport version
|
11
|
+
|
12
|
+
Version 0.4.3 *(2021-08-10)*
|
13
|
+
----------------------------
|
14
|
+
Adding support for multiple versions of ActiveSupport, up until at least ActiveSupport 6
|
15
|
+
Handle case where DTSTART is a date
|
16
|
+
Several bugfixes (fix weekday ordinal matching, BYDAY calculations with and without ordinals)
|
17
|
+
|
18
|
+
Version 0.4.2 *(2019-02-05)*
|
19
|
+
----------------------------
|
20
|
+
Truncate the floor_date option if it's less than the dtstart option
|
21
|
+
|
4
22
|
Version 0.4.1 *(2018-11-28)*
|
5
23
|
----------------------------
|
6
24
|
Fix bug in SimpleWeekly when ENV['TZ'] was not equal to time zone of rrule
|
data/Gemfile
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "pry", "~> 0.12.2"
|
6
|
+
gem "rake"
|
7
|
+
gem "rspec", "~> 3.8"
|
8
|
+
gem "rubocop", "0.63.1"
|
9
|
+
gem "rexml"
|
10
|
+
gem "activesupport", ">= 2", git: "https://github.com/makandra/rails.git", branch: "2-3-lts"
|
11
|
+
|
12
|
+
platforms :mri do
|
13
|
+
gem "pry-byebug"
|
14
|
+
end
|
15
|
+
|
16
|
+
gemspec path: "../"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "pry", "~> 0.12.2"
|
6
|
+
gem "rake"
|
7
|
+
gem "rspec", "~> 3.8"
|
8
|
+
gem "rubocop", "0.63.1"
|
9
|
+
gem "activesupport", "~> 3"
|
10
|
+
gem "tzinfo", "~> 1.2"
|
11
|
+
|
12
|
+
platforms :mri do
|
13
|
+
gem "pry-byebug"
|
14
|
+
end
|
15
|
+
|
16
|
+
gemspec path: "../"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "pry", "~> 0.12.2"
|
6
|
+
gem "rake"
|
7
|
+
gem "rspec", "~> 3.8"
|
8
|
+
gem "rubocop", "0.63.1"
|
9
|
+
gem "activesupport", "~> 4"
|
10
|
+
|
11
|
+
platforms :mri do
|
12
|
+
gem "pry-byebug"
|
13
|
+
end
|
14
|
+
|
15
|
+
gemspec path: "../"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "pry", "~> 0.12.2"
|
6
|
+
gem "rake"
|
7
|
+
gem "rspec", "~> 3.8"
|
8
|
+
gem "rubocop", "0.63.1"
|
9
|
+
gem "activesupport", "~> 5"
|
10
|
+
|
11
|
+
platforms :mri do
|
12
|
+
gem "pry-byebug"
|
13
|
+
end
|
14
|
+
|
15
|
+
gemspec path: "../"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "pry", "~> 0.12.2"
|
6
|
+
gem "rake"
|
7
|
+
gem "rspec", "~> 3.8"
|
8
|
+
gem "rubocop", "0.63.1"
|
9
|
+
gem "activesupport", "~> 6"
|
10
|
+
|
11
|
+
platforms :mri do
|
12
|
+
gem "pry-byebug"
|
13
|
+
end
|
14
|
+
|
15
|
+
gemspec path: "../"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "pry", "~> 0.12.2"
|
6
|
+
gem "rake"
|
7
|
+
gem "rspec", "~> 3.8"
|
8
|
+
gem "rubocop", "0.63.1"
|
9
|
+
gem "activesupport", "~> 7"
|
10
|
+
|
11
|
+
platforms :mri do
|
12
|
+
gem "pry-byebug"
|
13
|
+
end
|
14
|
+
|
15
|
+
gemspec path: "../"
|
@@ -8,17 +8,17 @@ module RRule
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def reject?(i)
|
11
|
-
masked?(i)
|
11
|
+
masked?(i) && !matches_by_week_days?(i)
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def masked?(i)
|
17
|
-
context.day_of_year_mask
|
17
|
+
context.day_of_year_mask.blank? || !context.day_of_year_mask[i]
|
18
18
|
end
|
19
19
|
|
20
20
|
def matches_by_week_days?(i)
|
21
|
-
by_week_days.
|
21
|
+
by_week_days.present? && by_week_days.include?(context.weekday_by_day_of_year[i])
|
22
22
|
end
|
23
23
|
|
24
24
|
attr_reader :by_week_days, :context
|
data/lib/rrule/rule.rb
CHANGED
@@ -8,7 +8,7 @@ module RRule
|
|
8
8
|
|
9
9
|
def initialize(rrule, dtstart: Time.now, tzid: 'UTC', exdate: [], max_year: nil)
|
10
10
|
@tz = tzid
|
11
|
-
@dtstart = floor_to_seconds_in_timezone(dtstart)
|
11
|
+
@dtstart = dtstart.is_a?(Date) ? dtstart : floor_to_seconds_in_timezone(dtstart)
|
12
12
|
@exdate = exdate
|
13
13
|
@options = parse_options(rrule)
|
14
14
|
@frequency_type = Frequency.for_options(options)
|
@@ -26,6 +26,11 @@ module RRule
|
|
26
26
|
all_until(start_date: floored_start_date, end_date: floored_end_date, limit: limit).reject { |instance| instance < floored_start_date }
|
27
27
|
end
|
28
28
|
|
29
|
+
def from(start_date, limit:)
|
30
|
+
floored_start_date = floor_to_seconds_in_timezone(start_date)
|
31
|
+
all_until(start_date: floored_start_date, limit: limit).reject { |instance| instance < floored_start_date }
|
32
|
+
end
|
33
|
+
|
29
34
|
def each(floor_date: nil)
|
30
35
|
# If we have a COUNT or INTERVAL option, we have to start at dtstart, because those are relative to dtstart
|
31
36
|
floor_date = dtstart if count_or_interval_present? || floor_date.nil? || dtstart > floor_date
|
@@ -89,13 +94,21 @@ module RRule
|
|
89
94
|
end
|
90
95
|
|
91
96
|
def all_until(start_date: nil, end_date: max_date, limit: nil)
|
92
|
-
|
97
|
+
count = 0
|
98
|
+
each(floor_date: start_date).take_while do |date|
|
99
|
+
if limit
|
100
|
+
date <= end_date && (count += 1) <= limit
|
101
|
+
else
|
102
|
+
date <= end_date
|
103
|
+
end
|
104
|
+
end
|
93
105
|
end
|
94
106
|
|
95
107
|
def parse_options(rule)
|
96
108
|
options = { interval: 1, wkst: 1 }
|
97
109
|
|
98
|
-
|
110
|
+
# Remove RRULE: prefix to prevent parsing options incorrectly.
|
111
|
+
params = rule.delete_prefix('RRULE:').split(';')
|
99
112
|
params.each do |param|
|
100
113
|
option, value = param.split('=')
|
101
114
|
|
@@ -111,7 +124,9 @@ module RRule
|
|
111
124
|
raise InvalidRRule, 'COUNT must be a non-negative integer' if i < 0
|
112
125
|
options[:count] = i
|
113
126
|
when 'UNTIL'
|
114
|
-
|
127
|
+
# The value of the UNTIL rule part MUST have the same
|
128
|
+
# value type as the "DTSTART" property.
|
129
|
+
options[:until] = @dtstart.is_a?(Date) ? Date.parse(value) : Time.parse(value)
|
115
130
|
when 'INTERVAL'
|
116
131
|
i = Integer(value) rescue 0
|
117
132
|
raise InvalidRRule, 'INTERVAL must be a positive integer' unless i > 0
|
@@ -154,7 +169,11 @@ module RRule
|
|
154
169
|
|
155
170
|
options[:byweekday], options[:bynweekday] = options[:byweekday].partition { |wday| wday.ordinal.nil? } unless options[:byweekday].nil?
|
156
171
|
|
157
|
-
|
172
|
+
# The BYSECOND, BYMINUTE and BYHOUR rule parts MUST NOT be specified
|
173
|
+
# when the associated "DTSTART" property has a DATE value type.
|
174
|
+
# These rule parts MUST be ignored in RECUR value that violate the
|
175
|
+
# above requirement
|
176
|
+
options[:timeset] = [{ hour: (options[:byhour].presence || dtstart.hour), minute: (options[:byminute].presence || dtstart.min), second: (options[:bysecond].presence || dtstart.sec) }] unless dtstart.is_a?(Date)
|
158
177
|
|
159
178
|
options
|
160
179
|
end
|
data/lib/rrule/version.rb
CHANGED
data/lib/rrule/weekday.rb
CHANGED
data/rrule.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
'changelog_uri' => 'https://github.com/square/ruby-rrule/blob/master/CHANGELOG.md'
|
22
22
|
}
|
23
23
|
|
24
|
-
s.required_ruby_version = '>= 2.
|
25
|
-
s.add_runtime_dependency 'activesupport', '>=
|
24
|
+
s.required_ruby_version = '>= 2.6.0'
|
25
|
+
s.add_runtime_dependency 'activesupport', '>= 2.3'
|
26
|
+
s.add_development_dependency 'appraisal'
|
26
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rrule
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Mitchell
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: appraisal
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: A gem for expanding dates according to the RRule specification
|
28
42
|
email: rmitchell@squareup.com
|
29
43
|
executables: []
|
@@ -33,12 +47,19 @@ files:
|
|
33
47
|
- ".gitignore"
|
34
48
|
- ".rubocop.yml"
|
35
49
|
- ".travis.yml"
|
50
|
+
- Appraisals
|
36
51
|
- CHANGELOG.md
|
37
52
|
- CONTRIBUTING.md
|
38
53
|
- Gemfile
|
39
54
|
- LICENSE.txt
|
40
55
|
- README.md
|
41
56
|
- Rakefile
|
57
|
+
- gemfiles/activesupport_2.3_LTS.gemfile
|
58
|
+
- gemfiles/activesupport_3.gemfile
|
59
|
+
- gemfiles/activesupport_4.gemfile
|
60
|
+
- gemfiles/activesupport_5.gemfile
|
61
|
+
- gemfiles/activesupport_6.gemfile
|
62
|
+
- gemfiles/activesupport_7.gemfile
|
42
63
|
- lib/rrule.rb
|
43
64
|
- lib/rrule/context.rb
|
44
65
|
- lib/rrule/filters/by_month.rb
|
@@ -68,7 +89,7 @@ metadata:
|
|
68
89
|
source_code_uri: https://github.com/square/ruby-rrule
|
69
90
|
bug_tracker_uri: https://github.com/square/ruby-rrule/issues
|
70
91
|
changelog_uri: https://github.com/square/ruby-rrule/blob/master/CHANGELOG.md
|
71
|
-
post_install_message:
|
92
|
+
post_install_message:
|
72
93
|
rdoc_options: []
|
73
94
|
require_paths:
|
74
95
|
- lib
|
@@ -76,15 +97,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
97
|
requirements:
|
77
98
|
- - ">="
|
78
99
|
- !ruby/object:Gem::Version
|
79
|
-
version: 2.
|
100
|
+
version: 2.6.0
|
80
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
102
|
requirements:
|
82
103
|
- - ">="
|
83
104
|
- !ruby/object:Gem::Version
|
84
105
|
version: '0'
|
85
106
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
87
|
-
signing_key:
|
107
|
+
rubygems_version: 3.1.6
|
108
|
+
signing_key:
|
88
109
|
specification_version: 4
|
89
110
|
summary: RRule expansion
|
90
111
|
test_files: []
|