by_star 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/mysql.yml +92 -92
- data/.github/workflows/postgresql.yml +99 -99
- data/.gitignore +6 -6
- data/.travis.yml +92 -92
- data/CHANGELOG.md +63 -59
- data/Gemfile +18 -18
- data/MIT-LICENSE +20 -20
- data/README.md +616 -616
- data/Rakefile +18 -18
- data/UPGRADING +4 -4
- data/by_star.gemspec +34 -34
- data/cleaner.rb +24 -24
- data/lib/by_star/base.rb +69 -69
- data/lib/by_star/between.rb +185 -185
- data/lib/by_star/directional.rb +35 -35
- data/lib/by_star/kernel/date.rb +41 -41
- data/lib/by_star/kernel/in_time_zone.rb +20 -20
- data/lib/by_star/kernel/time.rb +41 -41
- data/lib/by_star/normalization.rb +156 -156
- data/lib/by_star/orm/active_record/by_star.rb +75 -75
- data/lib/by_star/orm/mongoid/by_star.rb +90 -90
- data/lib/by_star/orm/mongoid/reorder.rb +23 -23
- data/lib/by_star/version.rb +3 -3
- data/lib/by_star.rb +18 -18
- data/spec/database.yml +15 -15
- data/spec/fixtures/active_record/models.rb +12 -12
- data/spec/fixtures/active_record/schema.rb +19 -19
- data/spec/fixtures/mongoid/models.rb +31 -31
- data/spec/fixtures/shared/seeds.rb +36 -36
- data/spec/gemfiles/Gemfile.rails +5 -5
- data/spec/gemfiles/Gemfile.rails32 +7 -7
- data/spec/gemfiles/Gemfile.rails40 +7 -7
- data/spec/gemfiles/Gemfile.rails41 +7 -7
- data/spec/gemfiles/Gemfile.rails42 +7 -7
- data/spec/gemfiles/Gemfile.rails50 +7 -7
- data/spec/gemfiles/Gemfile.rails51 +7 -7
- data/spec/gemfiles/Gemfile.rails52 +7 -7
- data/spec/gemfiles/Gemfile.rails60 +7 -7
- data/spec/gemfiles/Gemfile.rails61 +7 -7
- data/spec/integration/active_record/active_record_spec.rb +41 -41
- data/spec/integration/mongoid/mongoid_spec.rb +39 -39
- data/spec/integration/shared/at_time.rb +53 -53
- data/spec/integration/shared/between_dates.rb +99 -99
- data/spec/integration/shared/between_times.rb +99 -99
- data/spec/integration/shared/by_calendar_month.rb +55 -55
- data/spec/integration/shared/by_cweek.rb +54 -54
- data/spec/integration/shared/by_day.rb +120 -120
- data/spec/integration/shared/by_direction.rb +126 -126
- data/spec/integration/shared/by_fortnight.rb +48 -48
- data/spec/integration/shared/by_month.rb +50 -50
- data/spec/integration/shared/by_quarter.rb +49 -49
- data/spec/integration/shared/by_week.rb +54 -54
- data/spec/integration/shared/by_weekend.rb +49 -49
- data/spec/integration/shared/by_year.rb +48 -48
- data/spec/integration/shared/index_scope_parameter.rb +111 -111
- data/spec/integration/shared/offset_parameter.rb +32 -32
- data/spec/integration/shared/order_parameter.rb +36 -36
- data/spec/integration/shared/relative.rb +174 -174
- data/spec/spec_helper.rb +33 -33
- data/spec/unit/kernel_date_spec.rb +113 -113
- data/spec/unit/kernel_time_spec.rb +57 -57
- data/spec/unit/normalization_spec.rb +384 -384
- data/tmp/.gitignore +1 -1
- metadata +3 -3
@@ -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
|