schedulability 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 50fb75892fe34a90d09b2b053f07d7e60209aee6
4
+ data.tar.gz: fc229096b9d9395dbc2717194a4b6391440f6266
5
+ SHA512:
6
+ metadata.gz: 774433974b322f79241580ff4378173f009526cfad3b93a49bea994719fa8df0dbb15d0393bd9fe046c9a3a4ed6be9a842c1bc7abdd110449c763bb77276d2a5
7
+ data.tar.gz: 2cc54b3bfc288409a73eeea2c68881354766c7fde08c47aa77cfc41392fc104c402f131ea4efe3f3e2f4a706fecbecac652fdda05be4d17c6ca62400c57755c2
Binary file
@@ -0,0 +1 @@
1
+ ��k�ʚ���$���0� �������_�
@@ -0,0 +1,16 @@
1
+ # EditorConfig: http://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ # Unix-style newlines with a newline ending every file
7
+ [*]
8
+ end_of_line = lf
9
+ insert_final_newline = true
10
+
11
+ # Tab indentation
12
+ [**.*]
13
+ indent_style = tab
14
+
15
+ [**.rdoc]
16
+ indent_style = space
@@ -0,0 +1,9 @@
1
+ SimpleCov.start do
2
+ add_filter 'spec'
3
+ add_group "Tags" do |file|
4
+ file.filename =~ /tag.rb$/
5
+ end
6
+ add_group "Needing tests" do |file|
7
+ file.covered_percent < 90
8
+ end
9
+ end
@@ -0,0 +1,87 @@
1
+ 2015-12-30 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * .hgtags:
4
+ Backed out tag for v0.1.0; trying again
5
+ [342ac3d0b6db] [tip]
6
+
7
+ * Rakefile, schedulability.gemspec:
8
+ Explicitly set urls in the Hoespec, since Hoe can't read Markdown.
9
+ [19eb06e85937]
10
+
11
+ * .hgtags:
12
+ Added tag v0.1.0 for changeset 99d3bb8480ac
13
+ [c509bc778115]
14
+
15
+ * .hgsigs:
16
+ Added signature for changeset 39de155fb60f
17
+ [99d3bb8480ac]
18
+
19
+ * History.md, lib/schedulability.rb, lib/schedulability/schedule.rb:
20
+ Fix the version, history file, and some comments.
21
+ [39de155fb60f]
22
+
23
+ * .hgtags:
24
+ Backed out changeset 9def227667f5
25
+
26
+ Fixing the version and some little aesthetic things.
27
+ [c75030b1d915]
28
+
29
+ * .hgtags:
30
+ Added tag v0.11.0 for changeset efc2ba3917c1
31
+ [9def227667f5]
32
+
33
+ * .hgsigs:
34
+ Added signature for changeset 9a401a820265
35
+ [efc2ba3917c1]
36
+
37
+ * README.md, lib/schedulability/parser.rb,
38
+ lib/schedulability/schedule.rb,
39
+ spec/schedulability/schedule_spec.rb:
40
+ Implement negated periods; invert the meaning of empty schedule.
41
+ [9a401a820265] [github/master]
42
+
43
+ * lib/schedulability/parser.rb, lib/schedulability/schedule.rb,
44
+ spec/schedulability/schedule_spec.rb:
45
+ Implement boolean operations for the Schedule object.
46
+ [aaa0d5f6ed3f]
47
+
48
+ * lib/schedulability/parser.rb, spec/schedulability/schedule_spec.rb:
49
+ Fix the 12pm edge case for time parsing
50
+ [8687eaead89b]
51
+
52
+ * Manifest.txt, README.md, lib/schedulability.rb,
53
+ lib/schedulability/parser.rb, lib/schedulability/schedule.rb:
54
+ Break out schedule-parsing functions into a module.
55
+ [6ae39f6f0e6d]
56
+
57
+ * Manifest.txt, README.md, lib/schedulability/schedule.rb,
58
+ spec/schedulability/schedule_spec.rb:
59
+ Use counted week of month for `week` scale.
60
+ [bdf32f4fb2ef]
61
+
62
+ 2015-12-28 Michael Granger <ged@FaerieMUD.org>
63
+
64
+ * README.md, lib/schedulability.rb, lib/schedulability/mixins.rb,
65
+ lib/schedulability/schedule.rb, spec/helpers.rb,
66
+ spec/schedulability/schedule_spec.rb:
67
+ Finished up initial work on period parsing
68
+ [19fcd47d5dbc]
69
+
70
+ * Rakefile, schedulability.gemspec:
71
+ Add missing loggability dependency.
72
+ [8054ca4ee4a2]
73
+
74
+ * Manifest.txt, schedulability.gemspec:
75
+ Update build files, switch docs to Markdown.
76
+ [2b12bb7ae802]
77
+
78
+ 2015-12-26 Michael Granger <ged@FaerieMUD.org>
79
+
80
+ * .editorconfig, .gems, .hgignore, .hgsigs, .hgtags, .pryrc, .rvmrc,
81
+ .simplecov, .tm_properties, .travis.yml, Gemfile, History.md,
82
+ Manifest.txt, README.md, Rakefile, lib/schedulability.rb,
83
+ lib/schedulability/exceptions.rb, lib/schedulability/schedule.rb,
84
+ spec/helpers.rb, spec/schedulability/schedule_spec.rb,
85
+ spec/schedulability_spec.rb:
86
+ Initial commit
87
+ [eb1dd1197f1e]
@@ -0,0 +1,4 @@
1
+ ## v0.1.0 [2015-12-30] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ First release. Happy New Year!
4
+
@@ -0,0 +1,15 @@
1
+ .editorconfig
2
+ .simplecov
3
+ ChangeLog
4
+ History.md
5
+ Manifest.txt
6
+ README.md
7
+ Rakefile
8
+ lib/schedulability.rb
9
+ lib/schedulability/exceptions.rb
10
+ lib/schedulability/mixins.rb
11
+ lib/schedulability/parser.rb
12
+ lib/schedulability/schedule.rb
13
+ spec/helpers.rb
14
+ spec/schedulability/schedule_spec.rb
15
+ spec/schedulability_spec.rb
@@ -0,0 +1,236 @@
1
+ # schedulability
2
+
3
+ home
4
+ : http://deveiate.org/projects/schedulability
5
+
6
+ code
7
+ : http://bitbucket.org/ged/schedulability
8
+
9
+ docs
10
+ : http://deveiate.org/code/schedulability
11
+
12
+ github
13
+ : http://github.com/ged/schedulability
14
+
15
+
16
+ ## Description
17
+
18
+ Schedulability is a library for describing scheduled time. You can specify one or more periods of time using a simple syntax, then combine them to describe more-complex schedules.
19
+
20
+
21
+ ## Usage
22
+
23
+ Schedules are represented with Schedulability::Schedule objects, which are empty by default:
24
+
25
+ schedule = Schedulability::Schedule.new
26
+ # => #<Schedulability::Schedule:0x007ffcf2b982b8 (empty)>
27
+
28
+ An empty Schedule has no time restrictions, and will match any time.
29
+
30
+ To specify matching times, you'll need to construct a Schedule with one or more periods.
31
+
32
+
33
+ ### Periods
34
+
35
+ A schedule is specified as a String that contains a comma-separated list of period descriptions. The string `"never"` can be specified to explicitly create a schedule which will not match any time.
36
+
37
+ A period description is of the form
38
+
39
+ scale {range [range ...]} [scale {range [range ...]}]
40
+
41
+ Scale must be one of nine different scales (or their equivalent codes):
42
+
43
+ Scale | Scale | Valid Range Values
44
+ | Code |
45
+ -------+-------+------------------------------------------------------
46
+ year | yr | n where n is a 4-digit integer
47
+ month | mo | 1-12 or jan, feb, mar, apr, may, jun, jul,
48
+ | | aug, sep, oct, nov, dec
49
+ week | wk | 1-6
50
+ yday | yd | 1-366
51
+ mday | md | 1-31
52
+ wday | wd | 1-7 or sun, mon, tue, wed, thu, fri, sat
53
+ hour | hr | 0-23 or 12am 1am-11am 12noon 12pm 1pm-11pm
54
+ minute | min | 0-59
55
+ second | sec | 0-59
56
+
57
+ The same scale type may be specified multiple times. Additional scales are unioned with the ranges defined by previous scales of the same type in the same sub-period.
58
+
59
+ A `range` is an exclusive Time range in the form:
60
+
61
+ t
62
+ or
63
+
64
+ t1-t2
65
+
66
+ For two-value ranges, the range is defined as the period between `t1` and `t2`. Scales which are in
67
+ seconds granularity are exclusive of their end value, but the rest are inclusive. For example, `hr {9am-5pm}` means 9:00:00 AM until 4:59:59 PM, but `wd {Wed-Sat}` runs until one second before midnight on Saturday.
68
+
69
+ If the first value is larger than the second value (e.g. `min {20-10}`), the range wraps (except when the scale specification is `year`). For example, `month {9-2}` is the same as specifying `month {1-2 9-12}` or `month {1-2} month {9-12}` or even `month {Jan-Feb Sep-Dec}`.
70
+
71
+ The range specified by the single-value specification is implicitly between the value of `t` and its next sequential whole value. For example, `hr {9}` is the same as specifying `hr {9-10}`, `mday {15}` is the same as `mday {15-16}`, etc.
72
+
73
+ Neither extra whitespace or case are significant in a period description. Scales must be specified either in long form (`year`, `month`, `week`, etc.) or in code form (`yr`, `mo`, `wk`, etc.). Scale forms may be mixed in a period statement.
74
+
75
+ Values for week days can be abbreviated to two characters (`Wednesday` == `Wed` == `we`), and months can be abbreviated to three (`September` == `Sep`).
76
+
77
+
78
+ #### Period Examples
79
+
80
+ <dl>
81
+ <dt><code>wd {Mon-Fri} hr {9am-4pm}</code></dt>
82
+ <dd>Monday through Friday, 9am to 5pm</dd>
83
+
84
+ <dt><code>wd {Mon Wed Fri} hr {9am-4pm}, wd{Tue Thu} hr {9am-2pm}</code></dt>
85
+ <dd>Monday through Friday, 9:00:00am to 3:59:59pm on Monday, Wednesday, and Friday,
86
+ and 9:00:00am to 1:59:59pm on Tuesday and Thursday</dd>
87
+
88
+ <dt><code>wk {1 3 5} wd {Mon-Fri} hr {9am-5pm}</code></dt>
89
+ <dd>Mon-Fri 9:00:00am-4:59:59pm, on odd weeks in the month</dd>
90
+
91
+ <dt><code>month {Jan-Feb Nov-Dec}</code></dt>
92
+ <dd>During Winter in the northern hemisphere.</dd>
93
+
94
+ <dt><code>mo {Nov-Feb}</code></dt>
95
+ <dd>The same thing (Winter) as a wrapped range.</dd>
96
+
97
+ <dt><code>mo {jan feb nov dec}</code></dt>
98
+ <dd>Northern Winter as single months</dd>
99
+
100
+ <dt><code>mo {Jan Feb}, mo {Nov Dec}</code></dt>
101
+ <dd>Also Northern Winter.</dd>
102
+
103
+ <dt><code>mo {Jan Feb} mo {Nov Dec}</code></dt>
104
+ <dd>Northern Winter.</dd>
105
+
106
+ <dt><code>minute { 0-29 }</code></dt>
107
+ <dd>The first half of every hour.</dd>
108
+
109
+ <dt><code>hour { 12am-12pm }</code></dt>
110
+ <dd>During the morning.</dd>
111
+
112
+ <dt><code>sec {0-4 10-14 20-24 30-34 40-44 50-54}</code></dt>
113
+ <dd>Alternating 5-second periods every hour.</dd>
114
+
115
+ <dt><code>wd {1 3 5 7} min {0-29}, wd {2 4 6} min {30-59}</code></dt>
116
+ <dd>Every first half-hour on alternating week days, and the second half-hour the
117
+ rest of the week.</dd>
118
+ </dl>
119
+
120
+
121
+ ### Schedule Objects
122
+
123
+ Schedules are immutable after they're created, but they have mutator methods to
124
+ allow you to compose the schedule you want by combining them, or by using mutator
125
+ methods that return a changed copy of the original:
126
+
127
+ weekend = Schedulability::Schedule( "wd {Sat - Sun}" )
128
+ weekdays = Schedulability::Schedule( "wd {Mon - Fri}" )
129
+ work_hours = Schedulability::Schedule( "hour {9am - 5pm}" )
130
+ off_hours = Schedulability::Schedule( "hour {5pm - 9am}" )
131
+
132
+ ### Boolean operators
133
+ on_duty = weekdays | work_hours
134
+ off_duty = weekend + ( weekdays | off_hours )
135
+ # -or-
136
+ off_duty = ~on_duty
137
+
138
+ ### Exclusivity predicates
139
+ on_duty.overlaps?( off_duty )
140
+ # => false
141
+ on_duty.exclusive?( off_duty )
142
+ # => true
143
+
144
+ ### Time predicates
145
+ Time.now
146
+ # => 2015-12-22 12:05:44 -0800
147
+ on_duty.include?( Time.now )
148
+ # => true
149
+ on_duty.now?
150
+ # => true
151
+ off_duty.now?
152
+ # => false
153
+
154
+ ### Case equality (=== operator)
155
+ case Time.now
156
+ when on_duty
157
+ send_sms( "Stuff happened." )
158
+ when off_duty
159
+ send_email( "Stuff happened." )
160
+ end
161
+
162
+ ### Enumerators
163
+ on_duty.each_minute
164
+ # => #<Enumerator: ...>
165
+ on_duty.each_hour
166
+ # => #<Enumerator: ...>
167
+ on_duty.each_day
168
+ # => #<Enumerator: ...>
169
+
170
+
171
+ ## Prerequisites
172
+
173
+ * Ruby 2.2.0 or better
174
+
175
+
176
+ ## Installation
177
+
178
+ $ gem install schedulability
179
+
180
+
181
+ ## Contributing
182
+
183
+ You can check out the current development source with
184
+ [Mercurial](https://bitbucket.org/ged/schedulability), or if you prefer Git, via
185
+ [its Github mirror](https://github.com/ged/schedulability).
186
+
187
+ After checking out the source, run:
188
+
189
+ $ rake newb
190
+
191
+ This task will install any missing dependencies, run the tests/specs,
192
+ and generate the API documentation.
193
+
194
+
195
+ ## License
196
+
197
+ This library borrows much of its schedule description syntax and several implementation strategies from the Time::Period Perl module by Patrick Ryan, used under the terms of the Perl Artistic License.
198
+
199
+ Patrick Ryan <perl@pryan.org> wrote it.
200
+ Paul Boyd <pboyd@cpan.org> fixed a few bugs.
201
+
202
+ Copyright (c) 1997 Patrick Ryan. All rights reserved. This Perl
203
+ module uses the conditions given by Perl. This module may only
204
+ be distributed and or modified under the conditions given by Perl.
205
+
206
+ The rest is:
207
+
208
+ Copyright (c) 2015, Michael Granger and Mahlon E. Smith
209
+ All rights reserved.
210
+
211
+ Redistribution and use in source and binary forms, with or without
212
+ modification, are permitted provided that the following conditions are met:
213
+
214
+ * Redistributions of source code must retain the above copyright notice,
215
+ this list of conditions and the following disclaimer.
216
+
217
+ * Redistributions in binary form must reproduce the above copyright notice,
218
+ this list of conditions and the following disclaimer in the documentation
219
+ and/or other materials provided with the distribution.
220
+
221
+ * Neither the name of the author/s, nor the names of the project's
222
+ contributors may be used to endorse or promote products derived from this
223
+ software without specific prior written permission.
224
+
225
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
226
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
227
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
228
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
229
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
230
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
231
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
232
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
233
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
234
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
235
+
236
+
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'rake/clean'
4
+
5
+ begin
6
+ require 'hoe'
7
+ rescue LoadError
8
+ abort "This Rakefile requires 'hoe' (gem install hoe)"
9
+ end
10
+
11
+ GEMSPEC = 'schedulability.gemspec'
12
+
13
+ Hoe.plugin :mercurial
14
+ Hoe.plugin :signing
15
+ Hoe.plugin :deveiate
16
+
17
+ Hoe.plugins.delete :rubyforge
18
+
19
+ hoespec = Hoe.spec 'schedulability' do
20
+ self.readme_file = 'README.md'
21
+ self.history_file = 'History.md'
22
+ self.extra_rdoc_files = FileList[ '*.md' ]
23
+ self.urls = {
24
+ home: 'http://deveiate.org/projects/schedulability',
25
+ code: 'http://bitbucket.org/ged/schedulability',
26
+ docs: 'http://deveiate.org/code/schedulability',
27
+ github: 'http://github.com/ged/schedulability',
28
+ }
29
+
30
+ self.developer 'Michael Granger', 'ged@FaerieMUD.org'
31
+ self.developer 'Mahlon E. Smith', 'mahlon@martini.nu'
32
+
33
+ self.dependency 'loggability', '~> 0.11'
34
+
35
+ self.dependency 'timecop', '~> 0.8', :developer
36
+ self.dependency 'hoe-deveiate', '~> 0.4', :developer
37
+ self.dependency 'hoe-bundler', '~> 1.2', :developer
38
+ self.dependency 'simplecov', '~> 0.7', :developer
39
+
40
+ self.license "BSD-3-Clause"
41
+ self.require_ruby_version( '>=2.2.0' )
42
+ self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
43
+ self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
44
+
45
+ self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
46
+ end
47
+
48
+ ENV['VERSION'] ||= hoespec.spec.version.to_s
49
+
50
+ # Ensure the specs pass before checking in
51
+ task 'hg:precheckin' => [ :check_history, :check_manifest, :gemspec, :spec ]
52
+
53
+
54
+ desc "Build a coverage report"
55
+ task :coverage do
56
+ ENV["COVERAGE"] = 'yes'
57
+ Rake::Task[:spec].invoke
58
+ end
59
+ CLOBBER.include( 'coverage' )
60
+
61
+
62
+ # Use the fivefish formatter for docs generated from development checkout
63
+ if File.directory?( '.hg' )
64
+ require 'rdoc/task'
65
+
66
+ Rake::Task[ 'docs' ].clear
67
+ RDoc::Task.new( 'docs' ) do |rdoc|
68
+ rdoc.main = "README.md"
69
+ rdoc.rdoc_files.include( "*.rdoc", "*.md", "ChangeLog", "lib/**/*.rb" )
70
+ rdoc.generator = :sixfish
71
+ rdoc.title = 'Schedulability'
72
+ rdoc.rdoc_dir = 'doc'
73
+ end
74
+ end
75
+
76
+ task :gemspec => GEMSPEC
77
+ file GEMSPEC => __FILE__
78
+ task GEMSPEC do |task|
79
+ spec = $hoespec.spec
80
+ spec.files.delete( '.gemtest' )
81
+ spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
82
+ File.open( task.name, 'w' ) do |fh|
83
+ fh.write( spec.to_ruby )
84
+ end
85
+ end
86
+
87
+ CLOBBER.include( GEMSPEC.to_s )
88
+