taskloop 0.1.0 → 0.3.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/Gemfile.lock +1 -1
- data/README-cn.md +273 -0
- data/README.md +283 -12
- data/lib/taskloop/command/deploy.rb +3 -4
- data/lib/taskloop/command/env.rb +5 -5
- data/lib/taskloop/command/init.rb +13 -8
- data/lib/taskloop/command/list.rb +10 -8
- data/lib/taskloop/dsl/dsl.rb +16 -5
- data/lib/taskloop/extension/integer_extension.rb +0 -4
- data/lib/taskloop/rules/after_scope_rule.rb +38 -45
- data/lib/taskloop/rules/before_scope_rule.rb +38 -45
- data/lib/taskloop/rules/between_scope_rule.rb +53 -60
- data/lib/taskloop/rules/boundary_rule.rb +21 -0
- data/lib/taskloop/rules/date_list_rule.rb +0 -4
- data/lib/taskloop/rules/default_rule.rb +0 -4
- data/lib/taskloop/rules/end_point_boundary_rule.rb +21 -0
- data/lib/taskloop/rules/interval_rule.rb +0 -4
- data/lib/taskloop/rules/loop_rule.rb +0 -4
- data/lib/taskloop/rules/rule.rb +3 -5
- data/lib/taskloop/rules/specific_rule.rb +25 -32
- data/lib/taskloop/rules/start_point_boundary_rule.rb +21 -0
- data/lib/taskloop/rules/time_list_rule.rb +0 -4
- data/lib/taskloop/task/task.rb +20 -10
- data/lib/taskloop/task/task_property.rb +128 -45
- data/lib/taskloop/version.rb +1 -1
- data/sig/integer.rbs +11 -0
- data/sig/string.rbs +7 -0
- data/sig/task_loop/after_scope_rule.rbs +11 -0
- data/sig/task_loop/before_scope_rule.rbs +11 -0
- data/sig/task_loop/between_scope_rule.rbs +14 -0
- data/sig/task_loop/boundary_rule.rbs +9 -0
- data/sig/task_loop/date_list_rule.rbs +11 -0
- data/sig/task_loop/default_rule.rbs +8 -0
- data/sig/task_loop/deploy.rbs +18 -0
- data/sig/task_loop/dsl.rbs +25 -0
- data/sig/task_loop/end_point_boundary_rule.rbs +9 -0
- data/sig/task_loop/env.rbs +13 -0
- data/sig/task_loop/init.rbs +5 -0
- data/sig/task_loop/interval_rule.rbs +9 -0
- data/sig/task_loop/launch.rbs +12 -0
- data/sig/task_loop/list.rbs +9 -0
- data/sig/task_loop/log.rbs +11 -0
- data/sig/task_loop/loop_rule.rbs +9 -0
- data/sig/task_loop/proj_task_list.rbs +5 -0
- data/sig/task_loop/rule.rbs +11 -0
- data/sig/task_loop/run.rbs +11 -0
- data/sig/task_loop/scope_rule.rbs +9 -0
- data/sig/task_loop/shutdown.rbs +7 -0
- data/sig/task_loop/specific_rule.rbs +11 -0
- data/sig/task_loop/start_point_boundary_rule.rbs +9 -0
- data/sig/task_loop/task.rbs +34 -0
- data/sig/task_loop/task_data_file.rbs +23 -0
- data/sig/task_loop/task_property.rbs +83 -0
- data/sig/task_loop/time_list_rule.rbs +13 -0
- data/sig/task_loop/undeploy.rbs +7 -0
- metadata +36 -2
@@ -2,63 +2,56 @@ module TaskLoop
|
|
2
2
|
|
3
3
|
class SpecificRule < Rule
|
4
4
|
|
5
|
-
attr_accessor :
|
5
|
+
attr_accessor :values
|
6
6
|
|
7
|
-
def initialize(unit,
|
7
|
+
def initialize(unit, values)
|
8
8
|
super unit
|
9
|
-
|
9
|
+
unless values != nil && values.length > 0
|
10
|
+
raise ArgumentError, "values arguments need at least one value."
|
11
|
+
end
|
12
|
+
|
13
|
+
@values = values
|
10
14
|
end
|
11
15
|
|
12
|
-
def
|
13
|
-
if
|
14
|
-
return Task::
|
15
|
-
end
|
16
|
-
if (Task::WEEK.has_key?(@value))
|
17
|
-
return Task::WEEK[@value]
|
18
|
-
end
|
19
|
-
if (Task::MONTH.has_key?(@value))
|
20
|
-
return Task::MONTH[@value]
|
16
|
+
def values_values
|
17
|
+
if @unit == :week
|
18
|
+
return @values.map { |key| Task::WEEK[key] }
|
21
19
|
end
|
22
20
|
|
23
|
-
|
24
|
-
return
|
21
|
+
if @unit == :day
|
22
|
+
return @values.map { |key| Task::DAY[key] }
|
25
23
|
end
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
def is_week_value?
|
31
|
-
if @unit == :day && Task::WEEK.has_key?(@value)
|
32
|
-
return true
|
25
|
+
if @unit == :month
|
26
|
+
return @values.map { |key| Task::MONTH[key] }
|
33
27
|
end
|
34
|
-
|
28
|
+
|
29
|
+
return @values
|
35
30
|
end
|
36
31
|
|
37
32
|
def is_conform_rule?(last_exec_time)
|
38
33
|
current = Time.now
|
39
|
-
|
34
|
+
vals = values_values
|
40
35
|
result = false
|
41
36
|
case @unit
|
42
37
|
when :year then
|
43
|
-
result = current.year
|
38
|
+
result = vals.include?(current.year)
|
44
39
|
when :month then
|
45
|
-
result = current.month
|
40
|
+
result = vals.include?(current.month)
|
41
|
+
when :week then
|
42
|
+
result = vals.include?(current.wday)
|
46
43
|
when :day then
|
47
|
-
|
48
|
-
result = current.wday == (value % TaskLoop::WEEK_BASE)
|
49
|
-
else
|
50
|
-
result = current.day == value
|
51
|
-
end
|
44
|
+
result = vals.include?(current.day)
|
52
45
|
when :hour then
|
53
|
-
result = current.hour
|
46
|
+
result = vals.include?(current.hour)
|
54
47
|
when :minute then
|
55
|
-
result = current.min
|
48
|
+
result = vals.include?(current.min)
|
56
49
|
end
|
57
50
|
return result
|
58
51
|
end
|
59
52
|
|
60
53
|
def desc
|
61
|
-
super + "; specific: #{
|
54
|
+
super + "; specific: #{values.join(', ')}"
|
62
55
|
end
|
63
56
|
end
|
64
57
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module TaskLoop
|
2
|
+
class StartPointBoundaryRule < BoundaryRule
|
3
|
+
attr_accessor :value
|
4
|
+
def initialize(unit, value)
|
5
|
+
super unit, :start
|
6
|
+
@value = value
|
7
|
+
end
|
8
|
+
|
9
|
+
def is_conform_rule?(last_exec_time)
|
10
|
+
current = Time.now.to_i
|
11
|
+
date_format = "%Y-%m-%d %H:%M:%S"
|
12
|
+
date_object = Time.strptime(value, date_format)
|
13
|
+
start_time = date_object.to_i
|
14
|
+
return current >= start_time
|
15
|
+
end
|
16
|
+
|
17
|
+
def desc
|
18
|
+
super + " from #{value}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/taskloop/task/task.rb
CHANGED
@@ -19,7 +19,7 @@ module TaskLoop
|
|
19
19
|
@@tasklist = value
|
20
20
|
end
|
21
21
|
|
22
|
-
def initialize
|
22
|
+
def initialize
|
23
23
|
yield self
|
24
24
|
check = true
|
25
25
|
unless @name
|
@@ -73,20 +73,20 @@ module TaskLoop
|
|
73
73
|
def check_rule_conflict?
|
74
74
|
result = true
|
75
75
|
# check year/month/day with date, they cannot be set at the same time
|
76
|
-
if
|
76
|
+
if has_ymd? && has_date?
|
77
77
|
puts "Error: #{desc} => <year/month/day> and <date> cannot be set at the same time.".ansi.red
|
78
78
|
result = false
|
79
79
|
end
|
80
80
|
|
81
81
|
# check hour/minute with time, they cannot be set at the same time
|
82
|
-
if
|
82
|
+
if has_hm? && has_time?
|
83
83
|
puts "Error: #{desc} => <hour/minute> and <time> cannot be set at the same time.".ansi.red
|
84
84
|
result = false
|
85
85
|
end
|
86
86
|
|
87
87
|
# check rule type
|
88
88
|
|
89
|
-
if
|
89
|
+
if has_ymd? && has_hm?
|
90
90
|
# check minute/hour/day/month/year. Get the last IntervalRule, than check if there is SpecificRule or ScopeRule before
|
91
91
|
rules = [minute, hour, day, month, year]
|
92
92
|
rIdx = rules.rindex { |rule| rule.is_a?(IntervalRule) }
|
@@ -98,13 +98,10 @@ module TaskLoop
|
|
98
98
|
break
|
99
99
|
end
|
100
100
|
end
|
101
|
-
|
102
101
|
end
|
103
|
-
|
104
|
-
|
105
102
|
end
|
106
103
|
|
107
|
-
if
|
104
|
+
if has_ymd? && has_time?
|
108
105
|
# check year/month/day with time, YMD can not have IntervalRule
|
109
106
|
rules = [day, month, year]
|
110
107
|
hasInterval = rules.any? { |rule| rule.is_a?(IntervalRule) }
|
@@ -114,11 +111,11 @@ module TaskLoop
|
|
114
111
|
end
|
115
112
|
end
|
116
113
|
|
117
|
-
if
|
114
|
+
if has_date? && has_hm?
|
118
115
|
# it's ok
|
119
116
|
end
|
120
117
|
|
121
|
-
if
|
118
|
+
if has_date? && has_time?
|
122
119
|
# it's ok
|
123
120
|
end
|
124
121
|
|
@@ -129,6 +126,7 @@ module TaskLoop
|
|
129
126
|
last_exec_time = last_time
|
130
127
|
|
131
128
|
result = true
|
129
|
+
result &&= check_boundary_rule?(last_exec_time)
|
132
130
|
result &&= check_interval_rule?(last_exec_time)
|
133
131
|
result &&= check_scope_rule?(last_exec_time)
|
134
132
|
result &&= check_specific_fule?(last_exec_time)
|
@@ -176,6 +174,9 @@ module TaskLoop
|
|
176
174
|
if minute.is_a?(ScopeRule)
|
177
175
|
result &&= minute.is_conform_rule?(last_exec_time)
|
178
176
|
end
|
177
|
+
if week.is_a?(ScopeRule)
|
178
|
+
result &&= week.is_conform_rule?(last_exec_time)
|
179
|
+
end
|
179
180
|
return result
|
180
181
|
end
|
181
182
|
|
@@ -196,6 +197,9 @@ module TaskLoop
|
|
196
197
|
if minute.is_a?(SpecificRule)
|
197
198
|
result &&= minute.is_conform_rule?(last_exec_time)
|
198
199
|
end
|
200
|
+
if week.is_a?(SpecificRule)
|
201
|
+
result &&= week.is_conform_rule?(last_exec_time)
|
202
|
+
end
|
199
203
|
if time.is_a?(TimeListRule)
|
200
204
|
result &&= time.is_conform_rule?(last_exec_time)
|
201
205
|
end
|
@@ -215,6 +219,12 @@ module TaskLoop
|
|
215
219
|
return result
|
216
220
|
end
|
217
221
|
|
222
|
+
private def check_boundary_rule?(last_exec_time)
|
223
|
+
result = true
|
224
|
+
result &&= start_point.is_conform_rule?(last_exec_time)
|
225
|
+
result &&= end_point.is_conform_rule?(last_exec_time)
|
226
|
+
return result
|
227
|
+
end
|
218
228
|
|
219
229
|
#################################
|
220
230
|
# Sha1 and description
|
@@ -1,5 +1,14 @@
|
|
1
1
|
module TaskLoop
|
2
2
|
module TaskProperty
|
3
|
+
WEEK = {
|
4
|
+
:Sun => 0,
|
5
|
+
:Mon => 1,
|
6
|
+
:Tue => 2,
|
7
|
+
:Wed => 3,
|
8
|
+
:Thu => 4,
|
9
|
+
:Fri => 5,
|
10
|
+
:Sat => 6,
|
11
|
+
}
|
3
12
|
|
4
13
|
MONTH = {
|
5
14
|
:Jan => 1,
|
@@ -27,17 +36,6 @@ module TaskLoop
|
|
27
36
|
:mon12 => 12,
|
28
37
|
}
|
29
38
|
|
30
|
-
WEEK_BASE = 10000
|
31
|
-
WEEK = {
|
32
|
-
:Sun => 10000,
|
33
|
-
:Mon => 10001,
|
34
|
-
:Tue => 10002,
|
35
|
-
:Wed => 10003,
|
36
|
-
:Thu => 10004,
|
37
|
-
:Fri => 10005,
|
38
|
-
:Sat => 10006,
|
39
|
-
}
|
40
|
-
|
41
39
|
DAY = {
|
42
40
|
:day1 => 1,
|
43
41
|
:day2 => 2,
|
@@ -78,11 +76,35 @@ module TaskLoop
|
|
78
76
|
attr_accessor :path
|
79
77
|
|
80
78
|
#################################
|
81
|
-
#
|
79
|
+
# Week Property
|
80
|
+
# specific syntax
|
81
|
+
# - at
|
82
|
+
# - example: at :Mon, :Tue, :Fri
|
83
|
+
# scope syntax
|
84
|
+
# - before
|
85
|
+
# - example: before :Mon
|
86
|
+
# - between
|
87
|
+
# - example: between :Mon, :Fri
|
88
|
+
# - after
|
89
|
+
# 0 example: after :Tue
|
82
90
|
#################################
|
91
|
+
def week=(rule)
|
92
|
+
unless rule.is_a?(SpecificRule) || rule.is_a?(ScopeRule)
|
93
|
+
raise TypeError, "the rule of week must be SpecificRule or ScopeRule or IntervalRule"
|
94
|
+
end
|
95
|
+
@week = rule
|
96
|
+
@week.unit = :week
|
97
|
+
end
|
98
|
+
|
99
|
+
def week
|
100
|
+
@week ||= DefaultRule.new(:week)
|
101
|
+
end
|
102
|
+
|
103
|
+
#################################
|
104
|
+
# Year Property
|
83
105
|
# specific syntax
|
84
106
|
# - of
|
85
|
-
# - example:
|
107
|
+
# - example: at 2024, 2025 ...
|
86
108
|
# interval syntax
|
87
109
|
# - interval
|
88
110
|
# - example: interval 1.year
|
@@ -92,12 +114,12 @@ module TaskLoop
|
|
92
114
|
# - between
|
93
115
|
# - example: between 2025, 2026
|
94
116
|
# - after
|
95
|
-
# -
|
117
|
+
# - example: after 2023
|
118
|
+
#################################
|
96
119
|
def year=(rule)
|
97
|
-
unless rule.is_a?(
|
98
|
-
raise TypeError, "the rule of year must be
|
120
|
+
unless rule.is_a?(SpecificRule) || rule.is_a?(ScopeRule) || rule.is_a?(IntervalRule)
|
121
|
+
raise TypeError, "the rule of year must be SpecificRule or ScopeRule or IntervalRule"
|
99
122
|
end
|
100
|
-
|
101
123
|
@year = rule
|
102
124
|
@year.unit = :year
|
103
125
|
end
|
@@ -106,10 +128,12 @@ module TaskLoop
|
|
106
128
|
@year ||= DefaultRule.new(:year)
|
107
129
|
end
|
108
130
|
|
131
|
+
#################################
|
132
|
+
# Month Property
|
109
133
|
# specific syntax
|
110
|
-
# -
|
111
|
-
# - example:
|
112
|
-
# - example:
|
134
|
+
# - at
|
135
|
+
# - example: at :Jan, :Feb, :Mar, :Apr, :Jun, :Jul, :Aug, :Sep, :Oct, :Nov, :Dec;
|
136
|
+
# - example: at :month1, :month2, :month3 ...
|
113
137
|
# interval syntax
|
114
138
|
# - every
|
115
139
|
# - example: interval 1.month
|
@@ -120,9 +144,10 @@ module TaskLoop
|
|
120
144
|
# - example: between 2025, 2026
|
121
145
|
# - after
|
122
146
|
# - examle: after 2023
|
147
|
+
#################################
|
123
148
|
def month=(rule)
|
124
|
-
unless rule.is_a?(
|
125
|
-
raise TypeError, "the rule of month must be
|
149
|
+
unless rule.is_a?(SpecificRule) || rule.is_a?(ScopeRule) || rule.is_a?(IntervalRule)
|
150
|
+
raise TypeError, "the rule of month must be SpecificRule or ScopeRule or IntervalRule"
|
126
151
|
end
|
127
152
|
@month = rule
|
128
153
|
@month.unit = :month
|
@@ -132,10 +157,11 @@ module TaskLoop
|
|
132
157
|
@month||= DefaultRule.new(:month)
|
133
158
|
end
|
134
159
|
|
160
|
+
#################################
|
161
|
+
# Day Property
|
135
162
|
# specific syntax
|
136
|
-
# -
|
137
|
-
# - example:
|
138
|
-
# - example: on :day1, :day2, :day3;
|
163
|
+
# - at
|
164
|
+
# - example: at :day1, :day2, :day3 ...
|
139
165
|
# interval syntax
|
140
166
|
# - interval
|
141
167
|
# - example: interval 10.day
|
@@ -147,9 +173,10 @@ module TaskLoop
|
|
147
173
|
# - example: between :Mon, :Fri
|
148
174
|
# - after
|
149
175
|
# - example: after :day10
|
176
|
+
#################################
|
150
177
|
def day=(rule)
|
151
|
-
unless rule.is_a?(
|
152
|
-
raise TypeError, "the rule of day must be
|
178
|
+
unless rule.is_a?(SpecificRule) || rule.is_a?(ScopeRule) || rule.is_a?(IntervalRule)
|
179
|
+
raise TypeError, "the rule of day must be SpecificRule or ScopeRule or IntervalRule"
|
153
180
|
end
|
154
181
|
@day = rule
|
155
182
|
@day.unit = :day
|
@@ -159,9 +186,11 @@ module TaskLoop
|
|
159
186
|
@day ||= DefaultRule.new(:day)
|
160
187
|
end
|
161
188
|
|
189
|
+
#################################
|
190
|
+
# Hour Property
|
162
191
|
# specific syntax
|
163
192
|
# - at
|
164
|
-
# - example: at 10
|
193
|
+
# - example: at 10, 11, 13 ...
|
165
194
|
# interval syntax
|
166
195
|
# - interval
|
167
196
|
# - example: interval 10.hour
|
@@ -172,9 +201,10 @@ module TaskLoop
|
|
172
201
|
# - example: between 10, 12
|
173
202
|
# - after
|
174
203
|
# - example: after 11
|
204
|
+
#################################
|
175
205
|
def hour=(rule)
|
176
|
-
unless rule.is_a?(
|
177
|
-
raise TypeError, "the rule of hour must be
|
206
|
+
unless rule.is_a?(SpecificRule) || rule.is_a?(ScopeRule) || rule.is_a?(IntervalRule)
|
207
|
+
raise TypeError, "the rule of hour must be SpecificRule or ScopeRule or IntervalRule"
|
178
208
|
end
|
179
209
|
@hour = rule
|
180
210
|
@hour.unit = :hour
|
@@ -184,19 +214,24 @@ module TaskLoop
|
|
184
214
|
@hour ||= DefaultRule.new(:hour)
|
185
215
|
end
|
186
216
|
|
217
|
+
#################################
|
218
|
+
# Minute Property
|
187
219
|
# specific syntax
|
188
220
|
# - at
|
189
|
-
# - example: at 59
|
221
|
+
# - example: at 59, 23 ...
|
190
222
|
# interval syntax
|
191
223
|
# - interval
|
192
224
|
# - example: interval 5.minute
|
225
|
+
# scope syntax
|
226
|
+
# - before
|
227
|
+
# - example: before 9
|
228
|
+
# - between
|
229
|
+
# - example: between 10, 12
|
230
|
+
# - after
|
231
|
+
# - example: after 11
|
193
232
|
def minute=(rule)
|
194
|
-
unless rule.is_a?(
|
195
|
-
raise TypeError, "the rule of minute must be
|
196
|
-
end
|
197
|
-
|
198
|
-
if rule.is_a?(ScopeRule)
|
199
|
-
raise TypeError, "the rule of minute cannot be a class or subclass of ScopeRule"
|
233
|
+
unless rule.is_a?(SpecificRule) || rule.is_a?(ScopeRule) || rule.is_a?(IntervalRule)
|
234
|
+
raise TypeError, "the rule of minute must be SpecificRule or ScopeRule or IntervalRule"
|
200
235
|
end
|
201
236
|
@minute = rule
|
202
237
|
@minute.unit = :minute
|
@@ -206,12 +241,15 @@ module TaskLoop
|
|
206
241
|
@minute ||= DefaultRule.new(:minute)
|
207
242
|
end
|
208
243
|
|
244
|
+
#################################
|
245
|
+
# Loop Property
|
209
246
|
# loop syntax
|
210
247
|
# - loop
|
211
248
|
# - example: loop 5.times
|
249
|
+
#################################
|
212
250
|
def loop=(rule)
|
213
|
-
unless rule.is_a?(
|
214
|
-
raise TypeError, "the rule of loop must be
|
251
|
+
unless rule.is_a?(LoopRule)
|
252
|
+
raise TypeError, "the rule of loop must be LoopRule"
|
215
253
|
end
|
216
254
|
|
217
255
|
@loop = rule
|
@@ -221,12 +259,15 @@ module TaskLoop
|
|
221
259
|
@loop ||= DefaultRule.new(:loop)
|
222
260
|
end
|
223
261
|
|
262
|
+
#################################
|
263
|
+
# Time Property
|
224
264
|
# time list syntax
|
225
265
|
# - time
|
226
266
|
# - example: time "10:10:30", "9:10:20", "20:10:20"
|
267
|
+
#################################
|
227
268
|
def time=(rule)
|
228
269
|
unless rule.is_a?(TimeListRule)
|
229
|
-
raise TypeError, "the rule of time must be
|
270
|
+
raise TypeError, "the rule of time must be TimeListRule"
|
230
271
|
end
|
231
272
|
|
232
273
|
@time = rule
|
@@ -236,12 +277,15 @@ module TaskLoop
|
|
236
277
|
@time ||= DefaultRule.new(:time)
|
237
278
|
end
|
238
279
|
|
280
|
+
#################################
|
281
|
+
# Date Property
|
239
282
|
# date list syntax
|
240
283
|
# - date
|
241
284
|
# - example: date "2023-10-10", "2013-10-11", "2023-11-10"
|
285
|
+
#################################
|
242
286
|
def date=(rule)
|
243
287
|
unless rule.is_a?(DateListRule)
|
244
|
-
raise TypeError, "the rule of time must be
|
288
|
+
raise TypeError, "the rule of time must be DateListRule"
|
245
289
|
end
|
246
290
|
|
247
291
|
@date = rule
|
@@ -251,22 +295,61 @@ module TaskLoop
|
|
251
295
|
@date ||= DefaultRule.new(:date)
|
252
296
|
end
|
253
297
|
|
298
|
+
#################################
|
299
|
+
# StartPoint Property
|
300
|
+
# boundary syntax
|
301
|
+
# - start_point
|
302
|
+
# - example: from "2023-10-11 10:00:00"
|
303
|
+
#################################
|
304
|
+
def start_point=(rule)
|
305
|
+
unless rule.is_a?(StartPointBoundaryRule)
|
306
|
+
raise TypeError, "the rule of start_point must be StartPointBoundaryRule"
|
307
|
+
end
|
308
|
+
@start_point = rule
|
309
|
+
@start_point.unit = :full
|
310
|
+
end
|
311
|
+
|
312
|
+
def start_point
|
313
|
+
@start_point ||= DefaultRule.new(:full)
|
314
|
+
end
|
315
|
+
|
316
|
+
#################################
|
317
|
+
# EndPoint Property
|
318
|
+
# boundary syntax
|
319
|
+
# - end_point
|
320
|
+
# - example: to "2023-10-11 10:00:00"
|
321
|
+
#################################
|
322
|
+
def end_point=(rule)
|
323
|
+
unless rule.is_a?(EndPointBoundaryRule)
|
324
|
+
raise TypeError, "the rule of end_point must be EndPointBoundaryRule"
|
325
|
+
end
|
326
|
+
@end_point = rule
|
327
|
+
@end_point.unit = :full
|
328
|
+
end
|
329
|
+
|
330
|
+
def end_point
|
331
|
+
@end_point ||= DefaultRule.new(:full)
|
332
|
+
end
|
333
|
+
|
254
334
|
#################################
|
255
335
|
# Help Methods
|
256
336
|
#################################
|
257
|
-
def
|
337
|
+
def has_week?
|
338
|
+
!week.is_a?(DefaultRule)
|
339
|
+
end
|
340
|
+
def has_date?
|
258
341
|
!date.is_a?(DefaultRule)
|
259
342
|
end
|
260
343
|
|
261
|
-
def
|
344
|
+
def has_time?
|
262
345
|
!time.is_a?(DefaultRule)
|
263
346
|
end
|
264
347
|
|
265
|
-
def
|
348
|
+
def has_ymd?
|
266
349
|
[year, month, day].any? { |rule| !rule.is_a?(DefaultRule) }
|
267
350
|
end
|
268
351
|
|
269
|
-
def
|
352
|
+
def has_hm?
|
270
353
|
[hour, minute].any? { |rule| !rule.is_a?(DefaultRule) }
|
271
354
|
end
|
272
355
|
|
data/lib/taskloop/version.rb
CHANGED
data/sig/integer.rbs
ADDED
data/sig/string.rbs
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module TaskLoop
|
2
|
+
class BetweenScopeRule
|
3
|
+
attr_accessor left: [Symbol | Integer]
|
4
|
+
attr_accessor right: [Symbol | Integer]
|
5
|
+
|
6
|
+
def desc: () -> String
|
7
|
+
|
8
|
+
def is_conform_rule?: (Time) -> bool
|
9
|
+
|
10
|
+
def left_value: () -> Integer
|
11
|
+
|
12
|
+
def right_value: () -> Integer
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module TaskLoop
|
2
|
+
class Deploy
|
3
|
+
def run: () -> void
|
4
|
+
def register_taskfile_dir_if_needed: () -> void
|
5
|
+
|
6
|
+
def tasklist: () -> Array[Task]
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def clean_loopfile_if_needed: () -> void
|
11
|
+
|
12
|
+
def deploy_lint?: () -> bool
|
13
|
+
|
14
|
+
def eval_taskfile: (String) -> void
|
15
|
+
|
16
|
+
def generate_taskfile_deploy: () -> void
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module TaskLoop
|
2
|
+
module DSL
|
3
|
+
def after: ([Symbol | Integer]) -> AfterScopeRule
|
4
|
+
|
5
|
+
def at: (*[Symbol | Integer]) -> SpecificRule
|
6
|
+
|
7
|
+
def before: ([Symbol | Integer]) -> BeforeScopeRule
|
8
|
+
|
9
|
+
def between: ([Symbol | Integer], [Symbol | Integer]) -> BetweenScopeRule
|
10
|
+
|
11
|
+
def date: (*String) -> DateListRule
|
12
|
+
|
13
|
+
def env: (String, String) -> void
|
14
|
+
|
15
|
+
def from: (String) -> StartPointBoundaryRule
|
16
|
+
|
17
|
+
def interval: (Integer) -> IntervalRule
|
18
|
+
|
19
|
+
def loop: (Integer) -> LoopRule
|
20
|
+
|
21
|
+
def time: (*String) -> TimeListRule
|
22
|
+
|
23
|
+
def to: (String) -> EndPointBoundaryRule
|
24
|
+
end
|
25
|
+
end
|