by_star 3.0.0 → 4.0.1

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 (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
@@ -1,57 +1,57 @@
1
- require 'spec_helper'
2
-
3
- describe Time do
4
-
5
- describe 'weekend' do
6
-
7
- (0..6).each do |n|
8
- context "Monday plus #{n} days" do
9
- subject { Time.zone.parse('2014-01-06') + n.days }
10
- it { expect(subject.beginning_of_weekend).to eq Time.zone.parse('2014-01-11') }
11
- it { expect(subject.end_of_weekend).to eq Time.zone.parse('2014-01-12').end_of_day }
12
- end
13
- end
14
- end
15
-
16
- describe 'fortnight' do
17
-
18
- context 'first day of year' do
19
- subject { Time.zone.parse '2014-01-01' }
20
- it { expect(subject.beginning_of_fortnight).to eq Time.zone.parse('2014-01-01') }
21
- it { expect(subject.end_of_fortnight).to eq Time.zone.parse('2014-01-14').end_of_day }
22
- end
23
-
24
- context 'second fortnight of year' do
25
- subject { Time.zone.parse '2014-01-16' }
26
- it { expect(subject.beginning_of_fortnight).to eq Time.zone.parse('2014-01-15') }
27
- it { expect(subject.end_of_fortnight).to eq Time.zone.parse('2014-01-28').end_of_day }
28
- end
29
-
30
- context 'middle of year' do
31
- subject { Time.zone.parse '2014-06-13' }
32
- it { expect(subject.beginning_of_fortnight).to eq Time.zone.parse('2014-06-04') }
33
- it { expect(subject.end_of_fortnight).to eq Time.zone.parse('2014-06-17').end_of_day }
34
- end
35
-
36
- context 'last day of year' do
37
- subject { Time.zone.parse '2014-12-31' }
38
- it { expect(subject.beginning_of_fortnight).to eq Time.zone.parse('2014-12-31') }
39
- it { expect(subject.end_of_fortnight).to eq Time.zone.parse('2015-01-13').end_of_day }
40
- end
41
- end
42
-
43
- describe 'calendar_month' do
44
-
45
- subject { Time.zone.parse '2014-01-01' }
46
-
47
- context 'week begins Monday' do
48
- it { expect(subject.beginning_of_calendar_month).to eq Time.zone.parse('2013-12-30') }
49
- it { expect(subject.end_of_calendar_month).to eq Time.zone.parse('2014-02-02').end_of_day }
50
- end
51
-
52
- context 'week begins Sunday' do
53
- it { expect(subject.beginning_of_calendar_month(:sunday)).to eq Time.zone.parse('2013-12-29') }
54
- it { expect(subject.end_of_calendar_month(:sunday)).to eq Time.zone.parse('2014-02-01').end_of_day }
55
- end
56
- end
57
- end
1
+ require 'spec_helper'
2
+
3
+ describe Time do
4
+
5
+ describe 'weekend' do
6
+
7
+ (0..6).each do |n|
8
+ context "Monday plus #{n} days" do
9
+ subject { Time.zone.parse('2014-01-06') + n.days }
10
+ it { expect(subject.beginning_of_weekend).to eq Time.zone.parse('2014-01-11') }
11
+ it { expect(subject.end_of_weekend).to eq Time.zone.parse('2014-01-12').end_of_day }
12
+ end
13
+ end
14
+ end
15
+
16
+ describe 'fortnight' do
17
+
18
+ context 'first day of year' do
19
+ subject { Time.zone.parse '2014-01-01' }
20
+ it { expect(subject.beginning_of_fortnight).to eq Time.zone.parse('2014-01-01') }
21
+ it { expect(subject.end_of_fortnight).to eq Time.zone.parse('2014-01-14').end_of_day }
22
+ end
23
+
24
+ context 'second fortnight of year' do
25
+ subject { Time.zone.parse '2014-01-16' }
26
+ it { expect(subject.beginning_of_fortnight).to eq Time.zone.parse('2014-01-15') }
27
+ it { expect(subject.end_of_fortnight).to eq Time.zone.parse('2014-01-28').end_of_day }
28
+ end
29
+
30
+ context 'middle of year' do
31
+ subject { Time.zone.parse '2014-06-13' }
32
+ it { expect(subject.beginning_of_fortnight).to eq Time.zone.parse('2014-06-04') }
33
+ it { expect(subject.end_of_fortnight).to eq Time.zone.parse('2014-06-17').end_of_day }
34
+ end
35
+
36
+ context 'last day of year' do
37
+ subject { Time.zone.parse '2014-12-31' }
38
+ it { expect(subject.beginning_of_fortnight).to eq Time.zone.parse('2014-12-31') }
39
+ it { expect(subject.end_of_fortnight).to eq Time.zone.parse('2015-01-13').end_of_day }
40
+ end
41
+ end
42
+
43
+ describe 'calendar_month' do
44
+
45
+ subject { Time.zone.parse '2014-01-01' }
46
+
47
+ context 'week begins Monday' do
48
+ it { expect(subject.beginning_of_calendar_month).to eq Time.zone.parse('2013-12-30') }
49
+ it { expect(subject.end_of_calendar_month).to eq Time.zone.parse('2014-02-02').end_of_day }
50
+ end
51
+
52
+ context 'week begins Sunday' do
53
+ it { expect(subject.beginning_of_calendar_month(:sunday)).to eq Time.zone.parse('2013-12-29') }
54
+ it { expect(subject.end_of_calendar_month(:sunday)).to eq Time.zone.parse('2014-02-01').end_of_day }
55
+ end
56
+ end
57
+ end