active_date_range 0.3.2 → 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 +8 -6
- data/.rubocop.yml +1 -1
- data/.ruby-version +2 -0
- data/CHANGELOG.md +41 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +138 -77
- data/SECURITY.md +15 -0
- data/active_date_range.gemspec +9 -8
- data/lib/active_date_range/date_range.rb +24 -17
- 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,10 +20,10 @@ 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
28
|
uses: ruby/setup-ruby@v1
|
27
29
|
with:
|
@@ -34,13 +36,13 @@ jobs:
|
|
34
36
|
runs-on: ubuntu-latest
|
35
37
|
|
36
38
|
steps:
|
37
|
-
- uses: actions/checkout@
|
38
|
-
- name: Set up Ruby
|
39
|
+
- uses: actions/checkout@v5
|
40
|
+
- name: Set up Ruby
|
39
41
|
uses: ruby/setup-ruby@v1
|
40
42
|
with:
|
41
|
-
ruby-version:
|
43
|
+
ruby-version: 3.4
|
42
44
|
- name: Cache gems
|
43
|
-
uses: actions/cache@
|
45
|
+
uses: actions/cache@v4
|
44
46
|
with:
|
45
47
|
path: vendor/bundle
|
46
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,44 @@
|
|
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
|
+
|
1
42
|
## 0.3.2
|
2
43
|
|
3
44
|
* Add this_month?, this_quarter? and this_year? to check if a period is the current month, quarter or year
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,49 +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
|
-
|
33
|
-
|
34
|
-
|
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)
|
35
48
|
coderay (1.1.3)
|
36
|
-
concurrent-ruby (1.
|
49
|
+
concurrent-ruby (1.3.5)
|
50
|
+
connection_pool (2.5.4)
|
37
51
|
crass (1.0.6)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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)
|
42
61
|
formatador (>= 0.2.4)
|
43
62
|
listen (>= 2.7, < 4.0)
|
63
|
+
logger (~> 1.6)
|
44
64
|
lumberjack (>= 1.0.12, < 2.0)
|
45
65
|
nenv (~> 0.1)
|
46
66
|
notiffany (~> 0.0)
|
67
|
+
ostruct (~> 0.6)
|
47
68
|
pry (>= 0.13.0)
|
48
69
|
shellany (~> 0.0)
|
49
70
|
thor (>= 0.18.1)
|
@@ -51,90 +72,130 @@ GEM
|
|
51
72
|
guard-minitest (2.4.6)
|
52
73
|
guard-compat (~> 1.2)
|
53
74
|
minitest (>= 3.0)
|
54
|
-
i18n (1.14.
|
75
|
+
i18n (1.14.7)
|
55
76
|
concurrent-ruby (~> 1.0)
|
56
|
-
|
57
|
-
|
58
|
-
|
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)
|
59
86
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
60
87
|
rb-inotify (~> 0.9, >= 0.9.10)
|
61
|
-
|
88
|
+
logger (1.7.0)
|
89
|
+
loofah (2.24.1)
|
62
90
|
crass (~> 1.0.2)
|
63
91
|
nokogiri (>= 1.12.0)
|
64
|
-
lumberjack (1.2
|
65
|
-
memory_profiler (1.0
|
66
|
-
method_source (1.
|
67
|
-
mini_portile2 (2.8.
|
68
|
-
minitest (5.
|
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)
|
69
97
|
nenv (0.3.0)
|
70
|
-
nokogiri (1.
|
98
|
+
nokogiri (1.18.10)
|
71
99
|
mini_portile2 (~> 2.8.2)
|
72
100
|
racc (~> 1.4)
|
101
|
+
nokogiri (1.18.10-x86_64-linux-gnu)
|
102
|
+
racc (~> 1.4)
|
73
103
|
notiffany (0.1.3)
|
74
104
|
nenv (~> 0.1)
|
75
105
|
shellany (~> 0.0)
|
76
|
-
|
77
|
-
|
106
|
+
ostruct (0.6.3)
|
107
|
+
parallel (1.27.0)
|
108
|
+
parser (3.3.9.0)
|
78
109
|
ast (~> 2.4.1)
|
79
110
|
racc
|
80
|
-
|
111
|
+
pp (0.6.3)
|
112
|
+
prettyprint
|
113
|
+
prettyprint (0.2.0)
|
114
|
+
prism (1.5.1)
|
115
|
+
pry (0.15.2)
|
81
116
|
coderay (~> 1.1)
|
82
117
|
method_source (~> 1.0)
|
83
|
-
|
84
|
-
|
85
|
-
|
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)
|
86
127
|
rack (>= 1.3)
|
87
|
-
|
128
|
+
rackup (2.2.1)
|
129
|
+
rack (>= 3)
|
130
|
+
rails-dom-testing (2.3.0)
|
88
131
|
activesupport (>= 5.0.0)
|
89
132
|
minitest
|
90
133
|
nokogiri (>= 1.6)
|
91
|
-
rails-html-sanitizer (1.6.
|
134
|
+
rails-html-sanitizer (1.6.2)
|
92
135
|
loofah (~> 2.21)
|
93
|
-
nokogiri (
|
94
|
-
railties (
|
95
|
-
actionpack (=
|
96
|
-
activesupport (=
|
97
|
-
|
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)
|
98
142
|
rake (>= 12.2)
|
99
|
-
thor (~> 1.0)
|
100
|
-
|
143
|
+
thor (~> 1.0, >= 1.2.2)
|
144
|
+
tsort (>= 0.2)
|
145
|
+
zeitwerk (~> 2.6)
|
101
146
|
rainbow (3.1.1)
|
102
|
-
rake (
|
147
|
+
rake (13.3.0)
|
103
148
|
rb-fsevent (0.11.2)
|
104
|
-
rb-inotify (0.
|
149
|
+
rb-inotify (0.11.1)
|
105
150
|
ffi (~> 1.0)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
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)
|
110
159
|
json (~> 2.3)
|
111
|
-
language_server-protocol (
|
160
|
+
language_server-protocol (~> 3.17.0.2)
|
161
|
+
lint_roller (~> 1.1.0)
|
112
162
|
parallel (~> 1.10)
|
113
|
-
parser (>= 3.
|
163
|
+
parser (>= 3.3.0.2)
|
114
164
|
rainbow (>= 2.2.2, < 4.0)
|
115
|
-
regexp_parser (>=
|
116
|
-
|
117
|
-
rubocop-ast (>= 1.28.1, < 2.0)
|
165
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
166
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
118
167
|
ruby-progressbar (~> 1.7)
|
119
|
-
unicode-display_width (>= 2.4.0, <
|
120
|
-
rubocop-ast (1.
|
121
|
-
parser (>= 3.
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
rubocop (>= 1.
|
126
|
-
|
127
|
-
|
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)
|
128
180
|
activesupport (>= 4.2.0)
|
181
|
+
lint_roller (~> 1.1)
|
129
182
|
rack (>= 1.1)
|
130
|
-
rubocop (>= 1.
|
183
|
+
rubocop (>= 1.75.0, < 2.0)
|
184
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
131
185
|
ruby-progressbar (1.13.0)
|
186
|
+
securerandom (0.4.1)
|
132
187
|
shellany (0.0.1)
|
133
|
-
|
188
|
+
stringio (3.1.7)
|
189
|
+
thor (1.4.0)
|
190
|
+
tsort (0.2.0)
|
134
191
|
tzinfo (2.0.6)
|
135
192
|
concurrent-ruby (~> 1.0)
|
136
|
-
unicode-display_width (2.
|
137
|
-
|
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)
|
138
199
|
|
139
200
|
PLATFORMS
|
140
201
|
ruby
|
@@ -150,7 +211,7 @@ DEPENDENCIES
|
|
150
211
|
minitest (~> 5.0)
|
151
212
|
pry
|
152
213
|
railties (> 6.1)
|
153
|
-
rake (~>
|
214
|
+
rake (~> 13.0)
|
154
215
|
rubocop
|
155
216
|
rubocop-packaging
|
156
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.
|
@@ -232,26 +238,15 @@ module ActiveDateRange
|
|
232
238
|
end
|
233
239
|
end
|
234
240
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
self == DateRange.this_month
|
241
|
+
def current?
|
242
|
+
memoize(:@current) do
|
243
|
+
cover?(Time.zone.today)
|
239
244
|
end
|
240
245
|
end
|
241
246
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
self == DateRange.this_quarter
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
# Return true when the range is equal to the current year
|
250
|
-
def this_year?
|
251
|
-
memoize(:@this_year) do
|
252
|
-
self == DateRange.this_year
|
253
|
-
end
|
254
|
-
end
|
247
|
+
alias :this_month? :current?
|
248
|
+
alias :this_quarter? :current?
|
249
|
+
alias :this_year? :current?
|
255
250
|
|
256
251
|
# Returns true when the date range is before the given date. Accepts both a <tt>Date</tt>
|
257
252
|
# and <tt>DateRange</tt> as input.
|
@@ -404,6 +399,18 @@ module ActiveDateRange
|
|
404
399
|
cover?(other)
|
405
400
|
end
|
406
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
|
+
|
407
414
|
private
|
408
415
|
def grouped_collection(granularity, amount: 1)
|
409
416
|
raise UnknownGranularity, "Unknown granularity #{granularity}. Valid are: month, quarter and year" unless %w[month quarter year].include?(granularity.to_s)
|
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: []
|