timeboss 0.0.10 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.yardopts +1 -0
  4. data/README.md +1 -1
  5. data/doc/TimeBoss.html +146 -0
  6. data/doc/TimeBoss/Calendar.html +137 -0
  7. data/doc/TimeBoss/Calendar/Day.html +594 -0
  8. data/doc/TimeBoss/Calendar/Half.html +396 -0
  9. data/doc/TimeBoss/Calendar/Month.html +396 -0
  10. data/doc/TimeBoss/Calendar/Parser.html +386 -0
  11. data/doc/TimeBoss/Calendar/Period.html +841 -0
  12. data/doc/TimeBoss/Calendar/Quarter.html +396 -0
  13. data/doc/TimeBoss/Calendar/Support.html +131 -0
  14. data/doc/TimeBoss/Calendar/Support/Formatter.html +459 -0
  15. data/doc/TimeBoss/Calendar/Support/MonthBased.html +591 -0
  16. data/doc/TimeBoss/Calendar/Support/MonthBasis.html +437 -0
  17. data/doc/TimeBoss/Calendar/Support/MonthlyUnit.html +591 -0
  18. data/doc/TimeBoss/Calendar/Support/Navigable.html +723 -0
  19. data/doc/TimeBoss/Calendar/Support/Shiftable.html +138 -0
  20. data/doc/TimeBoss/Calendar/Support/Unit.html +1299 -0
  21. data/doc/TimeBoss/Calendar/Waypoints.html +155 -0
  22. data/doc/TimeBoss/Calendar/Waypoints/Absolute.html +1378 -0
  23. data/doc/TimeBoss/Calendar/Waypoints/Relative.html +4308 -0
  24. data/doc/TimeBoss/Calendar/Week.html +671 -0
  25. data/doc/TimeBoss/Calendar/Year.html +319 -0
  26. data/doc/TimeBoss/Calendars.html +336 -0
  27. data/doc/TimeBoss/Calendars/Broadcast.html +221 -0
  28. data/doc/TimeBoss/Calendars/Broadcast/Basis.html +278 -0
  29. data/doc/TimeBoss/Calendars/Entry.html +399 -0
  30. data/doc/TimeBoss/Support.html +115 -0
  31. data/doc/TimeBoss/Support/Shellable.html +249 -0
  32. data/doc/_index.html +416 -0
  33. data/doc/class_list.html +51 -0
  34. data/doc/css/common.css +1 -0
  35. data/doc/css/full_list.css +58 -0
  36. data/doc/css/style.css +496 -0
  37. data/doc/file.README.html +299 -0
  38. data/doc/file_list.html +56 -0
  39. data/doc/frames.html +17 -0
  40. data/doc/index.html +299 -0
  41. data/doc/js/app.js +314 -0
  42. data/doc/js/full_list.js +216 -0
  43. data/doc/js/jquery.js +4 -0
  44. data/doc/method_list.html +1139 -0
  45. data/doc/top-level-namespace.html +110 -0
  46. data/lib/timeboss.rb +4 -0
  47. data/lib/timeboss/calendar.rb +14 -0
  48. data/lib/timeboss/calendar/day.rb +10 -3
  49. data/lib/timeboss/calendar/half.rb +7 -2
  50. data/lib/timeboss/calendar/month.rb +7 -2
  51. data/lib/timeboss/calendar/parser.rb +1 -0
  52. data/lib/timeboss/calendar/period.rb +26 -11
  53. data/lib/timeboss/calendar/quarter.rb +7 -2
  54. data/lib/timeboss/calendar/support.rb +8 -0
  55. data/lib/timeboss/calendar/support/formatter.rb +1 -0
  56. data/lib/timeboss/calendar/support/month_basis.rb +3 -0
  57. data/lib/timeboss/calendar/support/{month_based.rb → monthly_unit.rb} +7 -1
  58. data/lib/timeboss/calendar/support/navigable.rb +25 -1
  59. data/lib/timeboss/calendar/support/shiftable.rb +3 -2
  60. data/lib/timeboss/calendar/support/unit.rb +24 -0
  61. data/lib/timeboss/calendar/waypoints.rb +6 -55
  62. data/lib/timeboss/calendar/waypoints/absolute.rb +114 -0
  63. data/lib/timeboss/calendar/waypoints/relative.rb +268 -0
  64. data/lib/timeboss/calendar/week.rb +11 -0
  65. data/lib/timeboss/calendar/year.rb +6 -5
  66. data/lib/timeboss/calendars.rb +16 -0
  67. data/lib/timeboss/version.rb +1 -1
  68. data/spec/calendar/support/{month_based_spec.rb → monthly_unit_spec.rb} +7 -7
  69. data/spec/calendars/broadcast_spec.rb +7 -7
  70. data/timeboss.gemspec +1 -0
  71. metadata +70 -7
@@ -3,27 +3,38 @@ require_relative './support/unit'
3
3
 
4
4
  module TimeBoss
5
5
  class Calendar
6
+ # Representation of a single week within a calendar.
6
7
  class Week < Support::Unit
7
8
  def initialize(calendar, start_date, end_date)
8
9
  super(calendar, start_date, end_date)
9
10
  end
10
11
 
12
+ # Get a simple representation of this week.
13
+ # @return [String] (e.g. "2020W32")
11
14
  def name
12
15
  "#{year_index}W#{index}"
13
16
  end
14
17
 
18
+ # Get a "pretty" representation of this week.
19
+ # @return [String] (e.g. "Week of August 3, 2020")
15
20
  def title
16
21
  "Week of #{start_date.strftime('%B %-d, %Y')}"
17
22
  end
18
23
 
24
+ # Get a stringified representation of this week.
25
+ # @return [String] (e.g. "2020W32: 2020-08-03 thru 2020-08-09")
19
26
  def to_s
20
27
  "#{name}: #{start_date} thru #{end_date}"
21
28
  end
22
29
 
30
+ # Get the index of this week within its containing year.
31
+ # @return [Integer]
23
32
  def index
24
33
  @_index ||= (((start_date - year.start_date) + 1) / 7.0).to_i + 1
25
34
  end
26
35
 
36
+ # Get the year number for this week.
37
+ # @return [Integer] (e.g. 2020)
27
38
  def year_index
28
39
  @_year_index ||= year.year_index
29
40
  end
@@ -1,18 +1,19 @@
1
1
  # frozen_string_literal: true
2
- require_relative './support/month_based'
2
+ require_relative './support/monthly_unit'
3
3
 
4
4
  module TimeBoss
5
5
  class Calendar
6
- class Year < Support::MonthBased
6
+ # Representation of a 12-month period within a calendar.
7
+ class Year < Support::MonthlyUnit
7
8
  NUM_MONTHS = 12
8
9
 
10
+ # Get a simple representation of this year.
11
+ # @return [String] (e.g. "2020")
9
12
  def name
10
13
  year_index.to_s
11
14
  end
12
15
 
13
- def title
14
- name
15
- end
16
+ alias_method :title, :name
16
17
  end
17
18
  end
18
19
  end
@@ -5,17 +5,23 @@ require_relative 'calendar'
5
5
  Dir[File.expand_path('../calendars/*.rb', __FILE__)].each { |f| require f }
6
6
 
7
7
  module TimeBoss
8
+ # A home for specific calendar implementations.
8
9
  module Calendars
9
10
  extend self
10
11
  extend Enumerable
11
12
  delegate :each, :length, to: :all
12
13
 
14
+ # Retrieve a list of all registered calendars.
15
+ # @return [Array<Entry>]
13
16
  def all
14
17
  @_all ||= TimeBoss::Calendar.subclasses.map do |klass|
15
18
  Entry.new(klass.to_s.demodulize.underscore.to_sym, klass)
16
19
  end
17
20
  end
18
21
 
22
+ # Retrieve an instance of the specified named calendar.
23
+ # @param name [String, Symbol] the name of the calendar to retrieve.
24
+ # @return [Calendar]
19
25
  def [](name)
20
26
  find { |e| e.name == name&.to_sym }&.calendar
21
27
  end
@@ -23,6 +29,16 @@ module TimeBoss
23
29
  private
24
30
 
25
31
  Entry = Struct.new(:name, :klass) do
32
+ # @!method name
33
+ # Get the name of the calendar referenced in this entry.
34
+ # @return [Symbol]
35
+
36
+ # @!method klass
37
+ # The class implementing this calendar.
38
+ # @return [Class<Calendar>]
39
+
40
+ # Get an instance of the calendar referenced in this entry.
41
+ # @return [Calendar]
26
42
  def calendar
27
43
  @_calendar ||= klass.new
28
44
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module TimeBoss
3
- VERSION = "0.0.10"
3
+ VERSION = "0.1.0"
4
4
  end
@@ -1,15 +1,15 @@
1
1
  module TimeBoss
2
2
  class Calendar
3
3
  module Support
4
- describe MonthBased do
5
- class ChunkMonthBased < described_class
4
+ describe MonthlyUnit do
5
+ class MonthBasedChunk < described_class
6
6
  NUM_MONTHS = 2
7
7
 
8
8
  def name
9
9
  "#{year_index}C#{index}"
10
10
  end
11
11
  end
12
- let(:described_class) { ChunkMonthBased }
12
+ let(:described_class) { MonthBasedChunk }
13
13
  let(:calendar) { double }
14
14
  let(:start_date) { Date.parse('2018-06-25') }
15
15
  let(:end_date) { Date.parse('2018-08-26') }
@@ -51,24 +51,24 @@ module TimeBoss
51
51
 
52
52
  describe '#previous' do
53
53
  it 'moves easily within itself' do
54
- expect(calendar).to receive(:chunk_month_based).with(48, 3).and_return result
54
+ expect(calendar).to receive(:month_based_chunk).with(48, 3).and_return result
55
55
  expect(described_class.new(calendar, 48, 4, nil, nil).previous).to eq result
56
56
  end
57
57
 
58
58
  it 'flips to the previous container' do
59
- expect(calendar).to receive(:chunk_month_based).with(47, 6).and_return result
59
+ expect(calendar).to receive(:month_based_chunk).with(47, 6).and_return result
60
60
  expect(described_class.new(calendar, 48, 1, nil, nil).previous).to eq result
61
61
  end
62
62
  end
63
63
 
64
64
  describe '#next' do
65
65
  it 'moves easily within itself' do
66
- expect(calendar).to receive(:chunk_month_based).with(48, 3).and_return result
66
+ expect(calendar).to receive(:month_based_chunk).with(48, 3).and_return result
67
67
  expect(described_class.new(calendar, 48, 2, nil, nil).next).to eq result
68
68
  end
69
69
 
70
70
  it 'flips to the previous container' do
71
- expect(calendar).to receive(:chunk_month_based).with(48, 1).and_return result
71
+ expect(calendar).to receive(:month_based_chunk).with(48, 1).and_return result
72
72
  expect(described_class.new(calendar, 47, 6, nil, nil).next).to eq result
73
73
  end
74
74
  end
@@ -133,8 +133,8 @@ module TimeBoss
133
133
  expect(quarters.map(&:name)).to eq ['2015Q3', '2015Q4', '2016Q1', '2016Q2', '2016Q3']
134
134
  end
135
135
 
136
- it 'can get a quarter hence' do
137
- quarter = subject.quarters_hence(4)
136
+ it 'can get a quarter ahead' do
137
+ quarter = subject.quarters_ahead(4)
138
138
  expect(quarter).to be_a TimeBoss::Calendar::Quarter
139
139
  expect(quarter.name).to eq '2016Q3'
140
140
  end
@@ -271,8 +271,8 @@ module TimeBoss
271
271
  expect(months.map(&:name)).to eq ['2015M3', '2015M4', '2015M5', '2015M6', '2015M7']
272
272
  end
273
273
 
274
- it 'can get a month hence' do
275
- month = subject.months_hence(4)
274
+ it 'can get a month ahead' do
275
+ month = subject.months_ahead(4)
276
276
  expect(month).to be_a TimeBoss::Calendar::Month
277
277
  expect(month.name).to eq '2015M7'
278
278
  end
@@ -510,7 +510,7 @@ module TimeBoss
510
510
  it 'can parse mathematic expressions' do
511
511
  result = subject.parse('this_month + 2')
512
512
  expect(result).to be_a TimeBoss::Calendar::Month
513
- expect(result).to eq subject.months_hence(2)
513
+ expect(result).to eq subject.months_ahead(2)
514
514
  end
515
515
 
516
516
  context 'ranges' do
@@ -574,7 +574,7 @@ module TimeBoss
574
574
 
575
575
  it 'can shift to a different year' do
576
576
  allow(subject).to receive(:this_year).and_return subject.parse('2019')
577
- result = basis.years_hence(3)
577
+ result = basis.years_ahead(3)
578
578
  expect(result).to be_a TimeBoss::Calendar::Day
579
579
  expect(result.to_s).to eq '2022-04-19'
580
580
  expect(basis.in_year).to eq 114
@@ -616,7 +616,7 @@ module TimeBoss
616
616
 
617
617
  it 'can shift to a different year' do
618
618
  allow(subject).to receive(:this_year).and_return subject.parse('2020')
619
- result = basis.years_hence(4)
619
+ result = basis.years_ahead(4)
620
620
  expect(result).to be_a TimeBoss::Calendar::Month
621
621
  expect(result.name).to eq '2024M4'
622
622
  expect(basis.in_year).to eq 4
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "rack-test"
28
28
  spec.add_development_dependency "rake"
29
29
  spec.add_development_dependency "rspec"
30
+ spec.add_development_dependency "yard"
30
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timeboss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin McDonald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-18 00:00:00.000000000 Z
11
+ date: 2020-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: yard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: Broadcast Calendar navigation in Ruby made simple
112
126
  email:
113
127
  - kevinstuffandthings@gmail.com
@@ -121,12 +135,59 @@ files:
121
135
  - ".gitignore"
122
136
  - ".rspec"
123
137
  - ".travis.yml"
138
+ - ".yardoc/checksums"
139
+ - ".yardoc/complete"
140
+ - ".yardoc/object_types"
141
+ - ".yardoc/objects/root.dat"
142
+ - ".yardoc/proxy_types"
143
+ - ".yardopts"
124
144
  - CODE_OF_CONDUCT.md
125
145
  - Gemfile
126
146
  - LICENSE.txt
127
147
  - README.md
128
148
  - Rakefile
129
149
  - bin/tbsh
150
+ - doc/TimeBoss.html
151
+ - doc/TimeBoss/Calendar.html
152
+ - doc/TimeBoss/Calendar/Day.html
153
+ - doc/TimeBoss/Calendar/Half.html
154
+ - doc/TimeBoss/Calendar/Month.html
155
+ - doc/TimeBoss/Calendar/Parser.html
156
+ - doc/TimeBoss/Calendar/Period.html
157
+ - doc/TimeBoss/Calendar/Quarter.html
158
+ - doc/TimeBoss/Calendar/Support.html
159
+ - doc/TimeBoss/Calendar/Support/Formatter.html
160
+ - doc/TimeBoss/Calendar/Support/MonthBased.html
161
+ - doc/TimeBoss/Calendar/Support/MonthBasis.html
162
+ - doc/TimeBoss/Calendar/Support/MonthlyUnit.html
163
+ - doc/TimeBoss/Calendar/Support/Navigable.html
164
+ - doc/TimeBoss/Calendar/Support/Shiftable.html
165
+ - doc/TimeBoss/Calendar/Support/Unit.html
166
+ - doc/TimeBoss/Calendar/Waypoints.html
167
+ - doc/TimeBoss/Calendar/Waypoints/Absolute.html
168
+ - doc/TimeBoss/Calendar/Waypoints/Relative.html
169
+ - doc/TimeBoss/Calendar/Week.html
170
+ - doc/TimeBoss/Calendar/Year.html
171
+ - doc/TimeBoss/Calendars.html
172
+ - doc/TimeBoss/Calendars/Broadcast.html
173
+ - doc/TimeBoss/Calendars/Broadcast/Basis.html
174
+ - doc/TimeBoss/Calendars/Entry.html
175
+ - doc/TimeBoss/Support.html
176
+ - doc/TimeBoss/Support/Shellable.html
177
+ - doc/_index.html
178
+ - doc/class_list.html
179
+ - doc/css/common.css
180
+ - doc/css/full_list.css
181
+ - doc/css/style.css
182
+ - doc/file.README.html
183
+ - doc/file_list.html
184
+ - doc/frames.html
185
+ - doc/index.html
186
+ - doc/js/app.js
187
+ - doc/js/full_list.js
188
+ - doc/js/jquery.js
189
+ - doc/method_list.html
190
+ - doc/top-level-namespace.html
130
191
  - lib/tasks/calendars.rake
131
192
  - lib/tasks/timeboss.rake
132
193
  - lib/timeboss.rb
@@ -137,13 +198,16 @@ files:
137
198
  - lib/timeboss/calendar/parser.rb
138
199
  - lib/timeboss/calendar/period.rb
139
200
  - lib/timeboss/calendar/quarter.rb
201
+ - lib/timeboss/calendar/support.rb
140
202
  - lib/timeboss/calendar/support/formatter.rb
141
- - lib/timeboss/calendar/support/month_based.rb
142
203
  - lib/timeboss/calendar/support/month_basis.rb
204
+ - lib/timeboss/calendar/support/monthly_unit.rb
143
205
  - lib/timeboss/calendar/support/navigable.rb
144
206
  - lib/timeboss/calendar/support/shiftable.rb
145
207
  - lib/timeboss/calendar/support/unit.rb
146
208
  - lib/timeboss/calendar/waypoints.rb
209
+ - lib/timeboss/calendar/waypoints/absolute.rb
210
+ - lib/timeboss/calendar/waypoints/relative.rb
147
211
  - lib/timeboss/calendar/week.rb
148
212
  - lib/timeboss/calendar/year.rb
149
213
  - lib/timeboss/calendars.rb
@@ -152,7 +216,7 @@ files:
152
216
  - lib/timeboss/version.rb
153
217
  - spec/calendar/day_spec.rb
154
218
  - spec/calendar/quarter_spec.rb
155
- - spec/calendar/support/month_based_spec.rb
219
+ - spec/calendar/support/monthly_unit_spec.rb
156
220
  - spec/calendar/support/unit_spec.rb
157
221
  - spec/calendar/week_spec.rb
158
222
  - spec/calendars/broadcast_spec.rb
@@ -178,15 +242,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
242
  - !ruby/object:Gem::Version
179
243
  version: '0'
180
244
  requirements: []
181
- rubyforge_project:
182
- rubygems_version: 2.7.7
245
+ rubygems_version: 3.0.8
183
246
  signing_key:
184
247
  specification_version: 4
185
248
  summary: Broadcast Calendar navigation in Ruby made simple
186
249
  test_files:
187
250
  - spec/calendar/day_spec.rb
188
251
  - spec/calendar/quarter_spec.rb
189
- - spec/calendar/support/month_based_spec.rb
252
+ - spec/calendar/support/monthly_unit_spec.rb
190
253
  - spec/calendar/support/unit_spec.rb
191
254
  - spec/calendar/week_spec.rb
192
255
  - spec/calendars/broadcast_spec.rb