week 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +35 -8
- data/lib/week.rb +7 -0
- data/test/test_week.rb +32 -0
- metadata +23 -43
data/README.md
CHANGED
@@ -1,16 +1,43 @@
|
|
1
|
-
|
2
|
-
A simple gem to work with weeks as arrays of days numbers. It works with commercial dates (according to http://en.wikipedia.org/wiki/ISO_week_date).
|
1
|
+
[![Build Status](https://secure.travis-ci.org/grsmv/week.png?branch=master)](http://travis-ci.org/grsmv/week)
|
3
2
|
|
4
|
-
|
3
|
+
## Description:
|
4
|
+
A simple gem to work with weeks as arrays of date objects. It works with commercial dates (according to http://en.wikipedia.org/wiki/ISO_week_date).
|
5
|
+
|
6
|
+
## Usage:
|
5
7
|
|
6
8
|
week(2011, 52).map { |day| p day }
|
9
|
+
|
10
|
+
# =>
|
11
|
+
# Sun Dec 25 00:00:00 +0200 2011
|
12
|
+
# (...)
|
13
|
+
# Sat Dec 31 00:00:00 +0200 2011
|
14
|
+
|
15
|
+
|
16
|
+
# Or you can use it without any parameters:
|
17
|
+
# (if todays date is 10, August 2011)
|
18
|
+
|
19
|
+
week.map { |day| p day }
|
20
|
+
|
21
|
+
# =>
|
22
|
+
# Sun Aug 07 00:00:00 +0300 2011
|
23
|
+
# (...)
|
24
|
+
# Sat Aug 13 00:00:00 +0300 2011
|
25
|
+
|
26
|
+
|
27
|
+
# Use gem with 1 as third parameter if you want
|
28
|
+
# to have Monday as a first day of the week:
|
29
|
+
|
30
|
+
week(2011, 8, 1).map { |day| p day }
|
31
|
+
|
32
|
+
# Also there is monkey patch for standart library Date class,
|
33
|
+
# with wich you can simply do this:
|
34
|
+
|
35
|
+
Date.new(2011, 12, 25).week
|
36
|
+
|
7
37
|
# =>
|
8
38
|
# Sun Dec 25 00:00:00 +0200 2011
|
9
|
-
#
|
10
|
-
# Tue Dec 27 00:00:00 +0200 2011
|
11
|
-
# Wed Dec 28 00:00:00 +0200 2011
|
12
|
-
# Thu Dec 29 00:00:00 +0200 2011
|
13
|
-
# Fri Dec 30 00:00:00 +0200 2011
|
39
|
+
# (...)
|
14
40
|
# Sat Dec 31 00:00:00 +0200 2011
|
15
41
|
|
42
|
+
|
16
43
|
Copyright (c) 2011 Sergey Gerasimov
|
data/lib/week.rb
CHANGED
data/test/test_week.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "week"
|
3
|
+
|
4
|
+
class WeekTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@standard_output = []
|
7
|
+
(25..31).each do |day|
|
8
|
+
@standard_output << Time.mktime(2011, 12, day)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_001_returning_array_count
|
13
|
+
assert_equal 7, week(2011, 52).size
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_002_returning_array_contents
|
17
|
+
assert_equal @standard_output, week(2011, 52)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_003_monday_as_first_day_of_the_week
|
21
|
+
assert_equal 1, week(2011, 8, 1)[0].wday
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_004_date_monkey_patching
|
25
|
+
assert_equal @standard_output, Date.new(2011, 12, 25).week
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_005_date_monkey_patching_wide_form
|
29
|
+
day = Date.new(2011, 12, 25)
|
30
|
+
assert_equal @standard_output, day.week
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,71 +1,51 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: week
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 0.0.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Sergey Gerasimov
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-08-10 00:00:00 +03:00
|
19
|
-
default_executable:
|
12
|
+
date: 2012-03-23 00:00:00.000000000Z
|
20
13
|
dependencies: []
|
21
|
-
|
22
|
-
|
23
|
-
email:
|
14
|
+
description: Simple gem to work with weeks as arrays of date objects. Also include
|
15
|
+
monkey patch for Date class. Cheers!
|
16
|
+
email:
|
24
17
|
- mail@grsmv.com
|
25
18
|
executables: []
|
26
|
-
|
27
19
|
extensions: []
|
28
|
-
|
29
20
|
extra_rdoc_files: []
|
30
|
-
|
31
|
-
files:
|
21
|
+
files:
|
32
22
|
- README.md
|
33
23
|
- CHANGELOG.md
|
34
24
|
- LICENSE
|
35
25
|
- lib/week.rb
|
36
|
-
|
26
|
+
- test/test_week.rb
|
37
27
|
homepage: http://github.com/grsmv/week
|
38
28
|
licenses: []
|
39
|
-
|
40
29
|
post_install_message:
|
41
30
|
rdoc_options: []
|
42
|
-
|
43
|
-
require_paths:
|
31
|
+
require_paths:
|
44
32
|
- lib
|
45
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
34
|
none: false
|
47
|
-
requirements:
|
48
|
-
- -
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
|
51
|
-
|
52
|
-
- 0
|
53
|
-
version: "0"
|
54
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
40
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
segments:
|
61
|
-
- 0
|
62
|
-
version: "0"
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
63
45
|
requirements: []
|
64
|
-
|
65
46
|
rubyforge_project: week
|
66
|
-
rubygems_version: 1.
|
47
|
+
rubygems_version: 1.8.10
|
67
48
|
signing_key:
|
68
49
|
specification_version: 3
|
69
|
-
summary: Simple gem to work with weeks as arrays of
|
50
|
+
summary: Simple gem to work with weeks as arrays of date objects.
|
70
51
|
test_files: []
|
71
|
-
|