by_star 3.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  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 -61
  6. data/CHANGELOG.md +63 -44
  7. data/Gemfile +18 -18
  8. data/MIT-LICENSE +20 -20
  9. data/README.md +616 -577
  10. data/Rakefile +18 -18
  11. data/UPGRADING +4 -6
  12. data/by_star.gemspec +34 -34
  13. data/cleaner.rb +24 -24
  14. data/lib/by_star/base.rb +69 -68
  15. data/lib/by_star/between.rb +185 -156
  16. data/lib/by_star/directional.rb +35 -37
  17. data/lib/by_star/kernel/date.rb +41 -50
  18. data/lib/by_star/kernel/in_time_zone.rb +20 -0
  19. data/lib/by_star/kernel/time.rb +41 -41
  20. data/lib/by_star/normalization.rb +156 -127
  21. data/lib/by_star/orm/active_record/by_star.rb +75 -61
  22. data/lib/by_star/orm/mongoid/by_star.rb +90 -76
  23. data/lib/by_star/orm/mongoid/reorder.rb +23 -23
  24. data/lib/by_star/version.rb +3 -3
  25. data/lib/by_star.rb +18 -17
  26. data/spec/database.yml +15 -15
  27. data/spec/fixtures/active_record/models.rb +12 -12
  28. data/spec/fixtures/active_record/schema.rb +19 -19
  29. data/spec/fixtures/mongoid/models.rb +31 -31
  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 -7
  34. data/spec/gemfiles/Gemfile.rails41 +7 -7
  35. data/spec/gemfiles/Gemfile.rails42 +7 -7
  36. data/spec/gemfiles/Gemfile.rails50 +7 -10
  37. data/spec/gemfiles/Gemfile.rails51 +7 -10
  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 -38
  42. data/spec/integration/mongoid/mongoid_spec.rb +39 -37
  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 -82
  46. data/spec/integration/shared/by_calendar_month.rb +55 -55
  47. data/spec/integration/shared/by_cweek.rb +54 -54
  48. data/spec/integration/shared/by_day.rb +120 -96
  49. data/spec/integration/shared/by_direction.rb +126 -172
  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 -32
  58. data/spec/integration/shared/order_parameter.rb +36 -36
  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 -113
  62. data/spec/unit/kernel_time_spec.rb +57 -57
  63. data/spec/unit/normalization_spec.rb +384 -305
  64. data/tmp/.gitignore +1 -1
  65. metadata +33 -21
  66. data/spec/gemfiles/Gemfile.master +0 -6
  67. data/spec/integration/shared/scope_parameter.rb +0 -73
data/tmp/.gitignore CHANGED
@@ -1 +1 @@
1
- *.log
1
+ *.log
metadata CHANGED
@@ -1,30 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: by_star
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.1
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: 2018-02-01 00:00:00.000000000 Z
12
+ date: 2023-01-18 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: '3'
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: '3'
27
+ version: 3.2.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: chronic
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -113,16 +113,16 @@ dependencies:
113
113
  name: mysql2
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - "~>"
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
- version: 0.3.10
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
- version: 0.3.10
125
+ version: '0'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: rspec-rails
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -172,6 +172,8 @@ executables: []
172
172
  extensions: []
173
173
  extra_rdoc_files: []
174
174
  files:
175
+ - ".github/workflows/mysql.yml"
176
+ - ".github/workflows/postgresql.yml"
175
177
  - ".gitignore"
176
178
  - ".travis.yml"
177
179
  - CHANGELOG.md
@@ -187,6 +189,7 @@ files:
187
189
  - lib/by_star/between.rb
188
190
  - lib/by_star/directional.rb
189
191
  - lib/by_star/kernel/date.rb
192
+ - lib/by_star/kernel/in_time_zone.rb
190
193
  - lib/by_star/kernel/time.rb
191
194
  - lib/by_star/normalization.rb
192
195
  - lib/by_star/orm/active_record/by_star.rb
@@ -198,14 +201,20 @@ files:
198
201
  - spec/fixtures/active_record/schema.rb
199
202
  - spec/fixtures/mongoid/models.rb
200
203
  - spec/fixtures/shared/seeds.rb
201
- - spec/gemfiles/Gemfile.master
204
+ - spec/gemfiles/Gemfile.rails
205
+ - spec/gemfiles/Gemfile.rails32
202
206
  - spec/gemfiles/Gemfile.rails40
203
207
  - spec/gemfiles/Gemfile.rails41
204
208
  - spec/gemfiles/Gemfile.rails42
205
209
  - spec/gemfiles/Gemfile.rails50
206
210
  - spec/gemfiles/Gemfile.rails51
211
+ - spec/gemfiles/Gemfile.rails52
212
+ - spec/gemfiles/Gemfile.rails60
213
+ - spec/gemfiles/Gemfile.rails61
207
214
  - spec/integration/active_record/active_record_spec.rb
208
215
  - spec/integration/mongoid/mongoid_spec.rb
216
+ - spec/integration/shared/at_time.rb
217
+ - spec/integration/shared/between_dates.rb
209
218
  - spec/integration/shared/between_times.rb
210
219
  - spec/integration/shared/by_calendar_month.rb
211
220
  - spec/integration/shared/by_cweek.rb
@@ -217,10 +226,10 @@ files:
217
226
  - spec/integration/shared/by_week.rb
218
227
  - spec/integration/shared/by_weekend.rb
219
228
  - spec/integration/shared/by_year.rb
229
+ - spec/integration/shared/index_scope_parameter.rb
220
230
  - spec/integration/shared/offset_parameter.rb
221
231
  - spec/integration/shared/order_parameter.rb
222
232
  - spec/integration/shared/relative.rb
223
- - spec/integration/shared/scope_parameter.rb
224
233
  - spec/spec_helper.rb
225
234
  - spec/unit/kernel_date_spec.rb
226
235
  - spec/unit/kernel_time_spec.rb
@@ -233,9 +242,7 @@ post_install_message: |
233
242
  Upgrading ByStar
234
243
  ----------------
235
244
 
236
- * Chronic gem (used for time string parsing) has been removed as a hard dependency for ByStar,
237
- however it is still supported. If you would like to use Chronic with ByStar, please explicitly
238
- include `gem chronic` into your Gemfile.
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.
239
246
  rdoc_options: []
240
247
  require_paths:
241
248
  - lib
@@ -250,9 +257,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
257
  - !ruby/object:Gem::Version
251
258
  version: '0'
252
259
  requirements: []
253
- rubyforge_project:
254
- rubygems_version: 2.7.4
255
- signing_key:
260
+ rubygems_version: 3.3.24
261
+ signing_key:
256
262
  specification_version: 4
257
263
  summary: ActiveRecord and Mongoid extension for easier date scopes and time ranges
258
264
  test_files:
@@ -261,14 +267,20 @@ test_files:
261
267
  - spec/fixtures/active_record/schema.rb
262
268
  - spec/fixtures/mongoid/models.rb
263
269
  - spec/fixtures/shared/seeds.rb
264
- - spec/gemfiles/Gemfile.master
270
+ - spec/gemfiles/Gemfile.rails
271
+ - spec/gemfiles/Gemfile.rails32
265
272
  - spec/gemfiles/Gemfile.rails40
266
273
  - spec/gemfiles/Gemfile.rails41
267
274
  - spec/gemfiles/Gemfile.rails42
268
275
  - spec/gemfiles/Gemfile.rails50
269
276
  - spec/gemfiles/Gemfile.rails51
277
+ - spec/gemfiles/Gemfile.rails52
278
+ - spec/gemfiles/Gemfile.rails60
279
+ - spec/gemfiles/Gemfile.rails61
270
280
  - spec/integration/active_record/active_record_spec.rb
271
281
  - spec/integration/mongoid/mongoid_spec.rb
282
+ - spec/integration/shared/at_time.rb
283
+ - spec/integration/shared/between_dates.rb
272
284
  - spec/integration/shared/between_times.rb
273
285
  - spec/integration/shared/by_calendar_month.rb
274
286
  - spec/integration/shared/by_cweek.rb
@@ -280,10 +292,10 @@ test_files:
280
292
  - spec/integration/shared/by_week.rb
281
293
  - spec/integration/shared/by_weekend.rb
282
294
  - spec/integration/shared/by_year.rb
295
+ - spec/integration/shared/index_scope_parameter.rb
283
296
  - spec/integration/shared/offset_parameter.rb
284
297
  - spec/integration/shared/order_parameter.rb
285
298
  - spec/integration/shared/relative.rb
286
- - spec/integration/shared/scope_parameter.rb
287
299
  - spec/spec_helper.rb
288
300
  - spec/unit/kernel_date_spec.rb
289
301
  - spec/unit/kernel_time_spec.rb
@@ -1,6 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gemspec path: '../../'
4
-
5
- gem 'activerecord', github: 'rails'
6
- gem 'mongoid', github: 'mongoid'
@@ -1,73 +0,0 @@
1
- require 'spec_helper'
2
-
3
- shared_examples_for 'scope parameter' do
4
-
5
- describe ':scope' do
6
-
7
- it 'should memoize the scope variable' do
8
- expect(Event.instance_variable_get(:@by_star_scope)).to be_nil
9
- expect(Post.instance_variable_get(:@by_star_scope)).to be_nil
10
- expect(Appointment.instance_variable_get(:@by_star_scope)).to be_a Proc
11
- end
12
-
13
- context 'between_times with default scope' do
14
- subject { Appointment.between_times(Date.parse('2013-12-01'), Date.parse('2014-02-01')) }
15
- it { expect(subject.count).to eql(3) }
16
- end
17
-
18
- context 'between_times with scope override as a query criteria' do
19
- subject { Appointment.between_times(Date.parse('2013-12-01')..Date.parse('2014-02-01'), scope: Appointment.unscoped) }
20
- it { expect(subject.count).to eql(14) }
21
- end
22
-
23
- context 'between_times with scope override as a Lambda' do
24
- subject { Appointment.between_times([Date.parse('2013-12-01'), Date.parse('2014-02-01')], scope: ->{ unscoped }) }
25
- it { expect(subject.count).to eql(14) }
26
- end
27
-
28
- context 'between_times with scope override as a Lambda' do
29
- subject { Appointment.between_times(Date.parse('2013-12-01')..Date.parse('2014-02-01'), scope: ->(x){ unscoped }) }
30
- it{ expect{ subject }.to raise_error(RuntimeError, 'ByStar :scope Proc requires :scope_args to be specified.') }
31
- end
32
-
33
- context 'between_times with scope override as a Proc with arguments' do
34
- subject { Appointment.between_times(Date.parse('2013-12-01'), Date.parse('2014-02-01'), scope: Proc.new{ unscoped }) }
35
- it { expect(subject.count).to eql(14) }
36
- end
37
-
38
- context 'between_times with scope override as a Proc with arguments' do
39
- subject { Appointment.between_times([Date.parse('2013-12-01'), Date.parse('2014-02-01')], scope: Proc.new{|x,y| unscoped }) }
40
- it{ expect{ subject }.to raise_error(RuntimeError, 'ByStar :scope Proc requires :scope_args to be specified.') }
41
- end
42
-
43
- context 'by_month with default scope' do
44
- subject { Appointment.by_month(Date.parse('2014-01-01')) }
45
- it { expect(subject.count).to eql(2) }
46
- end
47
-
48
- context 'by_month with scope override as a query criteria' do
49
- subject { Appointment.by_month(Date.parse('2014-01-01'), scope: Appointment.unscoped) }
50
- it { expect(subject.count).to eql(6) }
51
- end
52
-
53
- context 'by_month with scope override as a Lambda' do
54
- subject { Appointment.by_month(Date.parse('2014-01-01'), scope: ->{ unscoped }) }
55
- it { expect(subject.count).to eql(6) }
56
- end
57
-
58
- context 'by_month with scope override as a Lambda with arguments' do
59
- subject { Appointment.by_month(Date.parse('2014-01-01'), scope: ->(x){ unscoped }) }
60
- it{ expect{ subject }.to raise_error(RuntimeError, 'ByStar :scope Proc requires :scope_args to be specified.') }
61
- end
62
-
63
- context 'by_month with scope override as a Proc' do
64
- subject { Appointment.by_month(Date.parse('2014-01-01'), scope: Proc.new{ unscoped }) }
65
- it { expect(subject.count).to eql(6) }
66
- end
67
-
68
- context 'by_month with scope override as a Proc with arguments' do
69
- subject { Appointment.by_month(Date.parse('2014-01-01'), scope: Proc.new{|x| unscoped }) }
70
- it{ expect{ subject }.to raise_error(RuntimeError, 'ByStar :scope Proc requires :scope_args to be specified.') }
71
- end
72
- end
73
- end