sculd 0.1.2 → 0.1.3
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.
- data/CHANGES +4 -2
- data/Gemfile +1 -2
- data/VERSION +1 -1
- data/lib/sculd/manager.rb +142 -142
- data/lib/sculd/plan.rb +73 -73
- data/lib/sculd/plan/deadline.rb +27 -25
- data/lib/sculd/plan/reminder.rb +12 -12
- data/lib/sculd/plan/schedule.rb +8 -8
- data/lib/sculd/plan/todo.rb +25 -25
- data/sculd.gemspec +5 -5
- data/test/helper.rb +4 -4
- data/test/test_deadline.rb +49 -45
- data/test/test_manager.rb +94 -94
- data/test/test_plan.rb +88 -88
- data/test/test_reminder.rb +28 -28
- data/test/test_schedule.rb +17 -17
- data/test/test_todo.rb +40 -40
- metadata +5 -5
data/test/test_plan.rb
CHANGED
|
@@ -6,92 +6,92 @@ require "helper"
|
|
|
6
6
|
#require "pkg/klass.rb"
|
|
7
7
|
|
|
8
8
|
class TC_Plan < Test::Unit::TestCase
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
9
|
+
def test_parse
|
|
10
|
+
## correct string
|
|
11
|
+
result = Sculd::Plan.parse('[2012-10-23]! deadlineA')
|
|
12
|
+
date = DateTime.new(2012, 10, 23, 0, 0, 0)
|
|
13
|
+
assert_equal(date , result[:datetime])
|
|
14
|
+
assert_equal("!" , result[:type])
|
|
15
|
+
assert_equal(nil , result[:option])
|
|
16
|
+
assert_equal("deadlineA", result[:description])
|
|
17
|
+
assert_equal(false , result[:flag_time])
|
|
18
|
+
|
|
19
|
+
result = Sculd::Plan.parse('[2012-10-23]!30 deadlineA')
|
|
20
|
+
date = DateTime.new(2012, 10, 23, 0, 0, 0)
|
|
21
|
+
assert_equal(date , result[:datetime])
|
|
22
|
+
assert_equal("!" , result[:type])
|
|
23
|
+
assert_equal(30 , result[:option])
|
|
24
|
+
assert_equal("deadlineA", result[:description])
|
|
25
|
+
assert_equal(false , result[:flag_time])
|
|
26
|
+
|
|
27
|
+
result = Sculd::Plan.parse('[2012-10-23 01:02:03]@ scheduleA')
|
|
28
|
+
date = DateTime.new(2012, 10, 23, 1, 2, 3)
|
|
29
|
+
assert_equal(date , result[:datetime])
|
|
30
|
+
assert_equal("@" , result[:type])
|
|
31
|
+
assert_equal(nil , result[:option])
|
|
32
|
+
assert_equal("scheduleA", result[:description])
|
|
33
|
+
assert_equal(true , result[:flag_time])
|
|
34
|
+
|
|
35
|
+
result = Sculd::Plan.parse('[2012-11-01 01:02:03(Thu)]@ scheduleA')
|
|
36
|
+
date = DateTime.new(2012, 11, 1, 1, 2, 3)
|
|
37
|
+
assert_equal(date , result[:datetime])
|
|
38
|
+
assert_equal("@" , result[:type])
|
|
39
|
+
assert_equal(nil , result[:option])
|
|
40
|
+
assert_equal("scheduleA", result[:description])
|
|
41
|
+
assert_equal(true , result[:flag_time])
|
|
42
|
+
|
|
43
|
+
result = Sculd::Plan.parse('[2012-11-01 01:02:03(th)]@ scheduleA')
|
|
44
|
+
date = DateTime.new(2012, 11, 01, 1, 2, 3)
|
|
45
|
+
assert_equal(date , result[:datetime])
|
|
46
|
+
assert_equal("@" , result[:type])
|
|
47
|
+
assert_equal(nil , result[:option])
|
|
48
|
+
assert_equal("scheduleA", result[:description])
|
|
49
|
+
assert_equal(true , result[:flag_time])
|
|
50
|
+
|
|
51
|
+
#context 'schedule with wrong weekday' do
|
|
52
|
+
io = StringIO.new
|
|
53
|
+
assert_raise(Sculd::Plan::WeekdayMismatchError ){ Sculd::Plan.parse('[2012-11-01 01:02:03(Sun)]@ scheduleA', io)}
|
|
54
|
+
|
|
55
|
+
assert_raise(Sculd::Plan::WeekdayMismatchError ){ Sculd::Plan.parse( "[2012-11-01(Fri)]@ mismach weekday\n", io)}
|
|
56
|
+
|
|
57
|
+
assert_raise(Sculd::Plan::NotWeekdayError ){ Sculd::Plan.parse('[2012-11-01 01:02:03(abc)]@ scheduleA', io)}
|
|
58
|
+
|
|
59
|
+
#Unable to interpret as date in [].
|
|
60
|
+
#assert_raise(Sculd::Plan::NotDateError ){ Sculd::Plan.parse('[abc]! deadlineA')}
|
|
61
|
+
assert_raise(ArgumentError){ Sculd::Plan.parse('[abc]! deadlineA')}
|
|
62
|
+
|
|
63
|
+
##Illegal syntax
|
|
64
|
+
# '[abc]]! deadlineA' do
|
|
65
|
+
assert_raise(Sculd::Plan::NotNumberError){
|
|
66
|
+
Sculd::Plan.parse('[2012-01-01]]! deadlineA')
|
|
67
|
+
}
|
|
68
|
+
#date = DateTime.new(2012, 01, 01)
|
|
69
|
+
#assert_equal(date , result[:datetime])
|
|
70
|
+
#assert_equal("]" , result[:type])
|
|
71
|
+
#assert_equal("!" , result[:option])
|
|
72
|
+
#assert_equal("deadlineA", result[:description])
|
|
73
|
+
|
|
74
|
+
#context ' [2012-10-23]! deadlineA with space at head' do
|
|
75
|
+
#it 'should return Date, !, deadlineA' do
|
|
76
|
+
result = Sculd::Plan.parse(' [2012-10-23]! deadlineA with space at head')
|
|
77
|
+
date = DateTime.new(2012, 10, 23)
|
|
78
|
+
assert_equal(date , result[:datetime])
|
|
79
|
+
assert_equal("!" , result[:type])
|
|
80
|
+
assert_equal(nil , result[:option])
|
|
81
|
+
assert_equal("deadlineA with space at head", result[:description])
|
|
82
|
+
assert_equal(false , result[:flag_time])
|
|
83
|
+
|
|
84
|
+
#context '[2012-10-23]!10 deadline with option value' do
|
|
85
|
+
#it 'should return Date, !, deadlineA' do
|
|
86
|
+
result = Sculd::Plan.parse( '[2012-10-23]!10 deadline with option value')
|
|
87
|
+
date = DateTime.new(2012, 10, 23)
|
|
88
|
+
assert_equal(date , result[:datetime])
|
|
89
|
+
assert_equal("!" , result[:type])
|
|
90
|
+
assert_equal(10 , result[:option])
|
|
91
|
+
assert_equal("deadline with option value", result[:description])
|
|
92
|
+
assert_equal(false , result[:flag_time])
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
end
|
|
97
97
|
end
|
data/test/test_reminder.rb
CHANGED
|
@@ -6,33 +6,33 @@ require "helper"
|
|
|
6
6
|
#require "pkg/klass.rb"
|
|
7
7
|
|
|
8
8
|
class TC_Klass < Test::Unit::TestCase
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
9
|
+
def setup
|
|
10
|
+
date = Date.new(2012, 10, 23)
|
|
11
|
+
@r00 = Sculd::Plan::Reminder.new(date, false, 10, 'reminderA')
|
|
12
|
+
|
|
13
|
+
date = DateTime.new(2012, 10, 23, 23, 45, 00)
|
|
14
|
+
@r01 = Sculd::Plan::Reminder.new(date, false, 10, 'reminderA')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_priority
|
|
18
|
+
#it 'return REMINDER_PRIORITY when the day is today .' do
|
|
19
|
+
date = Date.new(2012, 10, 23)
|
|
20
|
+
assert_equal(10000, @r00.priority(date))
|
|
21
|
+
|
|
22
|
+
#it 'return REMINDER_PRIORITY -1 when the day is yesterday .' do
|
|
23
|
+
date = Date.new(2012, 10, 24)
|
|
24
|
+
assert_equal(9999, @r00.priority(date))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_event_dates
|
|
28
|
+
#it 'return a Sculd::Event instance.' do
|
|
29
|
+
results = @r00.event_dates
|
|
30
|
+
assert_equal([Date.new(2012, 10, 23)], results)
|
|
31
|
+
|
|
32
|
+
results = @r01.event_dates
|
|
33
|
+
assert_equal(1 , results.size)
|
|
34
|
+
assert_equal(Date.new(2012, 10, 23), results[0] )
|
|
35
|
+
assert_equal(Date , results[0].class )
|
|
36
|
+
end
|
|
37
37
|
end
|
|
38
38
|
|
data/test/test_schedule.rb
CHANGED
|
@@ -6,25 +6,25 @@ require "helper"
|
|
|
6
6
|
#require "pkg/klass.rb"
|
|
7
7
|
|
|
8
8
|
class TC_Schedule < Test::Unit::TestCase
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
def setup
|
|
10
|
+
date = Date.new(2012, 10, 15)
|
|
11
|
+
@s00 = Sculd::Plan::Schedule.new(date, false, 0, "scheduleA")
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
date = DateTime.new(2012, 10, 15, 23, 45, 0)
|
|
14
|
+
@s01 = Sculd::Plan::Schedule.new(date, false, 0, "scheduleA")
|
|
15
|
+
end
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
def test_priority
|
|
18
|
+
#it 'should return 0' do
|
|
19
|
+
assert_equal(0, @s00.priority)
|
|
20
|
+
end
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
def test_event_dates
|
|
23
|
+
#it 'should return Array of 1 item' do
|
|
24
|
+
results = @s00.event_dates
|
|
25
|
+
assert_equal([Date.new(2012, 10, 15)], results)
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
results = @s01.event_dates
|
|
28
|
+
assert_equal([Date.new(2012, 10, 15)], results)
|
|
29
|
+
end
|
|
30
30
|
end
|
data/test/test_todo.rb
CHANGED
|
@@ -6,45 +6,45 @@ require "helper"
|
|
|
6
6
|
#require "pkg/klass.rb"
|
|
7
7
|
|
|
8
8
|
class TC_Todo < Test::Unit::TestCase
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
9
|
+
def setup
|
|
10
|
+
today = Date.new(2012, 10, 15)
|
|
11
|
+
@t00 = Sculd::Plan::Todo.new(today, false, 10, 'todoA')
|
|
12
|
+
|
|
13
|
+
today = DateTime.new(2012, 10, 15, 23, 45, 00)
|
|
14
|
+
@t01 = Sculd::Plan::Todo.new(today, false, 10, 'todoA')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_priority
|
|
18
|
+
#it 'return 0 before the period.' do
|
|
19
|
+
today = Date.new(2012, 10, 1)
|
|
20
|
+
assert_equal(0, @t00.priority(today))
|
|
21
|
+
|
|
22
|
+
#it 'return REMINDER_PRIORITY when the day is today.' do
|
|
23
|
+
today = Date.new(2012, 10, 15)
|
|
24
|
+
assert_equal(10000, @t00.priority(today))
|
|
25
|
+
|
|
26
|
+
#it 'return values between REMINDER_PRIORITY and DEADLINE_PRIORITY during the period.' do
|
|
27
|
+
today = Date.new(2012, 10, 20)
|
|
28
|
+
assert_equal(15000, @t00.priority(today))
|
|
29
|
+
|
|
30
|
+
#it 'return DEADLINE_PRIORITY when the day is past.' do
|
|
31
|
+
today = Date.new(2012, 10, 30)
|
|
32
|
+
assert_equal(20000, @t00.priority(today))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_event_dates
|
|
36
|
+
results = @t00.event_dates
|
|
37
|
+
assert_equal(2, results.size)
|
|
38
|
+
assert_equal(Date.new(2012, 10, 15), results[0])
|
|
39
|
+
assert_equal(Date.new(2012, 10, 25), results[1])
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
results = @t01.event_dates
|
|
43
|
+
assert_equal(2 , results.size)
|
|
44
|
+
assert_equal(Date.new(2012, 10, 15), results[0] )
|
|
45
|
+
assert_equal(Date.new(2012, 10, 25), results[1] )
|
|
46
|
+
assert_equal(Date , results[0].class )
|
|
47
|
+
assert_equal(Date , results[1].class )
|
|
48
|
+
end
|
|
49
49
|
end
|
|
50
50
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sculd
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2014-
|
|
12
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rdoc
|
|
@@ -34,7 +34,7 @@ dependencies:
|
|
|
34
34
|
requirements:
|
|
35
35
|
- - ~>
|
|
36
36
|
- !ruby/object:Gem::Version
|
|
37
|
-
version: 1.
|
|
37
|
+
version: 1.7.2
|
|
38
38
|
type: :development
|
|
39
39
|
prerelease: false
|
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -42,7 +42,7 @@ dependencies:
|
|
|
42
42
|
requirements:
|
|
43
43
|
- - ~>
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: 1.
|
|
45
|
+
version: 1.7.2
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
47
|
name: jeweler
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -147,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
147
147
|
version: '0'
|
|
148
148
|
segments:
|
|
149
149
|
- 0
|
|
150
|
-
hash:
|
|
150
|
+
hash: -3471432712698996207
|
|
151
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
none: false
|
|
153
153
|
requirements:
|