timeboss 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -4
- data/lib/timeboss/calendar.rb +0 -1
- data/lib/timeboss/calendar/day.rb +0 -1
- data/lib/timeboss/calendar/half.rb +0 -1
- data/lib/timeboss/calendar/month.rb +0 -1
- data/lib/timeboss/calendar/parser.rb +0 -1
- data/lib/timeboss/calendar/period.rb +0 -1
- data/lib/timeboss/calendar/quarter.rb +0 -1
- data/lib/timeboss/calendar/support/formatter.rb +2 -2
- data/lib/timeboss/calendar/support/month_basis.rb +0 -2
- data/lib/timeboss/calendar/support/monthly_unit.rb +0 -2
- data/lib/timeboss/calendar/support/navigable.rb +0 -1
- data/lib/timeboss/calendar/support/shiftable.rb +218 -29
- data/lib/timeboss/calendar/support/translatable.rb +92 -0
- data/lib/timeboss/calendar/support/unit.rb +2 -1
- data/lib/timeboss/calendar/waypoints.rb +0 -1
- data/lib/timeboss/calendar/waypoints/absolute.rb +0 -1
- data/lib/timeboss/calendar/waypoints/relative.rb +0 -1
- data/lib/timeboss/calendar/week.rb +0 -1
- data/lib/timeboss/calendar/year.rb +0 -1
- data/lib/timeboss/calendars.rb +0 -1
- data/lib/timeboss/version.rb +1 -1
- metadata +4 -49
- data/doc/TimeBoss.html +0 -146
- data/doc/TimeBoss/Calendar.html +0 -137
- data/doc/TimeBoss/Calendar/Day.html +0 -594
- data/doc/TimeBoss/Calendar/Half.html +0 -396
- data/doc/TimeBoss/Calendar/Month.html +0 -396
- data/doc/TimeBoss/Calendar/Parser.html +0 -386
- data/doc/TimeBoss/Calendar/Period.html +0 -841
- data/doc/TimeBoss/Calendar/Quarter.html +0 -396
- data/doc/TimeBoss/Calendar/Support.html +0 -131
- data/doc/TimeBoss/Calendar/Support/Formatter.html +0 -459
- data/doc/TimeBoss/Calendar/Support/MonthBased.html +0 -591
- data/doc/TimeBoss/Calendar/Support/MonthBasis.html +0 -437
- data/doc/TimeBoss/Calendar/Support/MonthlyUnit.html +0 -591
- data/doc/TimeBoss/Calendar/Support/Navigable.html +0 -723
- data/doc/TimeBoss/Calendar/Support/Shiftable.html +0 -138
- data/doc/TimeBoss/Calendar/Support/Unit.html +0 -1299
- data/doc/TimeBoss/Calendar/Waypoints.html +0 -155
- data/doc/TimeBoss/Calendar/Waypoints/Absolute.html +0 -1378
- data/doc/TimeBoss/Calendar/Waypoints/Relative.html +0 -4308
- data/doc/TimeBoss/Calendar/Week.html +0 -671
- data/doc/TimeBoss/Calendar/Year.html +0 -319
- data/doc/TimeBoss/Calendars.html +0 -336
- data/doc/TimeBoss/Calendars/Broadcast.html +0 -221
- data/doc/TimeBoss/Calendars/Broadcast/Basis.html +0 -278
- data/doc/TimeBoss/Calendars/Entry.html +0 -399
- data/doc/TimeBoss/Support.html +0 -115
- data/doc/TimeBoss/Support/Shellable.html +0 -249
- data/doc/_index.html +0 -416
- data/doc/class_list.html +0 -51
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -58
- data/doc/css/style.css +0 -496
- data/doc/file.README.html +0 -299
- data/doc/file_list.html +0 -56
- data/doc/frames.html +0 -17
- data/doc/index.html +0 -299
- data/doc/js/app.js +0 -314
- data/doc/js/full_list.js +0 -216
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -1139
- data/doc/top-level-namespace.html +0 -110
- data/lib/timeboss/calendar/support.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b27f1fec825b8ddb084a029a0621d939bd2525a67f33879611dfc36f6a722d4c
|
4
|
+
data.tar.gz: 93fb0c6366dab6a4e577c1507d8cb99ddbb952ebfeea5ec67f134d1ba0c33c14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dab7d412003da6fd0b753e49a46c8d877f15cf802997fa3ad172ad48b2fd571aeb9288572254bf8b4a9289f4eccdaef2f6cc1d88e4a0d0512beea946022fe7df
|
7
|
+
data.tar.gz: 197ae44718c8dca52c091d90ab6c0a80f0e45d3207b095ff8194801b06481f20efabb6612ba822270c682429da12b16c0e08c87b91ff7e0b72440dcf8b3573ee
|
data/.gitignore
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
*.gem
|
2
|
+
Gemfile.lock
|
3
|
+
.bundle
|
4
|
+
.yardoc
|
5
|
+
doc
|
data/lib/timeboss/calendar.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require_relative './
|
2
|
+
require_relative './translatable'
|
3
3
|
|
4
4
|
module TimeBoss
|
5
5
|
class Calendar
|
@@ -8,7 +8,7 @@ module TimeBoss
|
|
8
8
|
|
9
9
|
# The formatter is responsible for the implementation of name formatting for a unit.
|
10
10
|
class Formatter
|
11
|
-
PERIODS =
|
11
|
+
PERIODS = Translatable::PERIODS.reverse.map(&:to_sym).drop(1)
|
12
12
|
attr_reader :unit, :periods
|
13
13
|
|
14
14
|
def initialize(unit, periods)
|
@@ -2,50 +2,239 @@
|
|
2
2
|
module TimeBoss
|
3
3
|
class Calendar
|
4
4
|
module Support
|
5
|
-
# Provides the ability to take a unit, and shift it into a different period, relative to today.
|
6
5
|
module Shiftable
|
7
|
-
PERIODS
|
8
|
-
|
9
|
-
PERIODS.each do |period|
|
6
|
+
Support::Translatable::PERIODS.each do |period|
|
10
7
|
periods = period.pluralize
|
11
8
|
|
12
|
-
define_method
|
13
|
-
calendar.send("#{periods}_for", self)
|
14
|
-
end
|
15
|
-
|
16
|
-
define_method period do
|
17
|
-
entries = send(periods)
|
18
|
-
return nil unless entries.length == 1
|
19
|
-
entries.first
|
20
|
-
end
|
21
|
-
|
22
|
-
define_method "in_#{period}" do
|
9
|
+
define_method("in_#{period}") do
|
23
10
|
base = send(periods)
|
24
11
|
return unless base.length == 1
|
25
12
|
base.first.send(self.class.type.to_s.pluralize).find_index { |p| p == self } + 1
|
26
13
|
end
|
27
14
|
|
28
|
-
define_method
|
15
|
+
define_method("#{periods}_ago") do |offset|
|
29
16
|
base_offset = send("in_#{period}") or return
|
30
17
|
(calendar.send("this_#{period}") - offset).send(self.class.type.to_s.pluralize)[base_offset - 1]
|
31
18
|
end
|
32
19
|
|
33
|
-
define_method "
|
34
|
-
send("#{periods}_ago", 1)
|
35
|
-
end
|
20
|
+
define_method("#{periods}_ahead") { |o| send("#{periods}_ago", o * -1) }
|
36
21
|
|
37
|
-
define_method
|
38
|
-
|
39
|
-
|
22
|
+
define_method("last_#{period}") { send("#{periods}_ago", 1) }
|
23
|
+
define_method("this_#{period}") { send("#{periods}_ago", 0) }
|
24
|
+
define_method("next_#{period}") { send("#{periods}_ahead", 1) }
|
25
|
+
end
|
40
26
|
|
41
|
-
|
42
|
-
|
43
|
-
|
27
|
+
alias_method :yesterday, :last_day
|
28
|
+
alias_method :today, :this_day
|
29
|
+
alias_method :tomorrow, :next_day
|
44
30
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
31
|
+
#
|
32
|
+
# i hate this
|
33
|
+
#
|
34
|
+
|
35
|
+
### Days
|
36
|
+
|
37
|
+
# @!method in_day
|
38
|
+
# Get the index within the day that this unit falls in.
|
39
|
+
# Returns nil if no single day can be identified.
|
40
|
+
# @return [Integer, nil]
|
41
|
+
|
42
|
+
# @!method days_ago
|
43
|
+
# Get the index-relative day some number of days ago.
|
44
|
+
# Returns nil if no single day can be identified.
|
45
|
+
# @param offset [Integer] the number of days back to shift this period
|
46
|
+
# @return [Calendar::Day, nil]
|
47
|
+
|
48
|
+
# @!method days_ahead
|
49
|
+
# Get the index-relative day some number of days ahead.
|
50
|
+
# Returns nil if no single day can be identified.
|
51
|
+
# @param offset [Integer] the number of days forward to shift this period
|
52
|
+
# @return [Calendar::Day, nil]
|
53
|
+
|
54
|
+
# @!method last_day
|
55
|
+
# Get the index-relative day 1 day ago.
|
56
|
+
# Returns nil if no single day can be identified.
|
57
|
+
# @return [Calendar::Day, nil]
|
58
|
+
|
59
|
+
# @!method this_day
|
60
|
+
# Get the index-relative day for this day.
|
61
|
+
# Returns nil if no single day can be identified.
|
62
|
+
# @return [Calendar::Day, nil]
|
63
|
+
|
64
|
+
# @!method next_day
|
65
|
+
# Get the index-relative day 1 day forward.
|
66
|
+
# Returns nil if no single day can be identified.
|
67
|
+
# @return [Calendar::Day, nil]
|
68
|
+
|
69
|
+
### Weeks
|
70
|
+
|
71
|
+
# @!method in_week
|
72
|
+
# Get the index within the week that this unit falls in.
|
73
|
+
# Returns nil if no single week can be identified.
|
74
|
+
# @return [Integer, nil]
|
75
|
+
|
76
|
+
# @!method weeks_ago
|
77
|
+
# Get the index-relative week some number of weeks ago.
|
78
|
+
# Returns nil if no single week can be identified.
|
79
|
+
# @param offset [Integer] the number of weeks back to shift this period
|
80
|
+
# @return [Calendar::Week, nil]
|
81
|
+
|
82
|
+
# @!method weeks_ahead
|
83
|
+
# Get the index-relative week some number of weeks ahead.
|
84
|
+
# Returns nil if no single week can be identified.
|
85
|
+
# @param offset [Integer] the number of weeks forward to shift this period
|
86
|
+
# @return [Calendar::Week, nil]
|
87
|
+
|
88
|
+
# @!method last_week
|
89
|
+
# Get the index-relative week 1 week ago.
|
90
|
+
# Returns nil if no single week can be identified.
|
91
|
+
# @return [Calendar::Week, nil]
|
92
|
+
|
93
|
+
# @!method this_week
|
94
|
+
# Get the index-relative week for this week.
|
95
|
+
# Returns nil if no single week can be identified.
|
96
|
+
# @return [Calendar::Week, nil]
|
97
|
+
|
98
|
+
# @!method next_week
|
99
|
+
# Get the index-relative week 1 week forward.
|
100
|
+
# Returns nil if no single week can be identified.
|
101
|
+
# @return [Calendar::Week, nil]
|
102
|
+
|
103
|
+
### Months
|
104
|
+
|
105
|
+
# @!method in_month
|
106
|
+
# Get the index within the month that this unit falls in.
|
107
|
+
# Returns nil if no single month can be identified.
|
108
|
+
# @return [Integer, nil]
|
109
|
+
|
110
|
+
# @!method months_ago
|
111
|
+
# Get the index-relative month some number of months ago.
|
112
|
+
# Returns nil if no single month can be identified.
|
113
|
+
# @param offset [Integer] the number of months back to shift this period
|
114
|
+
# @return [Calendar::Month, nil]
|
115
|
+
|
116
|
+
# @!method months_ahead
|
117
|
+
# Get the index-relative month some number of months ahead.
|
118
|
+
# Returns nil if no single month can be identified.
|
119
|
+
# @param offset [Integer] the number of months forward to shift this period
|
120
|
+
# @return [Calendar::Month, nil]
|
121
|
+
|
122
|
+
# @!method last_month
|
123
|
+
# Get the index-relative month 1 month ago.
|
124
|
+
# Returns nil if no single month can be identified.
|
125
|
+
# @return [Calendar::Month, nil]
|
126
|
+
|
127
|
+
# @!method this_month
|
128
|
+
# Get the index-relative month for this month.
|
129
|
+
# Returns nil if no single month can be identified.
|
130
|
+
# @return [Calendar::Month, nil]
|
131
|
+
|
132
|
+
# @!method next_month
|
133
|
+
# Get the index-relative month 1 month forward.
|
134
|
+
# Returns nil if no single month can be identified.
|
135
|
+
# @return [Calendar::Month, nil]
|
136
|
+
|
137
|
+
### Quarters
|
138
|
+
|
139
|
+
# @!method in_quarter
|
140
|
+
# Get the index within the quarter that this unit falls in.
|
141
|
+
# Returns nil if no single quarter can be identified.
|
142
|
+
# @return [Integer, nil]
|
143
|
+
|
144
|
+
# @!method quarters_ago
|
145
|
+
# Get the index-relative quarter some number of quarters ago.
|
146
|
+
# Returns nil if no single quarter can be identified.
|
147
|
+
# @param offset [Integer] the number of quarters back to shift this period
|
148
|
+
# @return [Calendar::Quarter, nil]
|
149
|
+
|
150
|
+
# @!method quarters_ahead
|
151
|
+
# Get the index-relative quarter some number of quarters ahead.
|
152
|
+
# Returns nil if no single quarter can be identified.
|
153
|
+
# @param offset [Integer] the number of quarters forward to shift this period
|
154
|
+
# @return [Calendar::Quarter, nil]
|
155
|
+
|
156
|
+
# @!method last_quarter
|
157
|
+
# Get the index-relative quarter 1 quarter ago.
|
158
|
+
# Returns nil if no single quarter can be identified.
|
159
|
+
# @return [Calendar::Quarter, nil]
|
160
|
+
|
161
|
+
# @!method this_quarter
|
162
|
+
# Get the index-relative quarter for this quarter.
|
163
|
+
# Returns nil if no single quarter can be identified.
|
164
|
+
# @return [Calendar::Quarter, nil]
|
165
|
+
|
166
|
+
# @!method next_quarter
|
167
|
+
# Get the index-relative quarter 1 quarter forward.
|
168
|
+
# Returns nil if no single quarter can be identified.
|
169
|
+
# @return [Calendar::Quarter, nil]
|
170
|
+
|
171
|
+
### Halves
|
172
|
+
|
173
|
+
# @!method in_half
|
174
|
+
# Get the index within the half that this unit falls in.
|
175
|
+
# Returns nil if no single half can be identified.
|
176
|
+
# @return [Integer, nil]
|
177
|
+
|
178
|
+
# @!method halves_ago
|
179
|
+
# Get the index-relative half some number of halves ago.
|
180
|
+
# Returns nil if no single half can be identified.
|
181
|
+
# @param offset [Integer] the number of halves back to shift this period
|
182
|
+
# @return [Calendar::Half, nil]
|
183
|
+
|
184
|
+
# @!method halves_ahead
|
185
|
+
# Get the index-relative half some number of halves ahead.
|
186
|
+
# Returns nil if no single half can be identified.
|
187
|
+
# @param offset [Integer] the number of halves forward to shift this period
|
188
|
+
# @return [Calendar::Half, nil]
|
189
|
+
|
190
|
+
# @!method last_half
|
191
|
+
# Get the index-relative half 1 half ago.
|
192
|
+
# Returns nil if no single half can be identified.
|
193
|
+
# @return [Calendar::Half, nil]
|
194
|
+
|
195
|
+
# @!method this_half
|
196
|
+
# Get the index-relative half for this half.
|
197
|
+
# Returns nil if no single half can be identified.
|
198
|
+
# @return [Calendar::Half, nil]
|
199
|
+
|
200
|
+
# @!method next_half
|
201
|
+
# Get the index-relative half 1 half forward.
|
202
|
+
# Returns nil if no single half can be identified.
|
203
|
+
# @return [Calendar::Half, nil]
|
204
|
+
|
205
|
+
### Years
|
206
|
+
|
207
|
+
# @!method in_year
|
208
|
+
# Get the index within the year that this unit falls in.
|
209
|
+
# Returns nil if no single year can be identified.
|
210
|
+
# @return [Integer, nil]
|
211
|
+
|
212
|
+
# @!method years_ago
|
213
|
+
# Get the index-relative year some number of years ago.
|
214
|
+
# Returns nil if no single year can be identified.
|
215
|
+
# @param offset [Integer] the number of years back to shift this period
|
216
|
+
# @return [Calendar::Year, nil]
|
217
|
+
|
218
|
+
# @!method years_ahead
|
219
|
+
# Get the index-relative year some number of years ahead.
|
220
|
+
# Returns nil if no single year can be identified.
|
221
|
+
# @param offset [Integer] the number of years forward to shift this period
|
222
|
+
# @return [Calendar::Year, nil]
|
223
|
+
|
224
|
+
# @!method last_year
|
225
|
+
# Get the index-relative year 1 year ago.
|
226
|
+
# Returns nil if no single year can be identified.
|
227
|
+
# @return [Calendar::Year, nil]
|
228
|
+
|
229
|
+
# @!method this_year
|
230
|
+
# Get the index-relative year for this year.
|
231
|
+
# Returns nil if no single year can be identified.
|
232
|
+
# @return [Calendar::Year, nil]
|
233
|
+
|
234
|
+
# @!method next_year
|
235
|
+
# Get the index-relative year 1 year forward.
|
236
|
+
# Returns nil if no single year can be identified.
|
237
|
+
# @return [Calendar::Year, nil]
|
49
238
|
end
|
50
239
|
end
|
51
240
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module TimeBoss
|
3
|
+
class Calendar
|
4
|
+
module Support
|
5
|
+
module Translatable
|
6
|
+
PERIODS = %w[day week month quarter half year]
|
7
|
+
|
8
|
+
PERIODS.each do |period|
|
9
|
+
periods = period.pluralize
|
10
|
+
|
11
|
+
define_method(periods) { calendar.send("#{periods}_for", self) }
|
12
|
+
|
13
|
+
define_method(period) do
|
14
|
+
entries = send(periods)
|
15
|
+
return nil unless entries.length == 1
|
16
|
+
entries.first
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# i hate this
|
22
|
+
#
|
23
|
+
|
24
|
+
### Days
|
25
|
+
|
26
|
+
# @!method days
|
27
|
+
# Get a list of days that fall within this unit.
|
28
|
+
# @return [Array<Calendar::Day>]
|
29
|
+
|
30
|
+
# @!method day
|
31
|
+
# Get the day this unit represents.
|
32
|
+
# Returns nil if no single day can be identified.
|
33
|
+
# @return [Array<Calendar::Day>, nil]
|
34
|
+
|
35
|
+
### Weeks
|
36
|
+
|
37
|
+
# @!method weeks
|
38
|
+
# Get a list of weeks that fall within this unit.
|
39
|
+
# @return [Array<Calendar::Week>]
|
40
|
+
|
41
|
+
# @!method week
|
42
|
+
# Get the week this unit represents.
|
43
|
+
# Returns nil if no single week can be identified.
|
44
|
+
# @return [Array<Calendar::Week>, nil]
|
45
|
+
|
46
|
+
### Months
|
47
|
+
|
48
|
+
# @!method months
|
49
|
+
# Get a list of months that fall within this unit.
|
50
|
+
# @return [Array<Calendar::Month>]
|
51
|
+
|
52
|
+
# @!method month
|
53
|
+
# Get the month this unit represents.
|
54
|
+
# Returns nil if no single month can be identified.
|
55
|
+
# @return [Array<Calendar::Month>, nil]
|
56
|
+
|
57
|
+
### Quarters
|
58
|
+
|
59
|
+
# @!method quarters
|
60
|
+
# Get a list of quarters that fall within this unit.
|
61
|
+
# @return [Array<Calendar::Quarter>]
|
62
|
+
|
63
|
+
# @!method quarter
|
64
|
+
# Get the quarter this unit represents.
|
65
|
+
# Returns nil if no single quarter can be identified.
|
66
|
+
# @return [Array<Calendar::Quarter>, nil]
|
67
|
+
|
68
|
+
### Halves
|
69
|
+
|
70
|
+
# @!method halves
|
71
|
+
# Get a list of halves that fall within this unit.
|
72
|
+
# @return [Array<Calendar::Half>]
|
73
|
+
|
74
|
+
# @!method half
|
75
|
+
# Get the half this unit represents.
|
76
|
+
# Returns nil if no single half can be identified.
|
77
|
+
# @return [Array<Calendar::Half>, nil]
|
78
|
+
|
79
|
+
### Years
|
80
|
+
|
81
|
+
# @!method years
|
82
|
+
# Get a list of years that fall within this unit.
|
83
|
+
# @return [Array<Calendar::Year>]
|
84
|
+
|
85
|
+
# @!method year
|
86
|
+
# Get the year this unit represents.
|
87
|
+
# Returns nil if no single year can be identified.
|
88
|
+
# @return [Array<Calendar::Year>, nil]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|