active_date_range 0.3.1 → 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/.github/workflows/codeql.yml +83 -0
- data/.github/workflows/ruby.yml +9 -10
- data/.rubocop.yml +1 -1
- data/.ruby-version +2 -0
- data/CHANGELOG.md +48 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +154 -77
- data/SECURITY.md +15 -0
- data/active_date_range.gemspec +9 -8
- data/lib/active_date_range/date_range.rb +100 -34
- data/lib/active_date_range/version.rb +1 -1
- metadata +35 -35
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7cc5d1d6cd20c08b30702deb5ecf7822c5cbff0da252e849fa290b90c81c6d8
|
4
|
+
data.tar.gz: 55ff9960e377aed53497050259e8ed76891a11cb2be911cf7a0079429f7bedae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f226583cd68e5f054cc4db0d2fade2ffe7f8825cb659400c07b9e1857c5279856a9fa65e1789ecd4a2b475847937281ce06bed1c4e73df089531ead7d1644900
|
7
|
+
data.tar.gz: a44baee259cee6516cd7729f1572cc3c49aa0e6543d09a201f30036e14a44f886297582c63df7110a09d08ac81e4c752d47a15805c08d4e9b0c6fc7338f5cb5c
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
2
|
+
# to commit it to your repository.
|
3
|
+
#
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
5
|
+
# or to provide custom queries or build logic.
|
6
|
+
#
|
7
|
+
# ******** NOTE ********
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
10
|
+
# supported CodeQL languages.
|
11
|
+
#
|
12
|
+
name: "CodeQL Advanced"
|
13
|
+
|
14
|
+
on:
|
15
|
+
push:
|
16
|
+
branches: [ "main" ]
|
17
|
+
pull_request:
|
18
|
+
branches: [ "main" ]
|
19
|
+
schedule:
|
20
|
+
- cron: '25 4 * * 1'
|
21
|
+
|
22
|
+
jobs:
|
23
|
+
analyze:
|
24
|
+
name: Analyze (${{ matrix.language }})
|
25
|
+
runs-on: ubuntu-latest
|
26
|
+
permissions:
|
27
|
+
# required for all workflows
|
28
|
+
security-events: write
|
29
|
+
|
30
|
+
# required to fetch internal or private CodeQL packs
|
31
|
+
packages: read
|
32
|
+
|
33
|
+
strategy:
|
34
|
+
fail-fast: false
|
35
|
+
matrix:
|
36
|
+
include:
|
37
|
+
- language: actions
|
38
|
+
build-mode: none
|
39
|
+
- language: ruby
|
40
|
+
build-mode: none
|
41
|
+
steps:
|
42
|
+
- name: Checkout repository
|
43
|
+
uses: actions/checkout@v5
|
44
|
+
|
45
|
+
# Add any setup steps before running the `github/codeql-action/init` action.
|
46
|
+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
|
47
|
+
# or others). This is typically only required for manual builds.
|
48
|
+
# - name: Setup runtime (example)
|
49
|
+
# uses: actions/setup-example@v1
|
50
|
+
|
51
|
+
# Initializes the CodeQL tools for scanning.
|
52
|
+
- name: Initialize CodeQL
|
53
|
+
uses: github/codeql-action/init@v3
|
54
|
+
with:
|
55
|
+
languages: ${{ matrix.language }}
|
56
|
+
build-mode: ${{ matrix.build-mode }}
|
57
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
58
|
+
# By default, queries listed here will override any specified in a config file.
|
59
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
60
|
+
|
61
|
+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
62
|
+
# queries: security-extended,security-and-quality
|
63
|
+
|
64
|
+
# If the analyze step fails for one of the languages you are analyzing with
|
65
|
+
# "We were unable to automatically build your code", modify the matrix above
|
66
|
+
# to set the build mode to "manual" for that language. Then modify this step
|
67
|
+
# to build your code.
|
68
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
69
|
+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
70
|
+
- if: matrix.build-mode == 'manual'
|
71
|
+
shell: bash
|
72
|
+
run: |
|
73
|
+
echo 'If you are using a "manual" build mode for one or more of the' \
|
74
|
+
'languages you are analyzing, replace this with the commands to build' \
|
75
|
+
'your code, for example:'
|
76
|
+
echo ' make bootstrap'
|
77
|
+
echo ' make release'
|
78
|
+
exit 1
|
79
|
+
|
80
|
+
- name: Perform CodeQL Analysis
|
81
|
+
uses: github/codeql-action/analyze@v3
|
82
|
+
with:
|
83
|
+
category: "/language:${{matrix.language}}"
|
data/.github/workflows/ruby.yml
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
7
|
|
8
8
|
name: Ruby
|
9
|
+
permissions:
|
10
|
+
contents: read
|
9
11
|
|
10
12
|
on:
|
11
13
|
push:
|
@@ -18,15 +20,12 @@ jobs:
|
|
18
20
|
runs-on: ubuntu-latest
|
19
21
|
strategy:
|
20
22
|
matrix:
|
21
|
-
ruby-version: ['2.
|
23
|
+
ruby-version: ['3.2', '3.3', '3.4']
|
22
24
|
|
23
25
|
steps:
|
24
|
-
- uses: actions/checkout@
|
26
|
+
- uses: actions/checkout@v5
|
25
27
|
- name: Set up Ruby
|
26
|
-
|
27
|
-
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
28
|
-
# uses: ruby/setup-ruby@v1
|
29
|
-
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
28
|
+
uses: ruby/setup-ruby@v1
|
30
29
|
with:
|
31
30
|
ruby-version: ${{ matrix.ruby-version }}
|
32
31
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
@@ -37,13 +36,13 @@ jobs:
|
|
37
36
|
runs-on: ubuntu-latest
|
38
37
|
|
39
38
|
steps:
|
40
|
-
- uses: actions/checkout@
|
41
|
-
- name: Set up Ruby
|
39
|
+
- uses: actions/checkout@v5
|
40
|
+
- name: Set up Ruby
|
42
41
|
uses: ruby/setup-ruby@v1
|
43
42
|
with:
|
44
|
-
ruby-version:
|
43
|
+
ruby-version: 3.4
|
45
44
|
- name: Cache gems
|
46
|
-
uses: actions/cache@
|
45
|
+
uses: actions/cache@v4
|
47
46
|
with:
|
48
47
|
path: vendor/bundle
|
49
48
|
key: ${{ runner.os }}-rubocop-${{ hashFiles('**/Gemfile.lock') }}
|
data/.rubocop.yml
CHANGED
@@ -4,7 +4,7 @@ require:
|
|
4
4
|
- rubocop-rails
|
5
5
|
|
6
6
|
AllCops:
|
7
|
-
TargetRubyVersion:
|
7
|
+
TargetRubyVersion: 3.4
|
8
8
|
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
|
9
9
|
# to ignore them, so only the ones explicitly set in this file are enabled.
|
10
10
|
DisabledByDefault: true
|
data/.ruby-version
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,51 @@
|
|
1
|
+
## 0.4.0
|
2
|
+
|
3
|
+
* Add #stretch_to_end_of_month:
|
4
|
+
|
5
|
+
```
|
6
|
+
DateRange.parse("20250101..20250112).stretch_to_end_of_month
|
7
|
+
# => "20250101..20250131"
|
8
|
+
```
|
9
|
+
|
10
|
+
*Vincent Oord*
|
11
|
+
|
12
|
+
* Add exceeds? to check if the period does not exceed a given limit.
|
13
|
+
|
14
|
+
```
|
15
|
+
DateRange.parse("202501..202503).exceeds?(1.month)
|
16
|
+
# => true
|
17
|
+
|
18
|
+
DateRange.parse("20250101..20250105).exceeds?(1.week)
|
19
|
+
# => false
|
20
|
+
```
|
21
|
+
|
22
|
+
*Vincent Oord*
|
23
|
+
|
24
|
+
* Update to Ruby 3.4.6 compatibility
|
25
|
+
|
26
|
+
*Vincent Oord*
|
27
|
+
|
28
|
+
## 0.3.3
|
29
|
+
|
30
|
+
* Add current? to check if the period containts the current date.
|
31
|
+
|
32
|
+
*Edwin Vlieg*
|
33
|
+
|
34
|
+
* Add .from_date_and_duration:
|
35
|
+
|
36
|
+
```
|
37
|
+
DateRange.from_date_and_duration(Date.new(2023, 1, 1), :month) # => Range
|
38
|
+
```
|
39
|
+
|
40
|
+
*Edwin Vlieg*
|
41
|
+
|
42
|
+
## 0.3.2
|
43
|
+
|
44
|
+
* Add this_month?, this_quarter? and this_year? to check if a period is the current month, quarter or year
|
45
|
+
|
46
|
+
*Edwin Vlieg*
|
47
|
+
|
48
|
+
|
1
49
|
## 0.3.1
|
2
50
|
|
3
51
|
* Fix issue with `next` not returning a full year when leap years are in the range
|
data/Gemfile
CHANGED
@@ -5,9 +5,11 @@ source "https://rubygems.org"
|
|
5
5
|
# Specify your gem's dependencies in active_date_range.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem "rake", "~>
|
8
|
+
gem "rake", "~> 13.0"
|
9
9
|
gem "railties", "> 6.1"
|
10
10
|
gem "minitest", "~> 5.0"
|
11
11
|
gem "guard"
|
12
12
|
gem "guard-minitest"
|
13
13
|
gem "pry"
|
14
|
+
gem "benchmark-ips"
|
15
|
+
gem "memory_profiler"
|
data/Gemfile.lock
CHANGED
@@ -1,47 +1,70 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active_date_range (0.
|
4
|
+
active_date_range (0.4.0)
|
5
5
|
activesupport (> 6.1)
|
6
6
|
i18n
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actionpack (
|
12
|
-
actionview (=
|
13
|
-
activesupport (=
|
14
|
-
|
11
|
+
actionpack (8.0.3)
|
12
|
+
actionview (= 8.0.3)
|
13
|
+
activesupport (= 8.0.3)
|
14
|
+
nokogiri (>= 1.8.5)
|
15
|
+
rack (>= 2.2.4)
|
16
|
+
rack-session (>= 1.0.1)
|
15
17
|
rack-test (>= 0.6.3)
|
16
|
-
rails-dom-testing (~> 2.
|
17
|
-
rails-html-sanitizer (~> 1.
|
18
|
-
|
19
|
-
|
18
|
+
rails-dom-testing (~> 2.2)
|
19
|
+
rails-html-sanitizer (~> 1.6)
|
20
|
+
useragent (~> 0.16)
|
21
|
+
actionview (8.0.3)
|
22
|
+
activesupport (= 8.0.3)
|
20
23
|
builder (~> 3.1)
|
21
|
-
erubi (~> 1.
|
22
|
-
rails-dom-testing (~> 2.
|
23
|
-
rails-html-sanitizer (~> 1.
|
24
|
-
activemodel (
|
25
|
-
activesupport (=
|
26
|
-
activesupport (
|
27
|
-
|
24
|
+
erubi (~> 1.11)
|
25
|
+
rails-dom-testing (~> 2.2)
|
26
|
+
rails-html-sanitizer (~> 1.6)
|
27
|
+
activemodel (8.0.3)
|
28
|
+
activesupport (= 8.0.3)
|
29
|
+
activesupport (8.0.3)
|
30
|
+
base64
|
31
|
+
benchmark (>= 0.3)
|
32
|
+
bigdecimal
|
33
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
34
|
+
connection_pool (>= 2.2.5)
|
35
|
+
drb
|
28
36
|
i18n (>= 1.6, < 2)
|
37
|
+
logger (>= 1.4.2)
|
29
38
|
minitest (>= 5.1)
|
30
|
-
|
31
|
-
|
32
|
-
|
39
|
+
securerandom (>= 0.3)
|
40
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
41
|
+
uri (>= 0.13.1)
|
42
|
+
ast (2.4.3)
|
43
|
+
base64 (0.3.0)
|
44
|
+
benchmark (0.4.1)
|
45
|
+
benchmark-ips (2.14.0)
|
46
|
+
bigdecimal (3.3.0)
|
47
|
+
builder (3.3.0)
|
33
48
|
coderay (1.1.3)
|
34
|
-
concurrent-ruby (1.
|
49
|
+
concurrent-ruby (1.3.5)
|
50
|
+
connection_pool (2.5.4)
|
35
51
|
crass (1.0.6)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
52
|
+
date (3.4.1)
|
53
|
+
drb (2.2.3)
|
54
|
+
erb (5.0.3)
|
55
|
+
erubi (1.13.1)
|
56
|
+
ffi (1.17.2)
|
57
|
+
ffi (1.17.2-x86_64-linux-gnu)
|
58
|
+
formatador (1.2.1)
|
59
|
+
reline
|
60
|
+
guard (2.19.1)
|
40
61
|
formatador (>= 0.2.4)
|
41
62
|
listen (>= 2.7, < 4.0)
|
63
|
+
logger (~> 1.6)
|
42
64
|
lumberjack (>= 1.0.12, < 2.0)
|
43
65
|
nenv (~> 0.1)
|
44
66
|
notiffany (~> 0.0)
|
67
|
+
ostruct (~> 0.6)
|
45
68
|
pry (>= 0.13.0)
|
46
69
|
shellany (~> 0.0)
|
47
70
|
thor (>= 0.18.1)
|
@@ -49,92 +72,146 @@ GEM
|
|
49
72
|
guard-minitest (2.4.6)
|
50
73
|
guard-compat (~> 1.2)
|
51
74
|
minitest (>= 3.0)
|
52
|
-
i18n (1.
|
75
|
+
i18n (1.14.7)
|
53
76
|
concurrent-ruby (~> 1.0)
|
54
|
-
|
77
|
+
io-console (0.8.1)
|
78
|
+
irb (1.15.2)
|
79
|
+
pp (>= 0.6.0)
|
80
|
+
rdoc (>= 4.0.0)
|
81
|
+
reline (>= 0.4.2)
|
82
|
+
json (2.15.1)
|
83
|
+
language_server-protocol (3.17.0.5)
|
84
|
+
lint_roller (1.1.0)
|
85
|
+
listen (3.9.0)
|
55
86
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
56
87
|
rb-inotify (~> 0.9, >= 0.9.10)
|
57
|
-
|
88
|
+
logger (1.7.0)
|
89
|
+
loofah (2.24.1)
|
58
90
|
crass (~> 1.0.2)
|
59
|
-
nokogiri (>= 1.
|
60
|
-
lumberjack (1.2
|
61
|
-
|
62
|
-
|
91
|
+
nokogiri (>= 1.12.0)
|
92
|
+
lumberjack (1.4.2)
|
93
|
+
memory_profiler (1.1.0)
|
94
|
+
method_source (1.1.0)
|
95
|
+
mini_portile2 (2.8.9)
|
96
|
+
minitest (5.25.5)
|
63
97
|
nenv (0.3.0)
|
64
|
-
nokogiri (1.
|
98
|
+
nokogiri (1.18.10)
|
99
|
+
mini_portile2 (~> 2.8.2)
|
100
|
+
racc (~> 1.4)
|
101
|
+
nokogiri (1.18.10-x86_64-linux-gnu)
|
65
102
|
racc (~> 1.4)
|
66
103
|
notiffany (0.1.3)
|
67
104
|
nenv (~> 0.1)
|
68
105
|
shellany (~> 0.0)
|
69
|
-
|
70
|
-
|
106
|
+
ostruct (0.6.3)
|
107
|
+
parallel (1.27.0)
|
108
|
+
parser (3.3.9.0)
|
71
109
|
ast (~> 2.4.1)
|
72
|
-
|
110
|
+
racc
|
111
|
+
pp (0.6.3)
|
112
|
+
prettyprint
|
113
|
+
prettyprint (0.2.0)
|
114
|
+
prism (1.5.1)
|
115
|
+
pry (0.15.2)
|
73
116
|
coderay (~> 1.1)
|
74
117
|
method_source (~> 1.0)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
118
|
+
psych (5.2.6)
|
119
|
+
date
|
120
|
+
stringio
|
121
|
+
racc (1.8.1)
|
122
|
+
rack (3.2.2)
|
123
|
+
rack-session (2.1.1)
|
124
|
+
base64 (>= 0.1.0)
|
125
|
+
rack (>= 3.0.0)
|
126
|
+
rack-test (2.2.0)
|
127
|
+
rack (>= 1.3)
|
128
|
+
rackup (2.2.1)
|
129
|
+
rack (>= 3)
|
130
|
+
rails-dom-testing (2.3.0)
|
131
|
+
activesupport (>= 5.0.0)
|
132
|
+
minitest
|
81
133
|
nokogiri (>= 1.6)
|
82
|
-
rails-html-sanitizer (1.
|
83
|
-
loofah (~> 2.
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
134
|
+
rails-html-sanitizer (1.6.2)
|
135
|
+
loofah (~> 2.21)
|
136
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
137
|
+
railties (8.0.3)
|
138
|
+
actionpack (= 8.0.3)
|
139
|
+
activesupport (= 8.0.3)
|
140
|
+
irb (~> 1.13)
|
141
|
+
rackup (>= 1.0.0)
|
142
|
+
rake (>= 12.2)
|
143
|
+
thor (~> 1.0, >= 1.2.2)
|
144
|
+
tsort (>= 0.2)
|
145
|
+
zeitwerk (~> 2.6)
|
146
|
+
rainbow (3.1.1)
|
147
|
+
rake (13.3.0)
|
148
|
+
rb-fsevent (0.11.2)
|
149
|
+
rb-inotify (0.11.1)
|
95
150
|
ffi (~> 1.0)
|
96
|
-
|
97
|
-
|
98
|
-
|
151
|
+
rdoc (6.15.0)
|
152
|
+
erb
|
153
|
+
psych (>= 4.0.0)
|
154
|
+
tsort
|
155
|
+
regexp_parser (2.11.3)
|
156
|
+
reline (0.6.2)
|
157
|
+
io-console (~> 0.5)
|
158
|
+
rubocop (1.81.1)
|
159
|
+
json (~> 2.3)
|
160
|
+
language_server-protocol (~> 3.17.0.2)
|
161
|
+
lint_roller (~> 1.1.0)
|
99
162
|
parallel (~> 1.10)
|
100
|
-
parser (>= 3.
|
163
|
+
parser (>= 3.3.0.2)
|
101
164
|
rainbow (>= 2.2.2, < 4.0)
|
102
|
-
regexp_parser (>=
|
103
|
-
|
104
|
-
rubocop-ast (>= 1.9.1, < 2.0)
|
165
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
166
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
105
167
|
ruby-progressbar (~> 1.7)
|
106
|
-
unicode-display_width (>=
|
107
|
-
rubocop-ast (1.
|
108
|
-
parser (>= 3.
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
rubocop (>= 1.
|
113
|
-
|
114
|
-
|
168
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
169
|
+
rubocop-ast (1.47.1)
|
170
|
+
parser (>= 3.3.7.2)
|
171
|
+
prism (~> 1.4)
|
172
|
+
rubocop-packaging (0.6.0)
|
173
|
+
lint_roller (~> 1.1.0)
|
174
|
+
rubocop (>= 1.72.1, < 2.0)
|
175
|
+
rubocop-performance (1.26.0)
|
176
|
+
lint_roller (~> 1.1)
|
177
|
+
rubocop (>= 1.75.0, < 2.0)
|
178
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
179
|
+
rubocop-rails (2.33.4)
|
115
180
|
activesupport (>= 4.2.0)
|
181
|
+
lint_roller (~> 1.1)
|
116
182
|
rack (>= 1.1)
|
117
|
-
rubocop (>= 1.
|
118
|
-
|
183
|
+
rubocop (>= 1.75.0, < 2.0)
|
184
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
185
|
+
ruby-progressbar (1.13.0)
|
186
|
+
securerandom (0.4.1)
|
119
187
|
shellany (0.0.1)
|
120
|
-
|
121
|
-
|
188
|
+
stringio (3.1.7)
|
189
|
+
thor (1.4.0)
|
190
|
+
tsort (0.2.0)
|
191
|
+
tzinfo (2.0.6)
|
122
192
|
concurrent-ruby (~> 1.0)
|
123
|
-
unicode-display_width (2.
|
124
|
-
|
193
|
+
unicode-display_width (3.2.0)
|
194
|
+
unicode-emoji (~> 4.1)
|
195
|
+
unicode-emoji (4.1.0)
|
196
|
+
uri (1.0.4)
|
197
|
+
useragent (0.16.11)
|
198
|
+
zeitwerk (2.7.3)
|
125
199
|
|
126
200
|
PLATFORMS
|
201
|
+
ruby
|
127
202
|
x86_64-linux
|
128
203
|
|
129
204
|
DEPENDENCIES
|
130
205
|
active_date_range!
|
131
206
|
activemodel
|
207
|
+
benchmark-ips
|
132
208
|
guard
|
133
209
|
guard-minitest
|
210
|
+
memory_profiler
|
134
211
|
minitest (~> 5.0)
|
135
212
|
pry
|
136
213
|
railties (> 6.1)
|
137
|
-
rake (~>
|
214
|
+
rake (~> 13.0)
|
138
215
|
rubocop
|
139
216
|
rubocop-packaging
|
140
217
|
rubocop-performance
|
data/SECURITY.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Supported Versions
|
4
|
+
|
5
|
+
Use this section to tell people about which versions of your project are
|
6
|
+
currently being supported with security updates.
|
7
|
+
|
8
|
+
| Version | Supported |
|
9
|
+
| ------- | ------------------ |
|
10
|
+
| 0.4.x | :white_check_mark: |
|
11
|
+
| < 0.3.3 | :x: |
|
12
|
+
|
13
|
+
## Reporting a Vulnerability
|
14
|
+
|
15
|
+
Please refer to https://www.moneybird.nl/security/ for our Responsible Disclosure policy.
|
data/active_date_range.gemspec
CHANGED
@@ -11,7 +11,8 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = "DateRange for ActiveSupport"
|
12
12
|
spec.description = "ActiveDateRange provides a range of dates with a powerful API to manipulate and use date ranges in your software."
|
13
13
|
spec.homepage = "https://github.com/moneybird/active-date-range"
|
14
|
-
spec.
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
|
15
16
|
|
16
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
17
18
|
spec.metadata["source_code_uri"] = "https://github.com/moneybird/active-date-range"
|
@@ -26,12 +27,12 @@ Gem::Specification.new do |spec|
|
|
26
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
28
|
spec.require_paths = ["lib"]
|
28
29
|
|
29
|
-
spec.
|
30
|
-
spec.
|
30
|
+
spec.add_runtime_dependency "activesupport", "~> 6.1"
|
31
|
+
spec.add_runtime_dependency "i18n", "~> 1.6"
|
31
32
|
|
32
|
-
spec.add_development_dependency "rubocop"
|
33
|
-
spec.add_development_dependency "rubocop-packaging"
|
34
|
-
spec.add_development_dependency "rubocop-performance"
|
35
|
-
spec.add_development_dependency "rubocop-rails"
|
36
|
-
spec.add_development_dependency "activemodel"
|
33
|
+
spec.add_development_dependency "rubocop", "~> 1.18"
|
34
|
+
spec.add_development_dependency "rubocop-packaging", "~> 0.6"
|
35
|
+
spec.add_development_dependency "rubocop-performance", "~> 1.26"
|
36
|
+
spec.add_development_dependency "rubocop-rails", "~> 2.33"
|
37
|
+
spec.add_development_dependency "activemodel", "~> 6.1"
|
37
38
|
end
|
@@ -31,6 +31,7 @@ module ActiveDateRange
|
|
31
31
|
# - A begin and end date: <tt>YYYYMMDD..YYYYMMDD</tt>
|
32
32
|
# - A begin and end month: <tt>YYYYMM..YYYYMM</tt>
|
33
33
|
def self.parse(input)
|
34
|
+
return nil if input.nil?
|
34
35
|
return DateRange.new(input) if input.kind_of?(Range)
|
35
36
|
return SHORTHANDS[input.to_sym].call if SHORTHANDS.key?(input.to_sym)
|
36
37
|
|
@@ -58,6 +59,11 @@ module ActiveDateRange
|
|
58
59
|
raise InvalidDateRangeFormat
|
59
60
|
end
|
60
61
|
|
62
|
+
def self.from_date_and_duration(date, duration)
|
63
|
+
duration = 1.send(duration) if duration.kind_of?(Symbol)
|
64
|
+
new(date, date + duration - 1.day)
|
65
|
+
end
|
66
|
+
|
61
67
|
private_class_method :parse_date
|
62
68
|
|
63
69
|
# Initializes a new DateRange. Accepts both a begin and end date or a range of dates.
|
@@ -128,84 +134,120 @@ module ActiveDateRange
|
|
128
134
|
|
129
135
|
# Returns true when begin of the range is at the beginning of the month
|
130
136
|
def begin_at_beginning_of_month?
|
131
|
-
|
137
|
+
memoize(:@begin_at_beginning_of_month) do
|
138
|
+
self.begin.present? && self.begin.day == 1
|
139
|
+
end
|
132
140
|
end
|
133
141
|
|
134
142
|
# Returns true when begin of the range is at the beginning of the quarter
|
135
143
|
def begin_at_beginning_of_quarter?
|
136
|
-
|
144
|
+
memoize(:@begin_at_beginning_of_quarter) do
|
145
|
+
self.begin.present? && begin_at_beginning_of_month? && [1, 4, 7, 10].include?(self.begin.month)
|
146
|
+
end
|
137
147
|
end
|
138
148
|
|
139
149
|
# Returns true when begin of the range is at the beginning of the year
|
140
150
|
def begin_at_beginning_of_year?
|
141
|
-
|
151
|
+
memoize(:@begin_at_beginning_of_year) do
|
152
|
+
self.begin.present? && begin_at_beginning_of_month? && self.begin.month == 1
|
153
|
+
end
|
142
154
|
end
|
143
155
|
|
144
156
|
# Returns true when begin of the range is at the beginning of the week
|
145
157
|
def begin_at_beginning_of_week?
|
146
|
-
|
158
|
+
memoize(:@begin_at_beginning_of_week) do
|
159
|
+
self.begin.present? && self.begin == self.begin.at_beginning_of_week
|
160
|
+
end
|
147
161
|
end
|
148
162
|
|
149
163
|
# Returns true when the range is exactly one month long
|
150
164
|
def one_month?
|
151
|
-
(
|
152
|
-
|
153
|
-
|
165
|
+
memoize(:@one_month) do
|
166
|
+
(28..31).cover?(days) &&
|
167
|
+
begin_at_beginning_of_month? &&
|
168
|
+
self.end == self.begin.at_end_of_month
|
169
|
+
end
|
154
170
|
end
|
155
171
|
|
156
172
|
# Returns true when the range is exactly one quarter long
|
157
173
|
def one_quarter?
|
158
|
-
(
|
159
|
-
|
160
|
-
|
174
|
+
memoize(:@one_quarter) do
|
175
|
+
(90..92).cover?(days) &&
|
176
|
+
begin_at_beginning_of_quarter? &&
|
177
|
+
self.end == self.begin.at_end_of_quarter
|
178
|
+
end
|
161
179
|
end
|
162
180
|
|
163
181
|
# Returns true when the range is exactly one year long
|
164
182
|
def one_year?
|
165
|
-
(
|
166
|
-
|
167
|
-
|
183
|
+
memoize(:@one_year) do
|
184
|
+
(365..366).cover?(days) &&
|
185
|
+
begin_at_beginning_of_year? &&
|
186
|
+
self.end == self.begin.at_end_of_year
|
187
|
+
end
|
168
188
|
end
|
169
189
|
|
170
190
|
def one_week?
|
171
|
-
|
172
|
-
|
173
|
-
|
191
|
+
memoize(:@one_week) do
|
192
|
+
days == 7 &&
|
193
|
+
begin_at_beginning_of_week? &&
|
194
|
+
self.end == self.begin.at_end_of_week
|
195
|
+
end
|
174
196
|
end
|
175
197
|
|
176
198
|
# Returns true when the range is exactly one or more months long
|
177
199
|
def full_month?
|
178
|
-
|
200
|
+
memoize(:@full_month) do
|
201
|
+
begin_at_beginning_of_month? && self.end.present? && self.end == self.end.at_end_of_month
|
202
|
+
end
|
179
203
|
end
|
180
204
|
|
181
205
|
alias :full_months? :full_month?
|
182
206
|
|
183
207
|
# Returns true when the range is exactly one or more quarters long
|
184
208
|
def full_quarter?
|
185
|
-
|
209
|
+
memoize(:@full_quarter) do
|
210
|
+
begin_at_beginning_of_quarter? && self.end.present? && self.end == self.end.at_end_of_quarter
|
211
|
+
end
|
186
212
|
end
|
187
213
|
|
188
214
|
alias :full_quarters? :full_quarter?
|
189
215
|
|
190
216
|
# Returns true when the range is exactly one or more years long
|
191
217
|
def full_year?
|
192
|
-
|
218
|
+
memoize(:@full_year) do
|
219
|
+
begin_at_beginning_of_year? && self.end.present? && self.end == self.end.at_end_of_year
|
220
|
+
end
|
193
221
|
end
|
194
222
|
|
195
223
|
alias :full_years? :full_year?
|
196
224
|
|
197
225
|
# Returns true when the range is exactly one or more weeks long
|
198
226
|
def full_week?
|
199
|
-
|
227
|
+
memoize(:@full_week) do
|
228
|
+
begin_at_beginning_of_week? && self.end.present? && self.end == self.end.at_end_of_week
|
229
|
+
end
|
200
230
|
end
|
201
231
|
|
202
232
|
alias :full_weeks? :full_week?
|
203
233
|
|
204
234
|
# Returns true when begin and end are in the same year
|
205
235
|
def same_year?
|
206
|
-
|
236
|
+
memoize(:@same_year) do
|
237
|
+
!boundless? && self.begin.year == self.end.year
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def current?
|
242
|
+
memoize(:@current) do
|
243
|
+
cover?(Time.zone.today)
|
244
|
+
end
|
207
245
|
end
|
208
246
|
|
247
|
+
alias :this_month? :current?
|
248
|
+
alias :this_quarter? :current?
|
249
|
+
alias :this_year? :current?
|
250
|
+
|
209
251
|
# Returns true when the date range is before the given date. Accepts both a <tt>Date</tt>
|
210
252
|
# and <tt>DateRange</tt> as input.
|
211
253
|
def before?(date)
|
@@ -227,14 +269,16 @@ module ActiveDateRange
|
|
227
269
|
# DateRange.this_quarter.granularity # => :quarter
|
228
270
|
# DateRange.this_year.granularity # => :year
|
229
271
|
def granularity
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
272
|
+
memoize(:@granularity) do
|
273
|
+
if one_year?
|
274
|
+
:year
|
275
|
+
elsif one_quarter?
|
276
|
+
:quarter
|
277
|
+
elsif one_month?
|
278
|
+
:month
|
279
|
+
elsif one_week?
|
280
|
+
:week
|
281
|
+
end
|
238
282
|
end
|
239
283
|
end
|
240
284
|
|
@@ -242,11 +286,13 @@ module ActiveDateRange
|
|
242
286
|
# a range of 2021-01-01..2021-12-31 will return `this_year` when the current date
|
243
287
|
# is somewhere in 2021.
|
244
288
|
def relative_param
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
289
|
+
memoize(:@relative_param) do
|
290
|
+
SHORTHANDS
|
291
|
+
.select { |key, _| key.end_with?(granularity.to_s) }
|
292
|
+
.find { |key, range| self == range.call }
|
293
|
+
&.first
|
294
|
+
&.to_s
|
295
|
+
end
|
250
296
|
end
|
251
297
|
|
252
298
|
# Returns a param representation of the date range. When `relative` is true,
|
@@ -353,6 +399,18 @@ module ActiveDateRange
|
|
353
399
|
cover?(other)
|
354
400
|
end
|
355
401
|
|
402
|
+
def stretch_to_end_of_month
|
403
|
+
return self if self.end.present? && self.end == self.end.at_end_of_month
|
404
|
+
|
405
|
+
side_to_stretch = boundless? ? self.begin : self.end
|
406
|
+
|
407
|
+
DateRange.new(self.begin, side_to_stretch.at_end_of_month)
|
408
|
+
end
|
409
|
+
|
410
|
+
def exceeds?(limit)
|
411
|
+
self.days > limit.in_days.ceil
|
412
|
+
end
|
413
|
+
|
356
414
|
private
|
357
415
|
def grouped_collection(granularity, amount: 1)
|
358
416
|
raise UnknownGranularity, "Unknown granularity #{granularity}. Valid are: month, quarter and year" unless %w[month quarter year].include?(granularity.to_s)
|
@@ -364,5 +422,13 @@ module ActiveDateRange
|
|
364
422
|
.slice_before { |_, index| index % amount == 0 }
|
365
423
|
.map { |group| group.map(&:first).inject(:+) }
|
366
424
|
end
|
425
|
+
|
426
|
+
def memoize(name)
|
427
|
+
if instance_variable_defined?(name)
|
428
|
+
instance_variable_get(name)
|
429
|
+
else
|
430
|
+
instance_variable_set(name, yield)
|
431
|
+
end
|
432
|
+
end
|
367
433
|
end
|
368
434
|
end
|
metadata
CHANGED
@@ -1,113 +1,112 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_date_range
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edwin Vlieg
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activesupport
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
|
-
- - "
|
16
|
+
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
18
|
version: '6.1'
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
|
-
- - "
|
23
|
+
- - "~>"
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: '6.1'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: i18n
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
|
-
- - "
|
30
|
+
- - "~>"
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
32
|
+
version: '1.6'
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
|
-
- - "
|
37
|
+
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
39
|
+
version: '1.6'
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
41
|
name: rubocop
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
|
-
- - "
|
44
|
+
- - "~>"
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
46
|
+
version: '1.18'
|
48
47
|
type: :development
|
49
48
|
prerelease: false
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
|
-
- - "
|
51
|
+
- - "~>"
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
53
|
+
version: '1.18'
|
55
54
|
- !ruby/object:Gem::Dependency
|
56
55
|
name: rubocop-packaging
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
58
57
|
requirements:
|
59
|
-
- - "
|
58
|
+
- - "~>"
|
60
59
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
60
|
+
version: '0.6'
|
62
61
|
type: :development
|
63
62
|
prerelease: false
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
65
64
|
requirements:
|
66
|
-
- - "
|
65
|
+
- - "~>"
|
67
66
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
67
|
+
version: '0.6'
|
69
68
|
- !ruby/object:Gem::Dependency
|
70
69
|
name: rubocop-performance
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
72
71
|
requirements:
|
73
|
-
- - "
|
72
|
+
- - "~>"
|
74
73
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
74
|
+
version: '1.26'
|
76
75
|
type: :development
|
77
76
|
prerelease: false
|
78
77
|
version_requirements: !ruby/object:Gem::Requirement
|
79
78
|
requirements:
|
80
|
-
- - "
|
79
|
+
- - "~>"
|
81
80
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
81
|
+
version: '1.26'
|
83
82
|
- !ruby/object:Gem::Dependency
|
84
83
|
name: rubocop-rails
|
85
84
|
requirement: !ruby/object:Gem::Requirement
|
86
85
|
requirements:
|
87
|
-
- - "
|
86
|
+
- - "~>"
|
88
87
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
88
|
+
version: '2.33'
|
90
89
|
type: :development
|
91
90
|
prerelease: false
|
92
91
|
version_requirements: !ruby/object:Gem::Requirement
|
93
92
|
requirements:
|
94
|
-
- - "
|
93
|
+
- - "~>"
|
95
94
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
95
|
+
version: '2.33'
|
97
96
|
- !ruby/object:Gem::Dependency
|
98
97
|
name: activemodel
|
99
98
|
requirement: !ruby/object:Gem::Requirement
|
100
99
|
requirements:
|
101
|
-
- - "
|
100
|
+
- - "~>"
|
102
101
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
102
|
+
version: '6.1'
|
104
103
|
type: :development
|
105
104
|
prerelease: false
|
106
105
|
version_requirements: !ruby/object:Gem::Requirement
|
107
106
|
requirements:
|
108
|
-
- - "
|
107
|
+
- - "~>"
|
109
108
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
109
|
+
version: '6.1'
|
111
110
|
description: ActiveDateRange provides a range of dates with a powerful API to manipulate
|
112
111
|
and use date ranges in your software.
|
113
112
|
email:
|
@@ -116,10 +115,11 @@ executables: []
|
|
116
115
|
extensions: []
|
117
116
|
extra_rdoc_files: []
|
118
117
|
files:
|
118
|
+
- ".github/workflows/codeql.yml"
|
119
119
|
- ".github/workflows/ruby.yml"
|
120
120
|
- ".gitignore"
|
121
121
|
- ".rubocop.yml"
|
122
|
-
- ".
|
122
|
+
- ".ruby-version"
|
123
123
|
- CHANGELOG.md
|
124
124
|
- Gemfile
|
125
125
|
- Gemfile.lock
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- LICENSE
|
128
128
|
- README.md
|
129
129
|
- Rakefile
|
130
|
+
- SECURITY.md
|
130
131
|
- active_date_range.gemspec
|
131
132
|
- bin/console
|
132
133
|
- bin/setup
|
@@ -140,12 +141,12 @@ files:
|
|
140
141
|
- lib/active_date_range/locale/en.yml
|
141
142
|
- lib/active_date_range/version.rb
|
142
143
|
homepage: https://github.com/moneybird/active-date-range
|
143
|
-
licenses:
|
144
|
+
licenses:
|
145
|
+
- MIT
|
144
146
|
metadata:
|
145
147
|
homepage_uri: https://github.com/moneybird/active-date-range
|
146
148
|
source_code_uri: https://github.com/moneybird/active-date-range
|
147
149
|
changelog_uri: https://github.com/moneybird/active-date-range/blob/main/CHANGELOG.md
|
148
|
-
post_install_message:
|
149
150
|
rdoc_options: []
|
150
151
|
require_paths:
|
151
152
|
- lib
|
@@ -153,15 +154,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
153
154
|
requirements:
|
154
155
|
- - ">="
|
155
156
|
- !ruby/object:Gem::Version
|
156
|
-
version: 2.
|
157
|
+
version: 3.2.0
|
157
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
159
|
requirements:
|
159
160
|
- - ">="
|
160
161
|
- !ruby/object:Gem::Version
|
161
162
|
version: '0'
|
162
163
|
requirements: []
|
163
|
-
rubygems_version: 3.
|
164
|
-
signing_key:
|
164
|
+
rubygems_version: 3.6.9
|
165
165
|
specification_version: 4
|
166
166
|
summary: DateRange for ActiveSupport
|
167
167
|
test_files: []
|