timely 0.6.0 → 0.10.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +13 -2
- data/lib/timely/rails/date_group.rb +1 -3
- data/lib/timely/version.rb +1 -1
- data/timely.gemspec +8 -10
- metadata +26 -91
- data/.gitignore +0 -6
- data/.rspec +0 -2
- data/.rubocop.yml +0 -28
- data/.ruby-version +0 -1
- data/.travis.yml +0 -16
- data/Gemfile +0 -4
- data/LICENSE +0 -21
- data/Rakefile +0 -14
- data/gemfiles/rails5.gemfile +0 -8
- data/gemfiles/rails6.gemfile +0 -8
- data/rails/init.rb +0 -3
- data/spec/calendar_tag_spec.rb +0 -30
- data/spec/date_chooser_spec.rb +0 -115
- data/spec/date_group_spec.rb +0 -86
- data/spec/date_range_spec.rb +0 -89
- data/spec/date_spec.rb +0 -78
- data/spec/extensions_spec.rb +0 -28
- data/spec/rails/date_spec.rb +0 -18
- data/spec/rails/date_time_spec.rb +0 -28
- data/spec/rails/period_spec.rb +0 -19
- data/spec/rails/time_spec.rb +0 -73
- data/spec/schema.rb +0 -17
- data/spec/season_spec.rb +0 -62
- data/spec/spec_helper.rb +0 -33
- data/spec/support/coverage_loader.rb +0 -6
- data/spec/temporal_patterns_spec.rb +0 -28
- data/spec/time_since_spec.rb +0 -26
- data/spec/time_spec.rb +0 -70
- data/spec/trackable_date_set_spec.rb +0 -82
- data/spec/week_days_spec.rb +0 -76
@@ -1,82 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Timely::TrackableDateSet, ' tracking 7 days' do
|
6
|
-
before do
|
7
|
-
@range = Date.today..(Date.today + 6)
|
8
|
-
@trackable_date_set = Timely::TrackableDateSet.new(@range)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should start on the first date' do
|
12
|
-
expect(@trackable_date_set.start_date).to eq Date.today
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should end on the last date' do
|
16
|
-
expect(@trackable_date_set.end_date).to eq Date.today + 6
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should have the 7 days set' do
|
20
|
-
expect(dates).to eq @range.to_a
|
21
|
-
expect(@trackable_date_set.duration).to eq 7
|
22
|
-
expect(@trackable_date_set.number_of_nights).to eq 7
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should have all the 7 days to do' do
|
26
|
-
expect(dates_to_do).to eq @range.to_a
|
27
|
-
should_not_have_done(@range.to_a)
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should have only the last 6 days to do when we set_done! the first one' do
|
31
|
-
@trackable_date_set.set_date_done!(Date.today)
|
32
|
-
expect(dates_to_do).to eq(((Date.today + 1)..(Date.today + 6)).to_a)
|
33
|
-
|
34
|
-
should_not_have_done(@range.to_a - [Date.today])
|
35
|
-
should_have_done([Date.today])
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should have the first, and last three left to do if we set 2nd, 3rd & 4th to be done' do
|
39
|
-
dates_to_be_done = [Date.today + 1, Date.today + 2, Date.today + 3]
|
40
|
-
@trackable_date_set.set_dates_done!(dates_to_be_done)
|
41
|
-
|
42
|
-
expect(dates_to_do).to eq [Date.today, Date.today + 4, Date.today + 5, Date.today + 6]
|
43
|
-
should_not_have_done(@range.to_a - dates_to_be_done)
|
44
|
-
should_have_done(dates_to_be_done)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should have none left to do when set_all_done!' do
|
48
|
-
@trackable_date_set.set_all_done!
|
49
|
-
expect(dates_to_do).to eq []
|
50
|
-
should_have_done(@range.to_a)
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should have no actions applied' do
|
54
|
-
expect(@trackable_date_set.action_applied?(:some_action)).to be false
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should remember if we apply an action' do
|
58
|
-
@trackable_date_set.apply_action(:some_action)
|
59
|
-
expect(@trackable_date_set.action_applied?(:some_action)).to be true
|
60
|
-
expect(@trackable_date_set.action_applied?(:some_other_action)).to be false
|
61
|
-
end
|
62
|
-
|
63
|
-
def should_have_done(dates)
|
64
|
-
dates.each { |date| expect(@trackable_date_set.done_dates?(date)).to be true }
|
65
|
-
end
|
66
|
-
|
67
|
-
def should_not_have_done(dates)
|
68
|
-
dates.each { |date| expect(@trackable_date_set.done_dates?(date)).to be false }
|
69
|
-
end
|
70
|
-
|
71
|
-
def dates
|
72
|
-
contained_dates = []
|
73
|
-
@trackable_date_set.each_date { |date| contained_dates << date }
|
74
|
-
contained_dates
|
75
|
-
end
|
76
|
-
|
77
|
-
def dates_to_do
|
78
|
-
contained_dates = []
|
79
|
-
@trackable_date_set.each_date_to_do { |date| contained_dates << date }
|
80
|
-
contained_dates
|
81
|
-
end
|
82
|
-
end
|
data/spec/week_days_spec.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe Timely::WeekDays do
|
6
|
-
before do
|
7
|
-
@weekdays = Timely::WeekDays.new(tue: true, thu: true)
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should create via hash, integer and array' do
|
11
|
-
# 0 0 1 0 1 0 0
|
12
|
-
# Sat Fri Thu Wed Tue Mon Sun
|
13
|
-
expect(Timely::WeekDays.new(0b0010100).weekdays).to eq %i[tue thu]
|
14
|
-
expect(Timely::WeekDays.new(%w[0 0 1 0 1 0 0]).weekdays).to eq %i[tue thu]
|
15
|
-
expect(Timely::WeekDays.new(tue: true, thu: true).weekdays).to eq %i[tue thu]
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should be able to set/unset days' do
|
19
|
-
@weekdays[:mon] = true
|
20
|
-
expect(@weekdays.weekdays).to eq %i[mon tue thu]
|
21
|
-
@weekdays[:tue] = false
|
22
|
-
expect(@weekdays.weekdays).to eq %i[mon thu]
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should output days nicely' do
|
26
|
-
expect(Timely::WeekDays.new(%w[1 0 0 0 0 0 0]).to_s).to eq 'Sun'
|
27
|
-
expect(Timely::WeekDays.new(%w[1 0 1 0 0 0 0]).to_s).to eq 'Sun, and Tue'
|
28
|
-
expect(Timely::WeekDays.new(%w[1 0 1 1 0 0 0]).to_s).to eq 'Sun, Tue, and Wed'
|
29
|
-
expect(Timely::WeekDays.new(%w[1 0 1 1 0 1 0]).to_s).to eq 'Sun, Tue, Wed, and Fri'
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should be able to determine if days of the week are selected' do
|
33
|
-
# Test mon and tue in both symbol/integer forms
|
34
|
-
expect(@weekdays.has_day?(1)).to be false
|
35
|
-
expect(@weekdays.has_day?(:mon)).to be false
|
36
|
-
expect(@weekdays.has_day?(2)).to be true
|
37
|
-
expect(@weekdays.has_day?(:tue)).to be true
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should be able to determine if it would be applicable on a date' do
|
41
|
-
expect(@weekdays.applies_for_date?(Date.new(2012, 0o4, 22))).to be false # Sunday
|
42
|
-
expect(@weekdays.applies_for_date?(Date.new(2012, 0o4, 24))).to be true # Tuesday
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should be able to convert to integer for use in databases, etc.' do
|
46
|
-
expect(@weekdays.weekdays_int).to eq 4 + 16 # 4 = Tue, 16 = Thu
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should be able to determine if all days are selected' do
|
50
|
-
expect(Timely::WeekDays.new(%w[1 1 1 1 1 1 1]).all_days?).to be true
|
51
|
-
expect(Timely::WeekDays.new(%w[1 1 1 1 1 0 1]).all_days?).to be false
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
RSpec.describe 'Timely::WeekDays.from_range' do
|
56
|
-
{
|
57
|
-
'single date as string': { date_range: '2019-10-17', expected_weekdays: [:thu] },
|
58
|
-
'single date as object': { date_range: '2019-10-17'.to_date, expected_weekdays: [:thu] },
|
59
|
-
'range with strings': {
|
60
|
-
date_range: '2019-10-17'..'2019-10-18',
|
61
|
-
expected_weekdays: %i[thu fri]
|
62
|
-
},
|
63
|
-
'range with objects': {
|
64
|
-
date_range: ('2019-10-17'.to_date)..('2019-10-18'.to_date),
|
65
|
-
expected_weekdays: %i[thu fri]
|
66
|
-
}
|
67
|
-
}.each do |type, data|
|
68
|
-
it "#{type} has correct weekdays and applies for dates" do
|
69
|
-
weekdays = Timely::WeekDays.from_range(data[:date_range])
|
70
|
-
expect(weekdays.weekdays).to eq(data[:expected_weekdays])
|
71
|
-
Array(data[:date_range]).each do |date|
|
72
|
-
expect(weekdays.applies_for_date?(date.to_date)).to eq(true)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|