runt 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/.gitignore +19 -0
  2. data/.travis.yml +5 -0
  3. data/{CHANGES → CHANGES.txt} +24 -8
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -44
  6. data/README.md +79 -0
  7. data/Rakefile +6 -119
  8. data/doc/tutorial_schedule.md +365 -0
  9. data/doc/tutorial_sugar.md +170 -0
  10. data/doc/tutorial_te.md +155 -0
  11. data/lib/runt.rb +36 -21
  12. data/lib/runt/dprecision.rb +4 -2
  13. data/lib/runt/pdate.rb +101 -95
  14. data/lib/runt/schedule.rb +18 -0
  15. data/lib/runt/sugar.rb +41 -9
  16. data/lib/runt/temporalexpression.rb +246 -30
  17. data/lib/runt/version.rb +3 -0
  18. data/runt.gemspec +24 -0
  19. data/site/.cvsignore +1 -0
  20. data/site/dcl-small.gif +0 -0
  21. data/site/index-rubforge-www.html +72 -0
  22. data/site/index.html +75 -60
  23. data/site/runt-logo.gif +0 -0
  24. data/site/runt-logo.psd +0 -0
  25. data/test/baseexpressiontest.rb +10 -8
  26. data/test/combinedexpressionstest.rb +166 -158
  27. data/test/daterangetest.rb +4 -6
  28. data/test/diweektest.rb +32 -32
  29. data/test/dprecisiontest.rb +2 -4
  30. data/test/everytetest.rb +6 -0
  31. data/test/expressionbuildertest.rb +2 -3
  32. data/test/icalendartest.rb +3 -6
  33. data/test/minitest_helper.rb +7 -0
  34. data/test/pdatetest.rb +21 -6
  35. data/test/redaytest.rb +3 -0
  36. data/test/reyeartest.rb +1 -1
  37. data/test/runttest.rb +5 -8
  38. data/test/scheduletest.rb +13 -14
  39. data/test/sugartest.rb +28 -6
  40. data/test/{spectest.rb → temporaldatetest.rb} +14 -4
  41. data/test/{rspectest.rb → temporalrangetest.rb} +4 -4
  42. data/test/test_runt.rb +11 -0
  43. data/test/weekintervaltest.rb +106 -0
  44. metadata +161 -116
  45. data/README +0 -106
  46. data/doc/tutorial_schedule.rdoc +0 -393
  47. data/doc/tutorial_sugar.rdoc +0 -143
  48. data/doc/tutorial_te.rdoc +0 -190
  49. data/setup.rb +0 -1331
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'baseexpressiontest'
4
+
5
+ class WeekIntervalTest < BaseExpressionTest
6
+
7
+ def test_every_other_week
8
+ expr = WeekInterval.new(Date.new(2013,4,23),2)
9
+ good_dates = [Date.new(2013,4,21), Date.new(2013,4,27),Date.new(2013,5,8)]
10
+ good_dates.each do |date|
11
+ assert(expr.include?(date),"Expr<#{expr}> should include #{date.ctime}")
12
+ end
13
+ bad_dates = [Date.new(2013,4,20), Date.new(2013,4,28)]
14
+ bad_dates.each do |date|
15
+ assert(!expr.include?(date),"Expr<#{expr}> should not include #{date.ctime}")
16
+ end
17
+ end
18
+
19
+ def test_every_third_week_spans_a_year
20
+ expr = WeekInterval.new(Date.new(2013,12,25),3)
21
+ good_dates = [Date.new(2013,12,22),Date.new(2014,1,12)]
22
+ good_dates.each do |date|
23
+ assert(expr.include?(date),"Expr<#{expr}> should include #{date.ctime}")
24
+ end
25
+ bad_dates = [Date.new(2013,12,21), Date.new(2013,12,31),Date.new(2014,01,11),Date.new(2014,01,19)]
26
+ bad_dates.each do |date|
27
+ assert(!expr.include?(date),"Expr<#{expr}> should not include #{date.ctime}")
28
+ end
29
+ end
30
+
31
+ def test_biweekly_with_sunday_start_with_diweek
32
+ every_other_friday = WeekInterval.new(Date.new(2006,2,26), 2) & DIWeek.new(Friday)
33
+
34
+ # should match the First friday and every other Friday after that
35
+ good_dates = [Date.new(2006,3,3), Date.new(2006,3,17), Date.new(2006,3,31)]
36
+ bad_dates = [Date.new(2006,3,1), Date.new(2006,3,10), Date.new(2006,3,24)]
37
+
38
+ good_dates.each do |date|
39
+ assert every_other_friday.include?(date), "Expression #{every_other_friday.to_s} should include #{date}"
40
+ end
41
+
42
+ bad_dates.each do |date|
43
+ assert !every_other_friday.include?(date), "Expression #{every_other_friday.to_s} should not include #{date}"
44
+ end
45
+ end
46
+
47
+ def test_biweekly_with_friday_start_with_diweek
48
+ every_other_wednesday = WeekInterval.new(Date.new(2006,3,3), 2) & DIWeek.new(Wednesday)
49
+
50
+ # should match the First friday and every other Friday after that
51
+ good_dates = [Date.new(2006,3,1), Date.new(2006,3,15), Date.new(2006,3,29)]
52
+ bad_dates = [Date.new(2006,3,2), Date.new(2006,3,8), Date.new(2006,3,22)]
53
+
54
+ good_dates.each do |date|
55
+ assert every_other_wednesday.include?(date), "Expression #{every_other_wednesday.to_s} should include #{date}"
56
+ end
57
+
58
+ bad_dates.each do |date|
59
+ assert !every_other_wednesday.include?(date), "Expression #{every_other_wednesday.to_s} should not include #{date}"
60
+ end
61
+ end
62
+
63
+ def test_tue_thur_every_third_week_with_diweek
64
+ every_tth_every_3 = WeekInterval.new(Date.new(2006,5,1), 3) & (DIWeek.new(Tuesday) | DIWeek.new(Thursday))
65
+
66
+ # should match the First tuesday and thursday for week 1 and every 3 weeks thereafter
67
+ good_dates = [Date.new(2006,5,2), Date.new(2006,5,4), Date.new(2006,5,23), Date.new(2006,5,25), Date.new(2006,6,13), Date.new(2006,6,15)]
68
+ bad_dates = [Date.new(2006,5,3), Date.new(2006,5,9), Date.new(2006,5,18)]
69
+
70
+ good_dates.each do |date|
71
+ assert every_tth_every_3.include?(date), "Expression #{every_tth_every_3.to_s} should include #{date}"
72
+ end
73
+
74
+ bad_dates.each do |date|
75
+ assert !every_tth_every_3.include?(date), "Expression #{every_tth_every_3.to_s} should not include #{date}"
76
+ end
77
+
78
+ range_start = Date.new(2006,5,1)
79
+ range_end = Date.new(2006,8,1)
80
+ expected_dates = [
81
+ Date.new(2006,5,2), Date.new(2006,5,4),
82
+ Date.new(2006,5,23), Date.new(2006,5,25),
83
+ Date.new(2006,6,13), Date.new(2006,6,15),
84
+ Date.new(2006,7,4), Date.new(2006,7,6),
85
+ Date.new(2006,7,25), Date.new(2006,7,27)
86
+ ]
87
+
88
+ dates = every_tth_every_3.dates(DateRange.new(range_start, range_end))
89
+ assert_equal dates, expected_dates
90
+ end
91
+
92
+ def test_to_s
93
+ date = Date.new(2006,2,26)
94
+ assert_equal "every 2nd week starting with the week containing #{Runt.format_date(date)}", WeekInterval.new(date, 2).to_s
95
+ assert_equal "every 3rd week starting with the week containing #{Runt.format_date(date)}", WeekInterval.new(date, 3).to_s
96
+ assert_equal "every 4th week starting with the week containing #{Runt.format_date(date)}", WeekInterval.new(date, 4).to_s
97
+ assert_equal "every 5th week starting with the week containing #{Runt.format_date(date)}", WeekInterval.new(date, 5).to_s
98
+ assert_equal "every 6th week starting with the week containing #{Runt.format_date(date)}", WeekInterval.new(date, 6).to_s
99
+ assert_equal "every 7th week starting with the week containing #{Runt.format_date(date)}", WeekInterval.new(date, 7).to_s
100
+ assert_equal "every 8th week starting with the week containing #{Runt.format_date(date)}", WeekInterval.new(date, 8).to_s
101
+ assert_equal "every 9th week starting with the week containing #{Runt.format_date(date)}", WeekInterval.new(date, 9).to_s
102
+ assert_equal "every 10th week starting with the week containing #{Runt.format_date(date)}", WeekInterval.new(date, 10).to_s
103
+ end
104
+
105
+
106
+ end
metadata CHANGED
@@ -1,148 +1,193 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: runt
3
- version: !ruby/object:Gem::Version
4
- version: 0.7.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - Matthew Lipper
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2008-06-30 00:00:00 +00:00
13
- default_executable:
14
- dependencies: []
15
-
16
- description: Runt is a Ruby version of temporal patterns by Martin Fowler. Runt provides an API for scheduling recurring events using set-like semantics.
17
- email: mlipper@gmail.com
12
+ date: 2013-05-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: minitest
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Runt is a Ruby implementation of temporal patterns by Martin Fowler.
63
+ Runt provides an API for working with recurring events using set expressions.
64
+ email:
65
+ - mlipper@gmail.com
18
66
  executables: []
19
-
20
67
  extensions: []
21
-
22
- extra_rdoc_files:
23
- - README
24
- - CHANGES
25
- - TODO
26
- - LICENSE.txt
27
- - doc/tutorial_te.rdoc
28
- - doc/tutorial_schedule.rdoc
29
- - doc/tutorial_sugar.rdoc
30
- files:
31
- - setup.rb
68
+ extra_rdoc_files: []
69
+ files:
70
+ - .gitignore
71
+ - .travis.yml
72
+ - CHANGES.txt
73
+ - Gemfile
32
74
  - LICENSE.txt
75
+ - README.md
33
76
  - Rakefile
34
77
  - TODO
35
- - CHANGES
36
- - README
37
- - lib/runt/pdate.rb
38
- - lib/runt/dprecision.rb
39
- - lib/runt/temporalexpression.rb
78
+ - doc/tutorial_schedule.md
79
+ - doc/tutorial_sugar.md
80
+ - doc/tutorial_te.md
81
+ - examples/payment_report.rb
82
+ - examples/payment_reporttest.rb
83
+ - examples/reminder.rb
84
+ - examples/schedule_tutorial.rb
85
+ - examples/schedule_tutorialtest.rb
86
+ - lib/runt.rb
40
87
  - lib/runt/daterange.rb
88
+ - lib/runt/dprecision.rb
89
+ - lib/runt/expressionbuilder.rb
90
+ - lib/runt/pdate.rb
41
91
  - lib/runt/schedule.rb
42
92
  - lib/runt/sugar.rb
43
- - lib/runt/expressionbuilder.rb
44
- - lib/runt.rb
45
- - test/reweektest.rb
46
- - test/icalendartest.rb
47
- - test/everytetest.rb
48
- - test/combinedexpressionstest.rb
49
- - test/wimonthtest.rb
50
- - test/reyeartest.rb
51
- - test/runttest.rb
52
- - test/uniontest.rb
53
- - test/yeartetest.rb
54
- - test/daterangetest.rb
93
+ - lib/runt/temporalexpression.rb
94
+ - lib/runt/version.rb
95
+ - runt.gemspec
96
+ - site/.cvsignore
97
+ - site/blue-robot3.css
98
+ - site/dcl-small.gif
99
+ - site/index-rubforge-www.html
100
+ - site/index.html
101
+ - site/logohover.png
102
+ - site/runt-logo.gif
103
+ - site/runt-logo.psd
104
+ - test/aftertetest.rb
55
105
  - test/baseexpressiontest.rb
56
- - test/spectest.rb
106
+ - test/beforetetest.rb
57
107
  - test/collectiontest.rb
58
- - test/scheduletest.rb
59
- - test/pdatetest.rb
108
+ - test/combinedexpressionstest.rb
109
+ - test/daterangetest.rb
110
+ - test/dayintervaltetest.rb
111
+ - test/difftest.rb
112
+ - test/dimonthtest.rb
113
+ - test/diweektest.rb
60
114
  - test/dprecisiontest.rb
115
+ - test/everytetest.rb
116
+ - test/expressionbuildertest.rb
117
+ - test/icalendartest.rb
61
118
  - test/intersecttest.rb
62
- - test/dimonthtest.rb
63
- - test/temporalexpressiontest.rb
119
+ - test/minitest_helper.rb
120
+ - test/pdatetest.rb
64
121
  - test/redaytest.rb
65
- - test/diweektest.rb
66
- - test/difftest.rb
67
- - test/dayintervaltetest.rb
68
122
  - test/remonthtest.rb
69
- - test/rspectest.rb
70
- - test/aftertetest.rb
71
- - test/sugartest.rb
72
- - test/beforetetest.rb
73
- - test/expressionbuildertest.rb
74
- - examples/schedule_tutorial.rb
75
- - examples/schedule_tutorialtest.rb
76
- - examples/reminder.rb
77
- - examples/payment_report.rb
78
- - examples/payment_reporttest.rb
79
- - doc/tutorial_te.rdoc
80
- - doc/tutorial_schedule.rdoc
81
- - doc/tutorial_sugar.rdoc
82
- - site/blue-robot3.css
83
- - site/logohover.png
84
- - site/index.html
85
- - site/runt-logo.gif
86
- - site/runt-logo.psd
87
- - site/dcl-small.gif
88
- has_rdoc: true
89
- homepage: http://runt.rubyforge.org
90
- post_install_message:
91
- rdoc_options:
92
- - --main
93
- - README
94
- - --title
95
- - Runt
96
- require_paths:
97
- - lib
98
- required_ruby_version: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: "0"
103
- version:
104
- required_rubygems_version: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- version: "0"
109
- version:
110
- requirements:
111
- - none
112
- rubyforge_project: runt
113
- rubygems_version: 1.2.0
114
- signing_key:
115
- specification_version: 2
116
- summary: Ruby Temporal Expressions.
117
- test_files:
118
123
  - test/reweektest.rb
119
- - test/icalendartest.rb
120
- - test/everytetest.rb
121
- - test/combinedexpressionstest.rb
122
- - test/wimonthtest.rb
123
124
  - test/reyeartest.rb
124
125
  - test/runttest.rb
126
+ - test/scheduletest.rb
127
+ - test/sugartest.rb
128
+ - test/temporaldatetest.rb
129
+ - test/temporalexpressiontest.rb
130
+ - test/temporalrangetest.rb
131
+ - test/test_runt.rb
125
132
  - test/uniontest.rb
133
+ - test/weekintervaltest.rb
134
+ - test/wimonthtest.rb
126
135
  - test/yeartetest.rb
127
- - test/daterangetest.rb
136
+ homepage: http://github.com/mlipper/runt
137
+ licenses:
138
+ - MIT
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 1.8.24
158
+ signing_key:
159
+ specification_version: 3
160
+ summary: Ruby Temporal Expressions
161
+ test_files:
162
+ - test/aftertetest.rb
128
163
  - test/baseexpressiontest.rb
129
- - test/spectest.rb
164
+ - test/beforetetest.rb
130
165
  - test/collectiontest.rb
131
- - test/scheduletest.rb
132
- - test/pdatetest.rb
166
+ - test/combinedexpressionstest.rb
167
+ - test/daterangetest.rb
168
+ - test/dayintervaltetest.rb
169
+ - test/difftest.rb
170
+ - test/dimonthtest.rb
171
+ - test/diweektest.rb
133
172
  - test/dprecisiontest.rb
173
+ - test/everytetest.rb
174
+ - test/expressionbuildertest.rb
175
+ - test/icalendartest.rb
134
176
  - test/intersecttest.rb
135
- - test/dimonthtest.rb
136
- - test/temporalexpressiontest.rb
177
+ - test/minitest_helper.rb
178
+ - test/pdatetest.rb
137
179
  - test/redaytest.rb
138
- - test/diweektest.rb
139
- - test/difftest.rb
140
- - test/dayintervaltetest.rb
141
180
  - test/remonthtest.rb
142
- - test/rspectest.rb
143
- - test/aftertetest.rb
181
+ - test/reweektest.rb
182
+ - test/reyeartest.rb
183
+ - test/runttest.rb
184
+ - test/scheduletest.rb
144
185
  - test/sugartest.rb
145
- - test/beforetetest.rb
146
- - test/expressionbuildertest.rb
147
- - examples/schedule_tutorialtest.rb
148
- - examples/payment_reporttest.rb
186
+ - test/temporaldatetest.rb
187
+ - test/temporalexpressiontest.rb
188
+ - test/temporalrangetest.rb
189
+ - test/test_runt.rb
190
+ - test/uniontest.rb
191
+ - test/weekintervaltest.rb
192
+ - test/wimonthtest.rb
193
+ - test/yeartetest.rb
data/README DELETED
@@ -1,106 +0,0 @@
1
- = RUNT -- Ruby Temporal Expressions
2
-
3
- * Runt is a Ruby[http://www.ruby-lang.org/en/] implementation of select Martin Fowler patterns[http://www.martinfowler.com/articles].
4
-
5
- * <em>TemporalExpression</em>s allow a developer to define patterns of date recurrence using set expressions.
6
-
7
- = INSTALL
8
-
9
- * gem install runt
10
-
11
- <b>or</b>
12
-
13
- * Unpack the Runt distribution.
14
-
15
- $ tar -xzvf runt-<version>.tar.gz
16
-
17
- * cd $UNPACK_DIR/runt/
18
-
19
- * execute:
20
-
21
- $ ruby setup.rb config
22
- $ ruby setup.rb setup
23
- $ ruby setup.rb install (may require root privilege)
24
-
25
- <b>or</b>
26
-
27
- $ ruby setup.rb --help
28
-
29
- for more options.
30
-
31
- = QUICK START
32
-
33
- * require 'runt'
34
-
35
- * See Runt website[http://runt.rubyforge.org].
36
-
37
- * See $UNPACK_DIR/runt/test/*.rb for example usage.
38
-
39
- * See this mini-TemporalExpression tutorial[http://runt.rubyforge.org/doc/files/doc/tutorial_te_rdoc.html]
40
- * Also this tutorial[http://runt.rubyforge.org/doc/files/doc/tutorial_schedule_rdoc.html]
41
- * And this tutorial[http://runt.rubyforge.org/doc/files/doc/tutorial_sugar_rdoc.html]
42
-
43
- * See http://chronicj.digitalclash.com/apidocs/index.html for commented Java source (JavaDoc)
44
-
45
- Get in touch if you have questions or if Runt causes your computer to burst into flames...
46
-
47
- Matt[mailto:mlipper@gmail.com]
48
-
49
- == Credits
50
-
51
- Rubyforge[http://rubyforge.org] for hosting this project.
52
-
53
- M.Fowler[http://martinfowler.com], Matz[http://ruby-lang.org],
54
- T.Funaba (Date/DateTime[http://www.funaba.org/en/ruby.html]),
55
- J.Weirich (Rake[http://rake.rubyforge.org]),
56
- PragmaticProgrammers[http://pragmaticprogrammer.com], and everyone on
57
- ruby-talk[mailto:ruby-talk@ruby-lang.org] for their shameless public display
58
- of smartness.
59
-
60
- Hal Fulton, Mauricio Fernandez, and Mark Hubbart for the
61
- thread[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/95465] on c.l.r.
62
- that inspired a more Ruby-esque syntax for creating TE's. 2X Thanks to Hal, for
63
- taking the time to exchange ideas off-line.
64
-
65
- The ruby-nyc user's group for their suggestions and feedback.
66
-
67
- BlueRobot[http://www.bluerobot.com/web/layouts/] for the CSS used to prettify the Runt website.
68
-
69
- Emmett Shear for contributed TExpr#dates code and several thought-provoking feature requests.
70
-
71
- Ira Burton for contributed DayIntervalTE class.
72
-
73
- Jodi Showers for serialization bug fix.
74
-
75
- Pat Maddox for YearTE.
76
-
77
- Paul Wright for Time class compatibility.
78
-
79
- Ara T. Howard for Numeric class extensions.
80
-
81
- Larry Karnowski for BeforeTE, AfterTE, TExpr#dates enhancements, RFC2445 (iCalendar) compliance tests.
82
-
83
- Gordon Thiesfeld for fixed Time integration and extended REWeek functionality.
84
-
85
- Justin Cunningham for performance optimizations, bug reports and patches.
86
-
87
- Bug #19982 and patch submitted by Riley Lynch
88
-
89
- The number 12, and the letters E, J, and B.
90
-
91
- = Etc...
92
-
93
- Author:: Matthew Lipper <mlipper@gmail.com>
94
- Requires:: Ruby 1.8.0 or later, Date/DateTime classes
95
- License:: Copyright 2004 by Digital Clash LLC.
96
- Released under the Apache Software license (see LICENSE.txt)
97
- included in the distribution.
98
-
99
- = Warranty
100
-
101
- This software is provided "as is" and without any express or
102
- implied warranties, including, without limitation, the implied
103
- warranties of merchantibility and fitness for a particular
104
- purpose.
105
-
106
- link://../dcl-small.gif