by_star 2.2.0 → 4.0.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.
Files changed (66) hide show
  1. checksums.yaml +5 -13
  2. data/.github/workflows/mysql.yml +92 -0
  3. data/.github/workflows/postgresql.yml +99 -0
  4. data/.gitignore +6 -5
  5. data/.travis.yml +92 -35
  6. data/CHANGELOG.md +59 -29
  7. data/Gemfile +18 -25
  8. data/MIT-LICENSE +20 -20
  9. data/README.md +616 -523
  10. data/Rakefile +18 -18
  11. data/UPGRADING +4 -12
  12. data/by_star.gemspec +34 -32
  13. data/cleaner.rb +24 -24
  14. data/lib/by_star/base.rb +69 -68
  15. data/lib/by_star/between.rb +185 -120
  16. data/lib/by_star/directional.rb +35 -21
  17. data/lib/by_star/kernel/date.rb +41 -0
  18. data/lib/by_star/kernel/in_time_zone.rb +20 -0
  19. data/lib/by_star/{kernel.rb → kernel/time.rb} +41 -41
  20. data/lib/by_star/normalization.rb +156 -118
  21. data/lib/by_star/orm/active_record/by_star.rb +75 -59
  22. data/lib/by_star/orm/mongoid/by_star.rb +90 -63
  23. data/lib/by_star/orm/mongoid/reorder.rb +23 -0
  24. data/lib/by_star/version.rb +3 -3
  25. data/lib/by_star.rb +18 -15
  26. data/spec/database.yml +15 -15
  27. data/spec/fixtures/active_record/models.rb +12 -10
  28. data/spec/fixtures/active_record/schema.rb +19 -19
  29. data/spec/fixtures/mongoid/models.rb +31 -29
  30. data/spec/fixtures/shared/seeds.rb +36 -26
  31. data/spec/gemfiles/Gemfile.rails +5 -0
  32. data/spec/gemfiles/Gemfile.rails32 +7 -0
  33. data/spec/gemfiles/Gemfile.rails40 +7 -0
  34. data/spec/gemfiles/Gemfile.rails41 +7 -0
  35. data/spec/gemfiles/Gemfile.rails42 +7 -0
  36. data/spec/gemfiles/Gemfile.rails50 +7 -0
  37. data/spec/gemfiles/Gemfile.rails51 +7 -0
  38. data/spec/gemfiles/Gemfile.rails52 +7 -0
  39. data/spec/gemfiles/Gemfile.rails60 +7 -0
  40. data/spec/gemfiles/Gemfile.rails61 +7 -0
  41. data/spec/integration/active_record/active_record_spec.rb +41 -53
  42. data/spec/integration/mongoid/mongoid_spec.rb +39 -46
  43. data/spec/integration/shared/at_time.rb +53 -0
  44. data/spec/integration/shared/between_dates.rb +99 -0
  45. data/spec/integration/shared/between_times.rb +99 -0
  46. data/spec/integration/shared/by_calendar_month.rb +55 -55
  47. data/spec/integration/shared/by_cweek.rb +54 -0
  48. data/spec/integration/shared/by_day.rb +120 -108
  49. data/spec/integration/shared/by_direction.rb +126 -114
  50. data/spec/integration/shared/by_fortnight.rb +48 -48
  51. data/spec/integration/shared/by_month.rb +50 -50
  52. data/spec/integration/shared/by_quarter.rb +49 -49
  53. data/spec/integration/shared/by_week.rb +54 -54
  54. data/spec/integration/shared/by_weekend.rb +49 -49
  55. data/spec/integration/shared/by_year.rb +48 -48
  56. data/spec/integration/shared/index_scope_parameter.rb +111 -0
  57. data/spec/integration/shared/offset_parameter.rb +32 -31
  58. data/spec/integration/shared/order_parameter.rb +36 -0
  59. data/spec/integration/shared/relative.rb +174 -174
  60. data/spec/spec_helper.rb +33 -29
  61. data/spec/unit/kernel_date_spec.rb +113 -0
  62. data/spec/unit/kernel_time_spec.rb +57 -57
  63. data/spec/unit/normalization_spec.rb +384 -255
  64. data/tmp/.gitignore +1 -1
  65. metadata +82 -68
  66. data/spec/integration/shared/scope_parameter.rb +0 -42
metadata CHANGED
@@ -1,168 +1,168 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: by_star
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg
8
8
  - Johnny Shields
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-01 00:00:00.000000000 Z
12
+ date: 2022-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ! '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '0'
20
+ version: 3.2.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ! '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '0'
27
+ version: 3.2.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: chronic
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ! '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ! '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ! '>='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: 1.0.0
48
+ version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ! '>='
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 1.0.0
55
+ version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: sqlite3
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ! '>='
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ! '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: activerecord
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ! '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ! '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: mongoid
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ! '>='
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ! '>='
95
+ - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: pg
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ! '>='
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ! '>='
109
+ - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: mysql2
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ! '>='
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ! '>='
123
+ - - ">="
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: rspec-rails
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - ~>
130
+ - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: '2.14'
132
+ version: '3.1'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - ~>
137
+ - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: '2.14'
139
+ version: '3.1'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: timecop
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
- - - ~>
144
+ - - "~>"
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0.3'
147
147
  type: :development
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
- - - ~>
151
+ - - "~>"
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0.3'
154
154
  - !ruby/object:Gem::Dependency
155
155
  name: pry
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - ! '>='
158
+ - - ">="
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  type: :development
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - ! '>='
165
+ - - ">="
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  description: ActiveRecord and Mongoid extension for easier date scopes and time ranges
@@ -172,8 +172,10 @@ executables: []
172
172
  extensions: []
173
173
  extra_rdoc_files: []
174
174
  files:
175
- - .gitignore
176
- - .travis.yml
175
+ - ".github/workflows/mysql.yml"
176
+ - ".github/workflows/postgresql.yml"
177
+ - ".gitignore"
178
+ - ".travis.yml"
177
179
  - CHANGELOG.md
178
180
  - Gemfile
179
181
  - MIT-LICENSE
@@ -186,19 +188,36 @@ files:
186
188
  - lib/by_star/base.rb
187
189
  - lib/by_star/between.rb
188
190
  - lib/by_star/directional.rb
189
- - lib/by_star/kernel.rb
191
+ - lib/by_star/kernel/date.rb
192
+ - lib/by_star/kernel/in_time_zone.rb
193
+ - lib/by_star/kernel/time.rb
190
194
  - lib/by_star/normalization.rb
191
195
  - lib/by_star/orm/active_record/by_star.rb
192
196
  - lib/by_star/orm/mongoid/by_star.rb
197
+ - lib/by_star/orm/mongoid/reorder.rb
193
198
  - lib/by_star/version.rb
194
199
  - spec/database.yml
195
200
  - spec/fixtures/active_record/models.rb
196
201
  - spec/fixtures/active_record/schema.rb
197
202
  - spec/fixtures/mongoid/models.rb
198
203
  - spec/fixtures/shared/seeds.rb
204
+ - spec/gemfiles/Gemfile.rails
205
+ - spec/gemfiles/Gemfile.rails32
206
+ - spec/gemfiles/Gemfile.rails40
207
+ - spec/gemfiles/Gemfile.rails41
208
+ - spec/gemfiles/Gemfile.rails42
209
+ - spec/gemfiles/Gemfile.rails50
210
+ - spec/gemfiles/Gemfile.rails51
211
+ - spec/gemfiles/Gemfile.rails52
212
+ - spec/gemfiles/Gemfile.rails60
213
+ - spec/gemfiles/Gemfile.rails61
199
214
  - spec/integration/active_record/active_record_spec.rb
200
215
  - spec/integration/mongoid/mongoid_spec.rb
216
+ - spec/integration/shared/at_time.rb
217
+ - spec/integration/shared/between_dates.rb
218
+ - spec/integration/shared/between_times.rb
201
219
  - spec/integration/shared/by_calendar_month.rb
220
+ - spec/integration/shared/by_cweek.rb
202
221
  - spec/integration/shared/by_day.rb
203
222
  - spec/integration/shared/by_direction.rb
204
223
  - spec/integration/shared/by_fortnight.rb
@@ -207,59 +226,39 @@ files:
207
226
  - spec/integration/shared/by_week.rb
208
227
  - spec/integration/shared/by_weekend.rb
209
228
  - spec/integration/shared/by_year.rb
229
+ - spec/integration/shared/index_scope_parameter.rb
210
230
  - spec/integration/shared/offset_parameter.rb
231
+ - spec/integration/shared/order_parameter.rb
211
232
  - spec/integration/shared/relative.rb
212
- - spec/integration/shared/scope_parameter.rb
213
233
  - spec/spec_helper.rb
234
+ - spec/unit/kernel_date_spec.rb
214
235
  - spec/unit/kernel_time_spec.rb
215
236
  - spec/unit/normalization_spec.rb
216
237
  - tmp/.gitignore
217
238
  homepage: http://github.com/radar/by_star
218
239
  licenses: []
219
240
  metadata: {}
220
- post_install_message: ! 'Upgrading to ByStar 2.2.0
221
-
222
- -------------------------
223
-
224
-
225
- * ActiveRecord: the `between` method has been deprecated as of version 2.2.0, and
226
- will be removed in version 3.3.0.
227
-
228
- Please use `between_times` instead.
241
+ post_install_message: |
242
+ Upgrading ByStar
243
+ ----------------
229
244
 
230
-
231
- * Mongoid: the `between` method has been removed as of version 2.2.0, as it conflicts
232
- with the native Mongoid `between`
233
-
234
- method. Please use `between_times` instead.
235
-
236
-
237
- * Chronic gem (used for time string parsing) has been removed as a hard dependency
238
- for ByStar,
239
-
240
- however it is still supported. If you would like to use Chronic with ByStar, please
241
- explicitly
242
-
243
- include `gem chronic` into your Gemfile.
244
-
245
- '
245
+ * As of version 4.0.0, ByStar changes the way it handles `Date` arg to the `#between_times` method. If a `Date` is given as the second (end) arg, the query will use `Date.end_of_day` to include all time values which fall inside that date.
246
246
  rdoc_options: []
247
247
  require_paths:
248
248
  - lib
249
249
  required_ruby_version: !ruby/object:Gem::Requirement
250
250
  requirements:
251
- - - ! '>='
251
+ - - ">="
252
252
  - !ruby/object:Gem::Version
253
- version: '0'
253
+ version: 2.0.0
254
254
  required_rubygems_version: !ruby/object:Gem::Requirement
255
255
  requirements:
256
- - - ! '>='
256
+ - - ">="
257
257
  - !ruby/object:Gem::Version
258
258
  version: '0'
259
259
  requirements: []
260
- rubyforge_project:
261
- rubygems_version: 2.2.1
262
- signing_key:
260
+ rubygems_version: 3.1.6
261
+ signing_key:
263
262
  specification_version: 4
264
263
  summary: ActiveRecord and Mongoid extension for easier date scopes and time ranges
265
264
  test_files:
@@ -268,9 +267,23 @@ test_files:
268
267
  - spec/fixtures/active_record/schema.rb
269
268
  - spec/fixtures/mongoid/models.rb
270
269
  - spec/fixtures/shared/seeds.rb
270
+ - spec/gemfiles/Gemfile.rails
271
+ - spec/gemfiles/Gemfile.rails32
272
+ - spec/gemfiles/Gemfile.rails40
273
+ - spec/gemfiles/Gemfile.rails41
274
+ - spec/gemfiles/Gemfile.rails42
275
+ - spec/gemfiles/Gemfile.rails50
276
+ - spec/gemfiles/Gemfile.rails51
277
+ - spec/gemfiles/Gemfile.rails52
278
+ - spec/gemfiles/Gemfile.rails60
279
+ - spec/gemfiles/Gemfile.rails61
271
280
  - spec/integration/active_record/active_record_spec.rb
272
281
  - spec/integration/mongoid/mongoid_spec.rb
282
+ - spec/integration/shared/at_time.rb
283
+ - spec/integration/shared/between_dates.rb
284
+ - spec/integration/shared/between_times.rb
273
285
  - spec/integration/shared/by_calendar_month.rb
286
+ - spec/integration/shared/by_cweek.rb
274
287
  - spec/integration/shared/by_day.rb
275
288
  - spec/integration/shared/by_direction.rb
276
289
  - spec/integration/shared/by_fortnight.rb
@@ -279,10 +292,11 @@ test_files:
279
292
  - spec/integration/shared/by_week.rb
280
293
  - spec/integration/shared/by_weekend.rb
281
294
  - spec/integration/shared/by_year.rb
295
+ - spec/integration/shared/index_scope_parameter.rb
282
296
  - spec/integration/shared/offset_parameter.rb
297
+ - spec/integration/shared/order_parameter.rb
283
298
  - spec/integration/shared/relative.rb
284
- - spec/integration/shared/scope_parameter.rb
285
299
  - spec/spec_helper.rb
300
+ - spec/unit/kernel_date_spec.rb
286
301
  - spec/unit/kernel_time_spec.rb
287
302
  - spec/unit/normalization_spec.rb
288
- has_rdoc:
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
-
3
- shared_examples_for 'scope parameter' do
4
-
5
- describe 'scope' do
6
- it 'should memoize the scope variable' do
7
- Event.instance_variable_get(:@by_star_scope).should be_nil
8
- Post.instance_variable_get(:@by_star_scope).should be_nil
9
- Appointment.instance_variable_get(:@by_star_scope).should be_a Proc
10
- end
11
-
12
- context 'between_times with default scope' do
13
- subject { Appointment.between_times(Date.parse('2013-12-01'), Date.parse('2014-02-01')) }
14
- its(:count) { should eq 3 }
15
- end
16
-
17
- context 'between_times with scope override as a query criteria' do
18
- subject { Appointment.between_times(Date.parse('2013-12-01'), Date.parse('2014-02-01'), scope: Appointment.unscoped) }
19
- its(:count) { should eq 14 }
20
- end
21
-
22
- context 'between_times with scope override as a Proc' do
23
- subject { Appointment.between_times(Date.parse('2013-12-01'), Date.parse('2014-02-01'), scope: ->{ unscoped }) }
24
- its(:count) { should eq 14 }
25
- end
26
-
27
- context 'by_month with default scope' do
28
- subject { Appointment.by_month(Date.parse('2014-01-01')) }
29
- its(:count) { should eq 2 }
30
- end
31
-
32
- context 'by_month with scope override as a query criteria' do
33
- subject { Appointment.by_month(Date.parse('2014-01-01'), scope: Appointment.unscoped) }
34
- its(:count) { should eq 6 }
35
- end
36
-
37
- context 'by_month with scope override as a Proc' do
38
- subject { Appointment.by_month(Date.parse('2014-01-01'), scope: ->{ unscoped }) }
39
- its(:count) { should eq 6 }
40
- end
41
- end
42
- end