sixarm_ruby_week 1.1.4 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -0,0 +1,120 @@
1
+ # SixArm.com » Ruby » <br> Week model based on Ruby Date
2
+
3
+ * Docs: <http://sixarm.com/sixarm_ruby_week/doc>
4
+ * Repo: <http://github.com/sixarm/sixarm_ruby_week>
5
+ * Email: Joel Parker Henderson, <joel@sixarm.com>
6
+
7
+
8
+ ## Introduction
9
+
10
+ This gem models a week, based on the built-in Ruby Date class.
11
+
12
+ For docs go to <http://sixarm.com/sixarm_ruby_week/doc>
13
+
14
+ Want to help? We're happy to get pull requests.
15
+
16
+
17
+ ## Quickstart
18
+
19
+ Install:
20
+
21
+ gem install sixarm_ruby_week
22
+
23
+ Bundler:
24
+
25
+ gem "sixarm_ruby_week", "=1.1.4"
26
+
27
+ Require:
28
+
29
+ require "sixarm_ruby_week"
30
+
31
+
32
+ ## High Security (Optional)
33
+
34
+ To enable high security for all our gems:
35
+
36
+ wget http://sixarm.com/sixarm.pem
37
+ gem cert --add sixarm.pem
38
+ gem sources --add http://sixarm.com
39
+
40
+ To install with high security:
41
+
42
+ gem install sixarm_ruby_week --test --trust-policy HighSecurity
43
+
44
+
45
+ ## Examples
46
+
47
+ Create:
48
+
49
+ date = Date.parse('2012-01-02')
50
+ week = Week.new(date)
51
+ week.to_s => '2012-01-02'
52
+
53
+ Parse:
54
+
55
+ week = Week.parse('2012-01-02')
56
+ week => 2012-01-02
57
+
58
+ Enumerable:
59
+
60
+ week.previous => 2011-12-26
61
+ week.next => 2012-01-16
62
+
63
+ Math:
64
+
65
+ week - 3 => 2011-12-12
66
+ week + 3 => 2012-01-24
67
+
68
+ Start & End Dates:
69
+
70
+ week.start_date => 2012-01-02
71
+ week.end_date => 2012-01-08
72
+
73
+ Range:
74
+
75
+ week.date_range => Range(2012-01-02..2012-01-08)
76
+
77
+ Collection:
78
+
79
+ date = Date.parse('2012-01-02')
80
+ week.include?(date) => true
81
+ week.include?(date+7) => false
82
+
83
+
84
+ ## Changes
85
+
86
+ * 2012-03-16 1.1.6 Upgrade for Ruby 1.9.3, minitest/spec, and improved docs.
87
+ * 2012-03-12 1.1.4 Improve tests from test/unit style toward minitest/spec style
88
+ * 2012-03-11 1.1.2 Add #date_range method to return start_date..end_date
89
+ * 2012-03-10 1.1.1 Rename #includes? to #include? because it matches Ruby's Array include? method
90
+ * 2012-02-24 1.1.0 Add methods .now, #includes?, #previous, #next, #start_date, #end_date, and improve examples
91
+ * 2012-02-23 1.0.0 Updates for gem publishing
92
+
93
+
94
+ ## License
95
+
96
+ You may choose any of these open source licenses:
97
+
98
+ * Apache License
99
+ * BSD License
100
+ * CreativeCommons License, Non-commercial Share Alike
101
+ * GNU General Public License Version 2 (GPL 2)
102
+ * GNU Lesser General Public License (LGPL)
103
+ * MIT License
104
+ * Perl Artistic License
105
+ * Ruby License
106
+
107
+ The software is provided "as is", without warranty of any kind,
108
+ express or implied, including but not limited to the warranties of
109
+ merchantability, fitness for a particular purpose and noninfringement.
110
+
111
+ In no event shall the authors or copyright holders be liable for any
112
+ claim, damages or other liability, whether in an action of contract,
113
+ tort or otherwise, arising from, out of or in connection with the
114
+ software or the use or other dealings in the software.
115
+
116
+ This license is for the included software that is created by SixArm;
117
+ some of the included software may have its own licenses, copyrights,
118
+ authors, etc. and these do take precedence over the SixArm license.
119
+
120
+ Copyright (c) 2013 Joel Parker Henderson
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  =begin rdoc
3
- Please see README.rdoc
3
+ Please see README
4
4
  =end
5
5
 
6
6
  require 'date'
@@ -1,5 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
- require 'test/unit'
3
2
  require 'minitest/autorun'
4
3
  require 'simplecov'
5
4
  SimpleCov.start
@@ -18,9 +17,9 @@ describe Week do
18
17
  describe ".initialize" do
19
18
 
20
19
  it "must initialize the year, week, and day" do
21
- assert_equal(WEEK.date.cwyear, 2012)
22
- assert_equal(WEEK.date.cweek, 1)
23
- assert_equal(WEEK.date.cwday, 1)
20
+ WEEK.date.cwyear.must_equal 2012
21
+ WEEK.date.cweek.must_equal 1
22
+ WEEK.date.cwday.must_equal 1
24
23
  end
25
24
 
26
25
  end
@@ -28,11 +27,11 @@ describe Week do
28
27
  describe "#date" do
29
28
 
30
29
  it "=> Date" do
31
- assert_kind_of(Date, WEEK.date)
30
+ WEEK.date.must_be_kind_of Date
32
31
  end
33
32
 
34
33
  it "=> the date that initiazed the week" do
35
- assert_equal(DATE, WEEK.date)
34
+ WEEK.date.must_equal DATE
36
35
  end
37
36
 
38
37
  end
@@ -40,11 +39,11 @@ describe Week do
40
39
  describe "#to_s" do
41
40
 
42
41
  it "=> String" do
43
- assert_kind_of(String, WEEK.to_s)
42
+ WEEK.to_s.must_be_kind_of String
44
43
  end
45
44
 
46
45
  it "=> the week's date formatted as YYYY-MM-DD" do
47
- assert_equal(TEXT, WEEK.to_s)
46
+ WEEK.to_s.must_equal TEXT
48
47
  end
49
48
 
50
49
  end
@@ -52,11 +51,11 @@ describe Week do
52
51
  describe ".now" do
53
52
 
54
53
  it "=> Week" do
55
- assert_kind_of(Week, Week.now)
54
+ Week.now.must_be_kind_of Week
56
55
  end
57
56
 
58
57
  it "=> a week based on today's date" do
59
- assert_equal(Date.today, Week.now.date)
58
+ Week.now.date.must_equal Date.today
60
59
  end
61
60
 
62
61
  end
@@ -64,12 +63,12 @@ describe Week do
64
63
  describe ".parse" do
65
64
 
66
65
  it "=> Week" do
67
- assert_kind_of(Week, Week.parse(TEXT))
66
+ Week.parse(TEXT).must_be_kind_of Week
68
67
  end
69
68
 
70
69
  it "=> a week based on the date text" do
71
70
  s = '2012-01-02'
72
- assert_equal(Date.parse(s), Week.parse(s).date)
71
+ Week.parse(s).date.must_equal Date.parse(s)
73
72
  end
74
73
 
75
74
  end
@@ -77,11 +76,11 @@ describe Week do
77
76
  describe "#hash" do
78
77
 
79
78
  it "=> Fixnum" do
80
- assert_kind_of(Fixnum, WEEK.hash)
79
+ WEEK.hash.must_be_kind_of Fixnum
81
80
  end
82
81
 
83
82
  it "=> the week's date's hash" do
84
- assert_equal(WEEK.date.hash, WEEK.hash)
83
+ WEEK.hash.must_equal WEEK.date.hash
85
84
  end
86
85
 
87
86
  end
@@ -113,15 +112,15 @@ describe Week do
113
112
  describe "<=>" do
114
113
 
115
114
  it "x<y => -1" do
116
- assert_equal(-1, WEEK <=> WEEK_NEXT)
115
+ (WEEK <=> WEEK_NEXT).must_equal -1
117
116
  end
118
117
 
119
118
  it "x=y => 0" do
120
- assert_equal( 0, WEEK <=> WEEK)
119
+ (WEEK <=> WEEK).must_equal 0
121
120
  end
122
121
 
123
122
  it "x>y => 1" do
124
- assert_equal( 1, WEEK <=> WEEK_PREV)
123
+ (WEEK <=> WEEK_PREV).must_equal 1
125
124
  end
126
125
 
127
126
  end
@@ -195,36 +194,34 @@ describe Week do
195
194
  describe "with Numeric type" do
196
195
 
197
196
  it "=> Week" do
198
- assert_kind_of(Week, WEEK + 0)
197
+ (WEEK + 0).must_be_kind_of Week
199
198
  end
200
199
 
201
200
  it "+ 0 => this week" do
202
- assert_equal(WEEK, WEEK + 0)
201
+ (WEEK + 0).must_equal WEEK
203
202
  end
204
203
 
205
204
  it "+ 1 => next week" do
206
- assert_equal(WEEK_NEXT, WEEK + 1)
205
+ (WEEK + 1).must_equal WEEK_NEXT
207
206
  end
208
207
 
209
208
  it "+ (-1) => previous week" do
210
- assert_equal(WEEK_PREV, WEEK + (-1))
209
+ (WEEK + (-1)).must_equal WEEK_PREV
211
210
  end
212
211
 
213
212
  it "+ any other number => different week" do
214
213
  w = WEEK + 2
215
- refute_equal(WEEK_PREV, w)
216
- refute_equal(WEEK, w)
217
- refute_equal(WEEK_NEXT, w)
214
+ w.wont_equal WEEK_PREV
215
+ w.wont_equal WEEK
216
+ w.wont_equal WEEK_NEXT
218
217
  end
219
218
 
220
219
  end
221
220
 
222
221
  describe "with bad type" do
223
222
 
224
- it "raises TypeError" do
225
- assert_raises TypeError do
226
- WEEK + "foo"
227
- end
223
+ it "TypeError" do
224
+ proc { WEEK + "foo" }.must_raise TypeError
228
225
  end
229
226
 
230
227
  end
@@ -236,26 +233,26 @@ describe Week do
236
233
  describe "with Numeric type" do
237
234
 
238
235
  it "=> Week" do
239
- assert_kind_of(Week, WEEK - 0)
236
+ (WEEK - 0).must_be_kind_of Week
240
237
  end
241
238
 
242
239
  it "- 0 => this week" do
243
- assert_equal(WEEK, WEEK - 0)
240
+ (WEEK - 0).must_equal WEEK
244
241
  end
245
242
 
246
243
  it "- 1 => previous week" do
247
- assert_equal(WEEK_PREV, WEEK - 1)
244
+ (WEEK - 1).must_equal WEEK_PREV
248
245
  end
249
246
 
250
247
  it "- (-1) => next week" do
251
- assert_equal(WEEK_NEXT, WEEK - (-1))
248
+ (WEEK - (-1)).must_equal WEEK_NEXT
252
249
  end
253
250
 
254
251
  it "- any other number => different week" do
255
252
  w = WEEK - 2
256
- refute_equal(WEEK_PREV, w)
257
- refute_equal(WEEK, w)
258
- refute_equal(WEEK_NEXT, w)
253
+ w.wont_equal WEEK_PREV
254
+ w.wont_equal WEEK
255
+ w.wont_equal WEEK_NEXT
259
256
  end
260
257
 
261
258
  end
@@ -263,29 +260,27 @@ describe Week do
263
260
  describe "with Week type" do
264
261
 
265
262
  it "=> Integer" do
266
- assert_kind_of(Integer, WEEK - WEEK)
263
+ (WEEK - WEEK).must_be_kind_of Integer
267
264
  end
268
265
 
269
266
  it "this week - previous week => 1" do
270
- assert_equal(1, WEEK - WEEK_PREV)
267
+ (WEEK - WEEK_PREV).must_equal 1
271
268
  end
272
269
 
273
270
  it "this week - this week => 0" do
274
- assert_equal(0, WEEK - WEEK)
271
+ (WEEK - WEEK).must_equal 0
275
272
  end
276
273
 
277
274
  it "this week - next week => -1" do
278
- assert_equal(-1, WEEK - WEEK_NEXT)
275
+ (WEEK - WEEK_NEXT).must_equal -1
279
276
  end
280
277
 
281
278
  end
282
279
 
283
280
  describe "with bad type" do
284
281
 
285
- it "raises TypeError" do
286
- assert_raises TypeError do
287
- WEEK - "foo"
288
- end
282
+ it "TypeError" do
283
+ proc { WEEK - "foo" }.must_raise TypeError
289
284
  end
290
285
 
291
286
  end
@@ -295,11 +290,11 @@ describe Week do
295
290
  describe "#previous" do
296
291
 
297
292
  it "=> Week" do
298
- assert_kind_of(Week, WEEK.previous)
293
+ WEEK.previous.must_be_kind_of Week
299
294
  end
300
295
 
301
296
  it "=> a week seven days earlier" do
302
- assert_equal(Week.new(DATE-7), Week.new(DATE).previous)
297
+ Week.new(DATE).previous.must_equal Week.new(DATE-7)
303
298
  end
304
299
 
305
300
  end
@@ -307,11 +302,11 @@ describe Week do
307
302
  describe "#next" do
308
303
 
309
304
  it "=> Week" do
310
- assert_kind_of(Week, WEEK.next)
305
+ (WEEK.next).must_be_kind_of Week
311
306
  end
312
307
 
313
308
  it "=> a week seven days later" do
314
- assert_equal(Week.new(DATE+7), Week.new(DATE).next)
309
+ Week.new(DATE).next.must_equal Week.new(DATE+7)
315
310
  end
316
311
 
317
312
  end
@@ -319,11 +314,11 @@ describe Week do
319
314
  describe "#start_date" do
320
315
 
321
316
  it "=> Date" do
322
- assert_kind_of(Date, WEEK.start_date)
317
+ WEEK.start_date.must_be_kind_of Date
323
318
  end
324
319
 
325
320
  it "=> the initialzation date" do
326
- assert_equal(DATE, WEEK.start_date)
321
+ WEEK.start_date.must_equal DATE
327
322
  end
328
323
 
329
324
  end
@@ -331,11 +326,11 @@ describe Week do
331
326
  describe "#end_date" do
332
327
 
333
328
  it "=> Date" do
334
- assert_kind_of(Date, WEEK.end_date)
329
+ WEEK.end_date.must_be_kind_of Date
335
330
  end
336
331
 
337
332
  it "=> six days after the initialization date" do
338
- assert_equal(DATE + 6, WEEK.end_date)
333
+ WEEK.end_date.must_equal DATE + 6
339
334
  end
340
335
 
341
336
  end
@@ -343,15 +338,15 @@ describe Week do
343
338
  describe "#date_range" do
344
339
 
345
340
  it "=> Range" do
346
- assert_kind_of(Range, WEEK.date_range)
341
+ WEEK.date_range.must_be_kind_of Range
347
342
  end
348
343
 
349
344
  it "=> Range first is the start date" do
350
- assert_equal(WEEK.start_date, WEEK.date_range.first)
345
+ WEEK.date_range.first.must_equal WEEK.start_date
351
346
  end
352
347
 
353
348
  it "=> Range last is the end date" do
354
- assert_equal(WEEK.end_date, WEEK.date_range.last)
349
+ WEEK.date_range.last.must_equal WEEK.end_date
355
350
  end
356
351
 
357
352
  end
@@ -359,23 +354,23 @@ describe Week do
359
354
  describe "#include?" do
360
355
 
361
356
  it "all days in this week => true" do
362
- assert_includes(WEEK, DATE+0)
363
- assert_includes(WEEK, DATE+1)
364
- assert_includes(WEEK, DATE+2)
365
- assert_includes(WEEK, DATE+3)
366
- assert_includes(WEEK, DATE+4)
367
- assert_includes(WEEK, DATE+5)
368
- assert_includes(WEEK, DATE+6)
357
+ WEEK.must_include DATE+0
358
+ WEEK.must_include DATE+1
359
+ WEEK.must_include DATE+2
360
+ WEEK.must_include DATE+3
361
+ WEEK.must_include DATE+4
362
+ WEEK.must_include DATE+5
363
+ WEEK.must_include DATE+6
369
364
  end
370
365
 
371
366
  it "any day before this week => false" do
372
- refute_includes(WEEK, DATE-1)
373
- refute_includes(WEEK, DATE-999)
367
+ WEEK.wont_include DATE-1
368
+ WEEK.wont_include DATE-999
374
369
  end
375
370
 
376
371
  it "any day after this week => false" do
377
- refute_includes(WEEK, DATE+7)
378
- refute_includes(WEEK, DATE+999)
372
+ WEEK.wont_include DATE+7
373
+ WEEK.wont_include DATE+999
379
374
  end
380
375
 
381
376
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sixarm_ruby_week
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -35,7 +35,7 @@ cert_chain:
35
35
  L2RORkllUkVIekVSClpEUlFZTXFydTlURU1uYTZIRDl6cGNzdEY3dndUaEdv
36
36
  dmxPUSszWTZwbFE0bk16aXBYY1o5VEhxczY1UElMMHEKZWFid3BDYkFvcG89
37
37
  Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
38
- date: 2012-03-13 00:00:00.000000000 Z
38
+ date: 2012-03-16 00:00:00.000000000 Z
39
39
  dependencies: []
40
40
  description:
41
41
  email: sixarm@sixarm.com
@@ -44,11 +44,8 @@ extensions: []
44
44
  extra_rdoc_files: []
45
45
  files:
46
46
  - .gemtest
47
- - CHANGELOG.txt
48
- - INSTALL.txt
49
- - LICENSE.txt
50
47
  - Rakefile
51
- - README.rdoc
48
+ - README.md
52
49
  - VERSION
53
50
  - lib/sixarm_ruby_week.rb
54
51
  - test/sixarm_ruby_week_test.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,7 +0,0 @@
1
- CHANGELOG
2
-
3
- 2012-03-12 1.1.4 Improve tests from test/unit style toward minitest/spec style
4
- 2012-03-11 1.1.2 Add #date_range method to return start_date..end_date
5
- 2012-03-10 1.1.1 Rename #includes? to #include? because it matches Ruby's Array include? method
6
- 2012-02-24 1.1.0 Add methods .now, #includes?, #previous, #next, #start_date, #end_date, and improve examples
7
- 2012-02-23 1.0.0 Updates for gem publishing
@@ -1,32 +0,0 @@
1
-
2
- = SixArm.com Ruby Gem Install
3
-
4
-
5
- First-time users: add our gem certificate and source.
6
- When you do this once, it works for all our gems.
7
-
8
- sudo wget http://sixarm.com/sixarm.pem
9
- sudo gem cert --add sixarm.pem
10
- sudo gem sources --add http://sixarm.com
11
-
12
- Install the gem with advanced options.
13
-
14
- sudo gem install sixarm_ruby_week --test --trust-policy HighSecurity
15
-
16
-
17
- == Notes
18
-
19
- Do you have any questions, comments, suggestions, or feedback?
20
- Let us know, we're happy to help. Our email is sixarm@sixarm.com
21
-
22
- Do you want to create your own high security gems?
23
- Learn how at http://www.rubygems.org/read/chapter/21
24
-
25
- To see your current gem certificate list:
26
-
27
- sudo gem cert --list
28
-
29
- Our cert looks like this:
30
-
31
- /C=US/ST=California/L=San Francisco/O=SixArm/CN=sixarm.com
32
-
@@ -1,25 +0,0 @@
1
- LICENSE
2
-
3
- You may choose any of these open source licenses:
4
-
5
- - Apache License
6
- - BSD License
7
- - CreativeCommons License, Non-commercial Share Alike
8
- - GNU General Public License Version 2 (GPL 2)
9
- - GNU Lesser General Public License (LGPL)
10
- - MIT License
11
- - Perl Artistic License
12
- - Ruby License
13
-
14
- The software is provided "as is", without warranty of any kind,
15
- express or implied, including but not limited to the warranties of
16
- merchantability, fitness for a particular purpose and noninfringement.
17
-
18
- In no event shall the authors or copyright holders be liable for any
19
- claim, damages or other liability, whether in an action of contract,
20
- tort or otherwise, arising from, out of or in connection with the
21
- software or the use or other dealings in the software.
22
-
23
- This license is for the included software that is created by SixArm;
24
- some of the included software may have its own licenses, copyrights,
25
- authors, etc. and these do take precedence over the SixArm license.
@@ -1,46 +0,0 @@
1
- = SixArm.com » Ruby » Week model based on Ruby Date
2
-
3
- Author:: Joel Parker Henderson, joel@joelparkerhenderson.com
4
- Copyright:: Copyright (c) 2006-2012 Joel Parker Henderson
5
- License:: See LICENSE.txt file
6
-
7
- This gem models a week, based on the built-in Ruby Date class.
8
-
9
- == Examples
10
-
11
-
12
- Initialize:
13
-
14
- date = Date.parse('2012-01-02')
15
- week = Week.new(date)
16
- week.to_s => '2012-01-02'
17
-
18
- Parse:
19
-
20
- week = Week.parse('2012-01-02')
21
- week => 2012-01-02
22
-
23
- Enumerable:
24
-
25
- week.previous => 2011-12-26
26
- week.next => 2012-01-16
27
-
28
- Math:
29
-
30
- week - 3 => 2011-12-12
31
- week + 3 => 2012-01-24
32
-
33
- Start & End Dates:
34
-
35
- week.start_date => 2012-01-02
36
- week.end_date => 2012-01-08
37
-
38
- Range:
39
-
40
- week.date_range => Range(2012-01-02..2012-01-08)
41
-
42
- Collection:
43
-
44
- date = Date.parse('2012-01-02')
45
- week.include?(date) => true
46
- week.include?(date+7) => false