active_record_date_range_scopes 0.1.2 → 1.0.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/Changelog.md +4 -1
- data/Readme.md +6 -1
- data/active_record_date_range_scopes.gemspec +8 -5
- data/lib/active_record/date_range_scopes/version.rb +1 -1
- data/lib/active_record/date_range_scopes.rb +9 -2
- metadata +61 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7071733aa0bb2ee4337f6ce02ebded6a6534bdcf9c460c1d68d9fe0dd86ce3b
|
4
|
+
data.tar.gz: e407c7859cb2a365e7e725ff605465e1e020b240b64fe118a9bf17cbaad72742
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a1e7353173d9013d63e8585c7e7f4eaf7f8abc7c4086b143d727eab7068af8e94324ad49dc98cb329e5a02a63e005bedaffd1d370010463bfe075cf4094ca8f
|
7
|
+
data.tar.gz: 6efeda7d75b167b93ce0cc413a4e4a8367a1b04a806c8284c3f0fe33a6c9ea072eeb871512a11df1110b9f07acd88af9d4a14720893b571c9c6d8630407cfd30
|
data/.gitignore
CHANGED
data/Changelog.md
CHANGED
@@ -3,7 +3,10 @@
|
|
3
3
|
This project follows [semver 2.0.0](http://semver.org/spec/v2.0.0.html) and the
|
4
4
|
recommendations of [keepachangelog.com](http://keepachangelog.com/).
|
5
5
|
|
6
|
-
## (
|
6
|
+
## 1.0.0 (2023-02-16)
|
7
|
+
|
8
|
+
Added:
|
9
|
+
- Add {name}_on scope
|
7
10
|
|
8
11
|
## 0.1.2 (2020-01-31)
|
9
12
|
|
data/Readme.md
CHANGED
@@ -69,7 +69,12 @@ class Author < ActiveRecord::Base
|
|
69
69
|
)
|
70
70
|
}
|
71
71
|
scope :with_any_books_created_before, ->(date_or_time) {
|
72
|
-
|
72
|
+
next unless date_or_time
|
73
|
+
|
74
|
+
joins(:books).
|
75
|
+
where(
|
76
|
+
Book.arel_table[:created_at].lteq( time_or_end_of_day(date_or_time) )
|
77
|
+
)
|
73
78
|
}
|
74
79
|
end
|
75
80
|
```
|
@@ -25,10 +25,13 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
|
28
|
-
spec.add_dependency "activesupport"
|
29
|
-
spec.add_dependency "activerecord"
|
28
|
+
spec.add_dependency "activesupport"
|
29
|
+
spec.add_dependency "activerecord"
|
30
30
|
|
31
|
-
spec.add_development_dependency "bundler"
|
32
|
-
spec.add_development_dependency "rake"
|
33
|
-
spec.add_development_dependency "
|
31
|
+
spec.add_development_dependency "bundler"
|
32
|
+
spec.add_development_dependency "rake"
|
33
|
+
spec.add_development_dependency "rails"
|
34
|
+
spec.add_development_dependency "rspec"
|
35
|
+
spec.add_development_dependency "rspec-rails"
|
36
|
+
spec.add_development_dependency "sqlite3"
|
34
37
|
end
|
@@ -68,7 +68,7 @@ module DateRangeScopes
|
|
68
68
|
arel_attr.().gteq( time_or_beginning_of_day(date_or_time) )
|
69
69
|
)
|
70
70
|
}
|
71
|
-
scope :"#{name}_before",
|
71
|
+
scope :"#{name}_before", ->(date_or_time) {
|
72
72
|
next unless date_or_time
|
73
73
|
|
74
74
|
instance_eval(&relation).
|
@@ -76,6 +76,13 @@ module DateRangeScopes
|
|
76
76
|
arel_attr.().lteq( time_or_end_of_day(date_or_time) )
|
77
77
|
)
|
78
78
|
}
|
79
|
+
|
80
|
+
scope :"#{name}_on", ->(date_or_time) {
|
81
|
+
public_send(:"#{name}_between",
|
82
|
+
date_or_time.in_time_zone.beginning_of_day,
|
83
|
+
date_or_time.in_time_zone.end_of_day
|
84
|
+
)
|
85
|
+
}
|
79
86
|
end
|
80
87
|
|
81
88
|
def time_or_end_of_day(date_or_time)
|
@@ -144,7 +151,7 @@ module DateRangeScopes
|
|
144
151
|
target_model.public_send(:"#{name_on_target}_after", date_or_time)
|
145
152
|
)
|
146
153
|
})
|
147
|
-
scope(:"#{local_name}_before",
|
154
|
+
scope(:"#{local_name}_before", ->(date_or_time) {
|
148
155
|
next unless date_or_time
|
149
156
|
|
150
157
|
instance_eval(&relation).
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_date_range_scopes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Rick
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,70 +16,112 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
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: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
75
|
+
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - "
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rspec
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- - "
|
87
|
+
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
89
|
+
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- - "
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec-rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sqlite3
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
81
123
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
124
|
+
version: '0'
|
83
125
|
description: Easily create ActiveRecord date range scopes
|
84
126
|
email:
|
85
127
|
- tyler@tylerrick.com
|
@@ -122,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
164
|
- !ruby/object:Gem::Version
|
123
165
|
version: '0'
|
124
166
|
requirements: []
|
125
|
-
rubygems_version: 3.
|
167
|
+
rubygems_version: 3.3.7
|
126
168
|
signing_key:
|
127
169
|
specification_version: 4
|
128
170
|
summary: Easily create ActiveRecord date range scopes
|