timely 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +22 -2
- data/.travis.yml +0 -6
- data/CHANGELOG.md +6 -0
- data/Gemfile +2 -0
- data/Rakefile +6 -4
- data/gemfiles/rails5.gemfile +4 -2
- data/gemfiles/rails6.gemfile +3 -1
- data/lib/timely/date.rb +6 -2
- data/lib/timely/date_chooser.rb +29 -30
- data/lib/timely/date_range.rb +17 -19
- data/lib/timely/date_time.rb +3 -1
- data/lib/timely/rails/calendar_tag.rb +3 -3
- data/lib/timely/rails/date.rb +3 -1
- data/lib/timely/rails/date_group.rb +24 -24
- data/lib/timely/rails/date_range_validity_module.rb +8 -6
- data/lib/timely/rails/date_time.rb +5 -3
- data/lib/timely/rails/extensions.rb +12 -37
- data/lib/timely/rails/period.rb +14 -12
- data/lib/timely/rails/season.rb +14 -33
- data/lib/timely/rails/time.rb +7 -3
- data/lib/timely/rails.rb +2 -0
- data/lib/timely/railtie.rb +2 -0
- data/lib/timely/range.rb +4 -2
- data/lib/timely/string.rb +4 -2
- data/lib/timely/time.rb +7 -3
- data/lib/timely/time_since.rb +5 -3
- data/lib/timely/trackable_date_set.rb +21 -21
- data/lib/timely/version.rb +3 -1
- data/lib/timely/week_days.rb +14 -16
- data/lib/timely.rb +2 -0
- data/rails/init.rb +2 -0
- data/spec/calendar_tag_spec.rb +11 -10
- data/spec/date_chooser_spec.rb +67 -62
- data/spec/date_group_spec.rb +18 -15
- data/spec/date_range_spec.rb +29 -19
- data/spec/date_spec.rb +3 -1
- data/spec/extensions_spec.rb +5 -9
- data/spec/rails/date_spec.rb +5 -3
- data/spec/rails/date_time_spec.rb +9 -7
- data/spec/rails/period_spec.rb +2 -0
- data/spec/rails/time_spec.rb +6 -4
- data/spec/schema.rb +4 -3
- data/spec/season_spec.rb +23 -26
- data/spec/spec_helper.rb +3 -1
- data/spec/support/coverage_loader.rb +3 -1
- data/spec/temporal_patterns_spec.rb +5 -5
- data/spec/time_since_spec.rb +6 -4
- data/spec/time_spec.rb +6 -4
- data/spec/trackable_date_set_spec.rb +20 -18
- data/spec/week_days_spec.rb +24 -22
- data/timely.gemspec +20 -18
- metadata +32 -20
- data/spec/string_spec.rb +0 -14
data/spec/week_days_spec.rb
CHANGED
@@ -1,30 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
RSpec.describe Timely::WeekDays do
|
4
6
|
before do
|
5
|
-
@weekdays = Timely::WeekDays.new(:
|
7
|
+
@weekdays = Timely::WeekDays.new(tue: true, thu: true)
|
6
8
|
end
|
7
9
|
|
8
10
|
it 'should create via hash, integer and array' do
|
9
11
|
# 0 0 1 0 1 0 0
|
10
12
|
# Sat Fri Thu Wed Tue Mon Sun
|
11
|
-
expect(Timely::WeekDays.new(0b0010100).weekdays).to eq [
|
12
|
-
expect(Timely::WeekDays.new(%w
|
13
|
-
expect(Timely::WeekDays.new(:
|
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]
|
14
16
|
end
|
15
17
|
|
16
18
|
it 'should be able to set/unset days' do
|
17
19
|
@weekdays[:mon] = true
|
18
|
-
expect(@weekdays.weekdays).to eq [
|
20
|
+
expect(@weekdays.weekdays).to eq %i[mon tue thu]
|
19
21
|
@weekdays[:tue] = false
|
20
|
-
expect(@weekdays.weekdays).to eq [
|
22
|
+
expect(@weekdays.weekdays).to eq %i[mon thu]
|
21
23
|
end
|
22
24
|
|
23
|
-
it 'should output days nicely' do
|
24
|
-
expect(Timely::WeekDays.new(%w
|
25
|
-
expect(Timely::WeekDays.new(%w
|
26
|
-
expect(Timely::WeekDays.new(%w
|
27
|
-
expect(Timely::WeekDays.new(%w
|
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'
|
28
30
|
end
|
29
31
|
|
30
32
|
it 'should be able to determine if days of the week are selected' do
|
@@ -36,8 +38,8 @@ RSpec.describe Timely::WeekDays do
|
|
36
38
|
end
|
37
39
|
|
38
40
|
it 'should be able to determine if it would be applicable on a date' do
|
39
|
-
expect(@weekdays.applies_for_date?(Date.new(2012,
|
40
|
-
expect(@weekdays.applies_for_date?(Date.new(2012,
|
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
|
41
43
|
end
|
42
44
|
|
43
45
|
it 'should be able to convert to integer for use in databases, etc.' do
|
@@ -45,23 +47,23 @@ RSpec.describe Timely::WeekDays do
|
|
45
47
|
end
|
46
48
|
|
47
49
|
it 'should be able to determine if all days are selected' do
|
48
|
-
expect(Timely::WeekDays.new(%w
|
49
|
-
expect(Timely::WeekDays.new(%w
|
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
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
53
55
|
RSpec.describe 'Timely::WeekDays.from_range' do
|
54
56
|
{
|
55
|
-
'single date as string': { date_range: '2019-10-17', expected_weekdays: [
|
56
|
-
'single date as object': { date_range: '2019-10-17'.to_date, expected_weekdays: [
|
57
|
-
'range with strings':
|
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': {
|
58
60
|
date_range: '2019-10-17'..'2019-10-18',
|
59
|
-
expected_weekdays: [
|
61
|
+
expected_weekdays: %i[thu fri]
|
60
62
|
},
|
61
|
-
'range with objects':
|
63
|
+
'range with objects': {
|
62
64
|
date_range: ('2019-10-17'.to_date)..('2019-10-18'.to_date),
|
63
|
-
expected_weekdays: [
|
64
|
-
}
|
65
|
+
expected_weekdays: %i[thu fri]
|
66
|
+
}
|
65
67
|
}.each do |type, data|
|
66
68
|
it "#{type} has correct weekdays and applies for dates" do
|
67
69
|
weekdays = Timely::WeekDays.from_range(data[:date_range])
|
data/timely.gemspec
CHANGED
@@ -1,36 +1,38 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'timely/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'timely'
|
8
9
|
spec.version = Timely::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.description =
|
12
|
-
spec.summary =
|
10
|
+
spec.authors = ['Michael Noack']
|
11
|
+
spec.email = ['support@travellink.com.au']
|
12
|
+
spec.description = 'Set of time, date, weekday related methods.'
|
13
|
+
spec.summary = 'Set of time, date, weekday related methods.'
|
13
14
|
spec.homepage = 'http://github.com/sealink/timely'
|
14
15
|
|
15
|
-
spec.license =
|
16
|
+
spec.license = 'MIT'
|
16
17
|
|
17
|
-
spec.files = `git ls-files`.split(
|
18
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
18
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
-
spec.require_paths = [
|
21
|
+
spec.require_paths = ['lib']
|
21
22
|
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency '
|
25
|
-
spec.add_development_dependency '
|
23
|
+
spec.add_development_dependency 'actionpack'
|
24
|
+
spec.add_development_dependency 'activerecord'
|
25
|
+
spec.add_development_dependency 'activesupport'
|
26
|
+
spec.add_development_dependency 'bundler', '~> 2.0.1'
|
26
27
|
spec.add_development_dependency 'coverage-kit'
|
27
|
-
spec.add_development_dependency 'simplecov-rcov'
|
28
28
|
spec.add_development_dependency 'coveralls'
|
29
|
+
spec.add_development_dependency 'rake'
|
30
|
+
spec.add_development_dependency 'rspec'
|
31
|
+
spec.add_development_dependency 'rspec-its'
|
29
32
|
spec.add_development_dependency 'rubocop'
|
33
|
+
spec.add_development_dependency 'rubocop-rails'
|
34
|
+
spec.add_development_dependency 'simplecov-rcov'
|
30
35
|
spec.add_development_dependency 'sqlite3'
|
31
|
-
spec.add_development_dependency 'activesupport'
|
32
|
-
spec.add_development_dependency 'activerecord'
|
33
|
-
spec.add_development_dependency 'actionpack'
|
34
36
|
spec.add_development_dependency 'timecop'
|
35
37
|
spec.add_development_dependency 'travis'
|
36
38
|
end
|
metadata
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timely
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Noack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: actionpack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,21 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coverage-kit
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
@@ -67,7 +81,7 @@ dependencies:
|
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: coveralls
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - ">="
|
@@ -81,7 +95,7 @@ dependencies:
|
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - ">="
|
@@ -95,7 +109,7 @@ dependencies:
|
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
112
|
+
name: rspec
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - ">="
|
@@ -109,7 +123,7 @@ dependencies:
|
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
126
|
+
name: rspec-its
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - ">="
|
@@ -123,7 +137,7 @@ dependencies:
|
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
140
|
+
name: rubocop
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - ">="
|
@@ -137,7 +151,7 @@ dependencies:
|
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
154
|
+
name: rubocop-rails
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
157
|
- - ">="
|
@@ -151,7 +165,7 @@ dependencies:
|
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
168
|
+
name: simplecov-rcov
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
171
|
- - ">="
|
@@ -165,7 +179,7 @@ dependencies:
|
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
182
|
+
name: sqlite3
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
170
184
|
requirements:
|
171
185
|
- - ">="
|
@@ -266,7 +280,6 @@ files:
|
|
266
280
|
- spec/schema.rb
|
267
281
|
- spec/season_spec.rb
|
268
282
|
- spec/spec_helper.rb
|
269
|
-
- spec/string_spec.rb
|
270
283
|
- spec/support/coverage_loader.rb
|
271
284
|
- spec/temporal_patterns_spec.rb
|
272
285
|
- spec/time_since_spec.rb
|
@@ -311,7 +324,6 @@ test_files:
|
|
311
324
|
- spec/schema.rb
|
312
325
|
- spec/season_spec.rb
|
313
326
|
- spec/spec_helper.rb
|
314
|
-
- spec/string_spec.rb
|
315
327
|
- spec/support/coverage_loader.rb
|
316
328
|
- spec/temporal_patterns_spec.rb
|
317
329
|
- spec/time_since_spec.rb
|
data/spec/string_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe String do
|
4
|
-
# Spec currently doesn't work
|
5
|
-
#it "should convert to date" do
|
6
|
-
# "10-2010-01".to_date('%d-%Y-%m').should eql Date.parse("2010-01-10")
|
7
|
-
#end
|
8
|
-
|
9
|
-
# Spec currently doesn't work
|
10
|
-
#it 'should handle rails date formats' do
|
11
|
-
# Date::DATE_FORMATS[:db] = '%m-%Y-%d'
|
12
|
-
# "01-2010-10".to_date(:db).should eql Date.parse("2010-01-10")
|
13
|
-
#end
|
14
|
-
end
|