rrule 0.4.2 → 0.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 110d8805d4e642767c86d7e23f0b77d8d42a0a11ef3c5edf5c08ee2d8f78d4ab
4
- data.tar.gz: 8dcd49b64e8300b5facdfb92c72485b6c87b3003ba9dc87116fe13ca9bd44bf5
3
+ metadata.gz: 75e4c7df763fb7f51c26dd5c904838cd711236c4f0c1b8903aaaa9fa8cb3a177
4
+ data.tar.gz: 8bd2ccc6326b7d839f53744091fed93000616e32af1305c8395fe129e9e5d294
5
5
  SHA512:
6
- metadata.gz: 467ad003c49dea6fb320775f59a33f739405edd0b330b87512ed4e183bcd757f8e16e4deda296c6f916055056ba98ae0be623df3f78fc9b8c39b790ca4198db6
7
- data.tar.gz: c51e63c57919c57c4954b66c4b55d77ed6f513117a338ea76c595239433a1bc983c50706e642ba3b7b596aaf1feb3d111743ba8bd945c61d372f099656170dbb
6
+ metadata.gz: 744bc6a792d4ccaf944b6ed56c090387fe7c7dd87c79eae8f5c93fee299b47451d3834d6bfa7dd7dab062e7ae80fa12b0b333984d18e1579a9d2228ad4119543
7
+ data.tar.gz: 641c8c1f5c8320e4e17461a3dd040171c9a4a71cc6bb3cc1e70d3e16bb6ef8536ff54ace59447c7854a1504a86e0f140bbdc558bffe33515c79e802410c1ec0e
data/.gitignore CHANGED
@@ -3,4 +3,5 @@ Gemfile.lock
3
3
  *.gem
4
4
  *.sublime-project
5
5
  *.sublime-workspace
6
- Gemfile.lock
6
+ .ruby-version
7
+ gemfiles/*.lock
data/.rubocop.yml CHANGED
@@ -1,5 +1,8 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.3
2
+ TargetRubyVersion: 2.6
3
+ Exclude:
4
+ - 'gemfiles/**/*'
5
+ - Appraisals
3
6
 
4
7
  Layout:
5
8
  Enabled: false
data/.travis.yml CHANGED
@@ -1,8 +1,28 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  rvm:
4
- - 2.3.8
5
- - 2.4.5
6
- - 2.5.3
7
- - 2.6.0
8
- - ruby-head
4
+ - 2.6.5
5
+ - 2.7.0
6
+ - 3.0.0
7
+
8
+ gemfile:
9
+ - gemfiles/activesupport_2.3_LTS.gemfile
10
+ - gemfiles/activesupport_3.gemfile
11
+ - gemfiles/activesupport_4.gemfile
12
+ - gemfiles/activesupport_5.gemfile
13
+ - gemfiles/activesupport_6.gemfile
14
+
15
+ jobs:
16
+ exclude:
17
+ - rvm: 2.7.0
18
+ gemfile: gemfiles/activesupport_3.gemfile
19
+ - rvm: 2.7.0
20
+ gemfile: gemfiles/activesupport_4.gemfile
21
+ - rvm: 3.0.0
22
+ gemfile: gemfiles/activesupport_3.gemfile
23
+ - rvm: 3.0.0
24
+ gemfile: gemfiles/activesupport_4.gemfile
25
+
26
+ before_install:
27
+ - yes | gem update --system --force
28
+ - gem install bundler
data/Appraisals ADDED
@@ -0,0 +1,23 @@
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
data/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  Change Log
2
2
  ==========
3
3
 
4
+ Version 0.4.3 *(2021-08-10)*
5
+ ----------------------------
6
+ Adding support for multiple versions of ActiveSupport, up until at least ActiveSupport 6
7
+ Handle case where DTSTART is a date
8
+ Several bugfixes (fix weekday ordinal matching, BYDAY calculations with and without ordinals)
9
+
10
+ Version 0.4.2 *(2019-02-05)*
11
+ ----------------------------
12
+ Truncate the floor_date option if it's less than the dtstart option
13
+
4
14
  Version 0.4.1 *(2018-11-28)*
5
15
  ----------------------------
6
16
  Fix bug in SimpleWeekly when ENV['TZ'] was not equal to time zone of rrule
data/Gemfile CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'pry'
5
+ gem 'pry', '~> 0.12.2'
6
6
  gem 'rake'
7
7
  gem 'rspec', '~> 3.8'
8
8
  gem 'rubocop', '0.63.1'
@@ -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: "../"
@@ -8,17 +8,17 @@ module RRule
8
8
  end
9
9
 
10
10
  def reject?(i)
11
- masked?(i) || !matches_by_week_days?(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 && !context.day_of_year_mask[i]
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.empty? || by_week_days.include?(context.weekday_by_day_of_year[i])
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
@@ -9,6 +9,8 @@ module RRule
9
9
  end
10
10
 
11
11
  def process_timeset(date, timeset)
12
+ return [date] if timeset.blank?
13
+
12
14
  timeset.map do |time|
13
15
  hour_sets = (
14
16
  Array.wrap(time[:hour]).sort.map do |hour|
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)
@@ -111,7 +111,9 @@ module RRule
111
111
  raise InvalidRRule, 'COUNT must be a non-negative integer' if i < 0
112
112
  options[:count] = i
113
113
  when 'UNTIL'
114
- options[:until] = Time.parse(value)
114
+ # The value of the UNTIL rule part MUST have the same
115
+ # value type as the "DTSTART" property.
116
+ options[:until] = @dtstart.is_a?(Date) ? Date.parse(value) : Time.parse(value)
115
117
  when 'INTERVAL'
116
118
  i = Integer(value) rescue 0
117
119
  raise InvalidRRule, 'INTERVAL must be a positive integer' unless i > 0
@@ -154,7 +156,11 @@ module RRule
154
156
 
155
157
  options[:byweekday], options[:bynweekday] = options[:byweekday].partition { |wday| wday.ordinal.nil? } unless options[:byweekday].nil?
156
158
 
157
- options[:timeset] = [{ hour: (options[:byhour].presence || dtstart.hour), minute: (options[:byminute].presence || dtstart.min), second: (options[:bysecond].presence || dtstart.sec) }]
159
+ # The BYSECOND, BYMINUTE and BYHOUR rule parts MUST NOT be specified
160
+ # when the associated "DTSTART" property has a DATE value type.
161
+ # These rule parts MUST be ignored in RECUR value that violate the
162
+ # above requirement
163
+ 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
164
 
159
165
  options
160
166
  end
data/lib/rrule/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RRule
4
- VERSION = '0.4.2'
4
+ VERSION = '0.4.3'
5
5
  end
data/lib/rrule/weekday.rb CHANGED
@@ -10,7 +10,7 @@ module RRule
10
10
  end
11
11
 
12
12
  def self.parse(weekday)
13
- match = /([+-]?\d)?([A-Z]{2})/.match(weekday)
13
+ match = /([+-]?\d+)?([A-Z]{2})/.match(weekday)
14
14
  index = RRule::WEEKDAYS.index(match[2])
15
15
  ordinal = match[1] ? match[1].to_i : nil
16
16
  new(index, ordinal)
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.3.0'
25
- s.add_runtime_dependency 'activesupport', '>= 4.1'
24
+ s.required_ruby_version = '>= 2.6.0'
25
+ s.add_runtime_dependency 'activesupport', '>= 2.3', '< 7'
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.2
4
+ version: 0.4.3
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: 2019-02-06 00:00:00.000000000 Z
11
+ date: 2021-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.1'
19
+ version: '2.3'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '4.1'
29
+ version: '2.3'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7'
33
+ - !ruby/object:Gem::Dependency
34
+ name: appraisal
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
27
47
  description: A gem for expanding dates according to the RRule specification
28
48
  email: rmitchell@squareup.com
29
49
  executables: []
@@ -33,12 +53,18 @@ files:
33
53
  - ".gitignore"
34
54
  - ".rubocop.yml"
35
55
  - ".travis.yml"
56
+ - Appraisals
36
57
  - CHANGELOG.md
37
58
  - CONTRIBUTING.md
38
59
  - Gemfile
39
60
  - LICENSE.txt
40
61
  - README.md
41
62
  - Rakefile
63
+ - gemfiles/activesupport_2.3_LTS.gemfile
64
+ - gemfiles/activesupport_3.gemfile
65
+ - gemfiles/activesupport_4.gemfile
66
+ - gemfiles/activesupport_5.gemfile
67
+ - gemfiles/activesupport_6.gemfile
42
68
  - lib/rrule.rb
43
69
  - lib/rrule/context.rb
44
70
  - lib/rrule/filters/by_month.rb
@@ -68,7 +94,7 @@ metadata:
68
94
  source_code_uri: https://github.com/square/ruby-rrule
69
95
  bug_tracker_uri: https://github.com/square/ruby-rrule/issues
70
96
  changelog_uri: https://github.com/square/ruby-rrule/blob/master/CHANGELOG.md
71
- post_install_message:
97
+ post_install_message:
72
98
  rdoc_options: []
73
99
  require_paths:
74
100
  - lib
@@ -76,15 +102,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
102
  requirements:
77
103
  - - ">="
78
104
  - !ruby/object:Gem::Version
79
- version: 2.3.0
105
+ version: 2.6.0
80
106
  required_rubygems_version: !ruby/object:Gem::Requirement
81
107
  requirements:
82
108
  - - ">="
83
109
  - !ruby/object:Gem::Version
84
110
  version: '0'
85
111
  requirements: []
86
- rubygems_version: 3.0.1
87
- signing_key:
112
+ rubygems_version: 3.1.4
113
+ signing_key:
88
114
  specification_version: 4
89
115
  summary: RRule expansion
90
116
  test_files: []