sculd 0.0.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.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/CHANGES ADDED
@@ -0,0 +1,6 @@
1
+ = sdrt changelog
2
+
3
+ == Version 0.0.0
4
+
5
+ * Initial release.
6
+
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 2.11.0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.2.1"
12
+ gem "jeweler", "~> 1.8.4"
13
+ gem "simplecov", ">= 0"
14
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 ippei94da
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
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
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,29 @@
1
+ = sculd
2
+
3
+ 4 types of Plan's; Reminder, Deadline, Schedule, Todo.
4
+ Reminder: nil till the date, REMINDER_PRIORITY at the date, decrease after that.
5
+ Deadline: nil till the date, REMINDER_PRIORITY at the beginning,
6
+ increase after that,
7
+ DEADLINE_PRIORITY at the deadline
8
+ Todo: nil till the date, REMINDER_PRIORITY at the date, increase after that,
9
+ DEADLINE_PRIORITY at the end.
10
+ Schedule: no priority.
11
+
12
+ For tasks, two hight of priority are set; REMINDER_PRIORITY and DEADLINE_PRIORITY.
13
+
14
+
15
+ == Contributing to sculd
16
+
17
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
18
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
19
+ * Fork the project.
20
+ * Start a feature/bugfix branch.
21
+ * Commit and push until you are happy with your contribution.
22
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
23
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
24
+
25
+ == Copyright
26
+
27
+ Copyright (c) 2012 ippei94da. See LICENSE.txt for
28
+ further details.
29
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "sculd"
18
+ gem.homepage = "http://github.com/ippei94da/sculd"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Sculd, SChedULe Dealer.}
21
+ gem.description = %Q{Schedule management system using 'howm' like format. Plans, i.e., schedule(@), reminder(-), deadline(!), and tood(+), make events and tasks. Command 'sculd' can output events on each date and tasks with high priority. }
22
+ gem.email = "ippei94da@gmail.com"
23
+ gem.authors = ["ippei94da"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "sculd #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
data/bin/sculd ADDED
@@ -0,0 +1,50 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ # Command 'sculd' can show events and tasks.
5
+ # Events include schedule and deadline(start and end).
6
+ # Tasks include deadline, reminder and todo.
7
+
8
+ SCULD_DAT = "#{ENV['HOME']}/.sculd.dat"
9
+
10
+ require "pp"
11
+ require "optparse"
12
+ require "rubygems"
13
+ gem "sculd"
14
+ require "sculd"
15
+
16
+ # option analysis
17
+ OPTS = {}
18
+ op = OptionParser.new
19
+ op.on("-e day", "--event days", "Show events."){|v| OPTS[:event] = v.to_i}
20
+ op.on("-t num", "--task num" , "Show tasks." ){|v| OPTS[:task ] = v.to_i}
21
+ op.parse!(ARGV)
22
+
23
+ #num_day = ARGV.shift.to_i
24
+ #num_task = ARGV.shift.to_i
25
+ OPTS[:event] ||= 0
26
+ OPTS[:task ] ||= 0
27
+
28
+ if (( OPTS[:event] == 0) &&( OPTS[:task ] == 0))
29
+ puts "USAGE: sculd -e 7 -t 10"
30
+ exit
31
+ end
32
+
33
+
34
+ unless FileTest.exist? SCULD_DAT
35
+ # lines = File.open(SCULD_DAT, "r").readlines
36
+ #rescue
37
+ puts "Not found #{SCULD_DAT}. Exit."
38
+ exit
39
+ end
40
+
41
+ sm = Sculd::Manager.new(SCULD_DAT)
42
+ sm.show(OPTS[:event], OPTS[:task])
43
+
44
+ #while (true)
45
+ # s.show(OPTS[:event], OPTS[:task])
46
+ # command = STDIN.gets
47
+ # case
48
+ # when command ==
49
+ # end
50
+ #end
data/lib/sculd.rb ADDED
@@ -0,0 +1,12 @@
1
+ module Sculd; end
2
+
3
+ require "sculd/manager.rb"
4
+ require "sculd/plan.rb"
5
+ require "sculd/event.rb"
6
+ require "sculd/task.rb"
7
+
8
+ require "sculd/plan/deadline.rb"
9
+ require "sculd/plan/reminder.rb"
10
+ require "sculd/plan/schedule.rb"
11
+ require "sculd/plan/todo.rb"
12
+
@@ -0,0 +1,23 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "sculd.rb"
5
+
6
+ #
7
+ #
8
+ #
9
+ class Sculd::Event
10
+ attr_reader :datetime, :description
11
+
12
+ #
13
+ def initialize(datetime, description)
14
+ @datetime = datetime
15
+ @description = description
16
+ end
17
+
18
+ def date
19
+ @datetime.to_date
20
+ end
21
+
22
+ end
23
+
@@ -0,0 +1,107 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "date"
5
+ require "sculd.rb"
6
+ #require "/home/ippei/devel/sculd/lib/sculd.rb"
7
+
8
+ #
9
+ #
10
+ #
11
+ class Sculd::Manager
12
+ #WEEKDAYS = [ "日", "月", "火", "水", "木", "金", "土" ]
13
+ WEEKDAYS = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]
14
+
15
+ #
16
+ def initialize(file)
17
+ @source_file = file
18
+ load_file(@source_file)
19
+ end
20
+
21
+ def show(num_event, num_task)
22
+ show_events(num_event)
23
+ show_tasks(num_task)
24
+ end
25
+
26
+ private
27
+
28
+ # read, parse file and set data to @events and @tasks.
29
+ def load_file(file)
30
+ @plans = []
31
+
32
+ File.open(file, "r").readlines.each_with_index do |line, index|
33
+ begin
34
+ date, type, option = Sculd::Plan.parse(line)
35
+ option = option.to_i
36
+ next unless type
37
+ case type
38
+ when "@"
39
+ plan_type = Sculd::Plan::Schedule
40
+ when "!"
41
+ plan_type = Sculd::Plan::Deadline
42
+ option = 7 if option == 0
43
+ when "-"
44
+ plan_type = Sculd::Plan::Reminder
45
+ when "+"
46
+ plan_type = Sculd::Plan::Todo
47
+ option = 7 if option == 0
48
+ else
49
+ next
50
+ end
51
+ @plans << plan_type.new(date, option, line)
52
+ rescue
53
+ #puts "error occured at #{index}: #{line}"
54
+ end
55
+ end
56
+ end
57
+
58
+ # Show events in 'num' days from todary.
59
+ def show_events(num, today = Date.today, io = $stdout)
60
+ return if num == 0
61
+
62
+ d_e = days_events
63
+ io.puts "Events:"
64
+ num.times do |i|
65
+ date = today + i
66
+ events = d_e[date]
67
+ if events # if plan is not empty.
68
+ io.puts " #{date.to_s} #{WEEKDAYS[date.wday]}"
69
+ events.sort_by{|i| i.datetime}.each do |job|
70
+ io.puts " #{job.description.strip}"
71
+ end
72
+ io.puts
73
+ else
74
+ next
75
+ end
76
+ end
77
+ end
78
+
79
+ # Return a hash of dates and events.
80
+ # The eventes generated from @schedules sorted by date and time.
81
+ def days_events
82
+ results = {}
83
+ @plans.each do |plan|
84
+ plan.events.each do |event|
85
+ date = event.date
86
+ results[date] ||= []
87
+ results[date] << event
88
+ end
89
+ end
90
+ return results
91
+ end
92
+
93
+ # Show 'num' tasks of the highest priority.
94
+ def show_tasks(num, today = Date.today, io = $stdout)
95
+ return if num == 0
96
+
97
+ io.puts "Tasks:"
98
+ plans = @plans.sort_by {|plan| plan.priority(today)}.reverse
99
+ #pp plans
100
+
101
+ num = plans.size if plans.size < num
102
+ plans[0..(num-1)].each do |plan|
103
+ io.puts " #{plan.description.strip}"
104
+ end
105
+ end
106
+ end
107
+
data/lib/sculd/plan.rb ADDED
@@ -0,0 +1,51 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ #require "sculd/plan/deadline.rb"
5
+ #require "sculd/plan/reminder.rb"
6
+ #require "sculd/plan/schedule.rb"
7
+ #require "sculd/plan/todo.rb"
8
+
9
+ #
10
+ #
11
+ #
12
+ class Sculd::Plan
13
+ class NotDefinedError < Exception; end
14
+
15
+ attr_reader :description
16
+
17
+ REMINDER_PRIORITY = 10000
18
+ DEADLINE_PRIORITY = 20000
19
+
20
+ # Parse and return date, type, option.
21
+ def self.parse(str)
22
+ #/\[(\d{4})-(\d{2})-(\d{2})\]([@+!-])(\d*)/ =~ @line
23
+ #/\[\d{4}-\d{2}-\d{2}(?: \d{2}\:\d{2})?\][@+!-](\d*)(.*)/ =~ line
24
+ #/\[\d{4}-\d{2}-\d{2}(?: \d{2}\:\d{2})?\][@+!-](\d*)(.*)/ =~ str
25
+ #/\[(\d{4}-\d{2}-\d{2}(?: \d{2}\:\d{2})?\][@+!-](\d*)(.*)/ =~ str
26
+ /\[(\d{4}-\d{2}-\d{2})\]([@+!-])(\S*)(.*)$/ =~ str
27
+ #/\[(^]+)\](.)(\S*)/ =~ str
28
+ #date = DateTime::new($1.to_i, $2.to_i, $3.to_i)
29
+ datetime = DateTime::parse $1
30
+ type = $2
31
+ option = $3.to_s
32
+ return datetime, type, option
33
+ end
34
+
35
+ #
36
+ def initialize(datetime, option, description)
37
+ @datetime = datetime
38
+ @option = option
39
+ @description = description
40
+ end
41
+
42
+ # return priority of task calculated by equation defined in subclass.
43
+ def priority
44
+ raise NotDefinedError
45
+ end
46
+
47
+ def events
48
+ raise NotDefinedError
49
+ end
50
+ end
51
+
@@ -0,0 +1,33 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "sculd/event.rb"
5
+ require "sculd/plan.rb"
6
+
7
+ #
8
+ #
9
+ #
10
+ class Sculd::Plan::Deadline < Sculd::Plan
11
+
12
+ def priority(today)
13
+ @option = 1 if @option < 1
14
+ beginning = @datetime - @option
15
+ if today < beginning
16
+ return 0
17
+ elsif today <= @datetime
18
+ rp = Sculd::Plan::REMINDER_PRIORITY
19
+ dp = Sculd::Plan::DEADLINE_PRIORITY
20
+ return (rp + (dp - rp) * (today - beginning)/(@option.to_f)).to_i
21
+ else
22
+ return Sculd::Plan::DEADLINE_PRIORITY
23
+ end
24
+ end
25
+
26
+ def events
27
+ results = []
28
+ results << Sculd::Event.new(@datetime - @option, @description)
29
+ results << Sculd::Event.new(@datetime, @description)
30
+ return results
31
+ end
32
+ end
33
+
@@ -0,0 +1,25 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "sculd/event.rb"
5
+ require "sculd/plan.rb"
6
+
7
+ #
8
+ #
9
+ #
10
+ class Sculd::Plan::Reminder < Sculd::Plan
11
+ # value of @option does not work
12
+ def priority(today = Date.now)
13
+ if today < @datetime
14
+ return 0
15
+ else
16
+ #@option = 1 if @option < 1
17
+ return Sculd::Plan::REMINDER_PRIORITY - (today - @datetime) #/@option
18
+ end
19
+ end
20
+
21
+ def events
22
+ return [Sculd::Event.new(@datetime, @description)]
23
+ end
24
+ end
25
+
@@ -0,0 +1,19 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "sculd/event.rb"
5
+
6
+ #
7
+ #
8
+ #
9
+ class Sculd::Plan::Schedule < Sculd::Plan
10
+ #
11
+ def priority(today = Date.new)
12
+ return 0
13
+ end
14
+
15
+ def events
16
+ return [Sculd::Event.new(@datetime, @description)]
17
+ end
18
+ end
19
+
@@ -0,0 +1,35 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "sculd/event.rb"
5
+ require "sculd/plan.rb"
6
+
7
+ #
8
+ #
9
+ #
10
+ class Sculd::Plan::Todo < Sculd::Plan
11
+
12
+ #
13
+ def priority(today)
14
+ @option = 1 if @option < 1
15
+ beginning = @datetime
16
+ ending = @datetime + @option
17
+ if today < beginning
18
+ return 0
19
+ elsif today <= ending
20
+ rp = Sculd::Plan::REMINDER_PRIORITY
21
+ dp = Sculd::Plan::DEADLINE_PRIORITY
22
+ return (rp + (dp - rp) * (today - beginning)/(@option.to_f)).to_i
23
+ else
24
+ return Sculd::Plan::DEADLINE_PRIORITY
25
+ end
26
+ end
27
+
28
+ def events
29
+ results = []
30
+ results << Sculd::Event.new(@datetime, @description)
31
+ results << Sculd::Event.new(@datetime + @option, @description)
32
+ return results
33
+ end
34
+ end
35
+
data/lib/sculd/task.rb ADDED
@@ -0,0 +1,18 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "sculd.rb"
5
+
6
+ #
7
+ #
8
+ #
9
+ class Sculd::Task
10
+ attr_reader :priority, :description
11
+
12
+ #
13
+ def initialize(priority, description)
14
+ @priority = priority
15
+ @description = description
16
+ end
17
+ end
18
+
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Command" do
4
+ end
5
+
@@ -0,0 +1,46 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Sculd::Plan::Deadline do # E.g., Klass
4
+ context 'Date[2012-10-15], 10, [2012-10-15]!10 deadlineA' do
5
+
6
+ before do
7
+ today = Date.new(2012, 10, 15)
8
+ @d00 = Sculd::Plan::Deadline.new(today, 10, '[2012-10-15]!10 deadlineA')
9
+ end
10
+
11
+ describe '#priority' do # ''
12
+ context '' do
13
+ it 'return DEADLINE_PRIORITY when the day is today.' do
14
+ today = Date.new(2012, 10, 15)
15
+ @d00.priority(today).should == 20000
16
+ end
17
+
18
+ it 'return DEADLINE_PRIORITY when the day is past.' do
19
+ today = Date.new(2012, 10, 20)
20
+ @d00.priority(today).should == 20000
21
+ end
22
+
23
+ it 'return values between REMINDER_PRIORITY and DEADLINE_PRIORITY during the period.' do
24
+ today = Date.new(2012, 10, 10)
25
+ @d00.priority(today).should == 15000
26
+ end
27
+
28
+ it 'return 0 before the period.' do
29
+ today = Date.new(2012, 10, 1)
30
+ @d00.priority(today).should == 0
31
+ end
32
+ end
33
+ end
34
+
35
+ describe "#events" do
36
+ context '' do
37
+ it '' do
38
+ @d00.events.size.should == 2
39
+ @d00.events[0].date.should == Date.new(2012, 10, 5)
40
+ @d00.events[1].date.should == Date.new(2012, 10, 15)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+
@@ -0,0 +1,35 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Sculd::Event do # E.g., Klass
4
+ context 'normal' do # 'when stack is empty'
5
+ before do
6
+ datetime = DateTime.new(2012, 3, 4, 5, 6, 7)
7
+ @e00 = Sculd::Event.new(datetime, "abc")
8
+ end
9
+
10
+ describe '#date' do # ''
11
+ context '' do
12
+ it 'should return Date.new(2012, 3, 4)' do
13
+ @e00.date.should == Date.new(2012, 3, 4)
14
+ end
15
+ end
16
+ end
17
+
18
+ describe '#datetime' do # ''
19
+ context '' do
20
+ it 'should return DateTime.new(2012, 3, 4, 5, 6, 7)' do
21
+ @e00.datetime.should == DateTime.new(2012, 3, 4, 5, 6, 7)
22
+ end
23
+ end
24
+ end
25
+
26
+ describe '#description' do # ''
27
+ context '' do
28
+ it 'should return abc' do
29
+ @e00.description.should == "abc"
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+
data/spec/job_spec.rb ADDED
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Job" do
4
+ #it "fails" do
5
+ # fail "hey buddy, you should probably rename this file and start specing for real"
6
+ #end
7
+ end
@@ -0,0 +1,121 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ # coding: utf-8
3
+
4
+ #require "stringio"
5
+
6
+ class Sculd::Manager
7
+ public :load_file, :show_events, :days_events, :show_tasks
8
+ attr_accessor :plans
9
+ end
10
+
11
+ describe "Manager" do
12
+ context "empty" do
13
+ before do
14
+ @s00 = Sculd::Manager.new("spec/schedule/empty.dat")
15
+ end
16
+
17
+ describe "#load_file" do
18
+ it "should overwrite data" do
19
+ result = @s00.load_file("spec/schedule/schedule.dat")
20
+ @s00.plans.size.should == 4
21
+ @s00.plans[0].should be_kind_of Sculd::Plan
22
+ @s00.plans[1].should be_kind_of Sculd::Plan
23
+ @s00.plans[2].should be_kind_of Sculd::Plan
24
+ @s00.plans[3].should be_kind_of Sculd::Plan
25
+
26
+ result = @s00.load_file("spec/schedule/empty.dat")
27
+ @s00.plans.size.should == 0
28
+ end
29
+ end
30
+ end
31
+
32
+ context "when there are some plans" do
33
+ before do
34
+ @s01 = Sculd::Manager.new("spec/schedule/schedule.dat")
35
+ end
36
+
37
+ describe "#days_events" do
38
+ it 'should return hash dates as keys and events as values.' do
39
+ results = @s01.days_events
40
+ results.keys.should == [
41
+ Date.new(2012, 9, 15), #@ schedule a 2012, 09, 06),
42
+ Date.new(2012, 9, 9), #! deadline b 2012, 09, 06),
43
+ Date.new(2012, 9, 16), #! deadline b 2012, 09, 06),
44
+ Date.new(2012, 9, 17), #- reminder c 2012, 09, 06),
45
+ Date.new(2012, 9, 18), #+ todo d 2012, 09, 06),
46
+ Date.new(2012, 9, 25), #+ todo d 2012, 09, 06),
47
+ ]
48
+ results[Date.new(2012, 9, 15)].should be_kind_of Array
49
+ #pp results[Date.new(2012, 9, 15)][0]
50
+ results[Date.new(2012, 9, 15)][0].should be_kind_of Sculd::Event
51
+ end
52
+ end
53
+
54
+ describe "#show_events" do
55
+ it 'should return itemized days and events' do
56
+ io = StringIO.new
57
+ today = Date.new(2012, 9,6)
58
+ @s01.show_events(10, today, io)
59
+ io.rewind
60
+ results = io.readlines
61
+ #pp results
62
+ results.size.should == 7
63
+ results[0].should == "Events:\n"
64
+ results[1].should == " 2012-09-09 Sun\n"
65
+ results[2].should == " [2012-09-16]! deadline b\n"
66
+ results[3].should == "\n"
67
+ results[4].should == " 2012-09-15 Sat\n"
68
+ results[5].should == " [2012-09-15]@ schedule a\n"
69
+ results[6].should == "\n"
70
+ #results[].should == "\n"
71
+ #results[].should == " [2012-09-16]\n"
72
+ #results[].should == " [2012-09-16]! deadline b\n"
73
+ #results[].should == "\n"
74
+ #results[].should == " [2012-09-17]\n"
75
+ #results[].should == " [2012-09-17]- reminder c\n"
76
+ #results[].should == "\n"
77
+ #results[].should == " [2012-09-18]\n"
78
+ #results[].should == " [2012-09-18]+ todo d\n"
79
+ #results[].should == "\n"
80
+ #results[].should == " [2012-09-15]\n"
81
+ #results[].should == " [2012-09-18]+ todo d\n"
82
+ end
83
+ end
84
+
85
+ describe "#show_tasks" do
86
+ it 'should return sorted tasks' do
87
+ io = StringIO.new
88
+ today = Date.new(2012, 9,20)
89
+ @s01.show_tasks(3, today, io)
90
+ io.rewind
91
+ results = io.readlines
92
+ #pp results
93
+ results.size.should == 4
94
+ results[0].should == "Tasks:\n"
95
+ results[1].should == " [2012-09-16]! deadline b\n"
96
+ results[2].should == " [2012-09-18]+ todo d\n"
97
+ results[3].should == " [2012-09-17]- reminder c\n"
98
+ #results[4].should == " [2012-09-15]@ schedule a\n"
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+ #describe "Manager" do
105
+ # context "empty" do
106
+ # describe "#load_file" do
107
+ # result = @s00.load_file("spec/schedule/schedule.dat")
108
+ # it '' do
109
+ # @s00.plans.size.should == 4
110
+ # @s00.plans[0].should be_kind_of Sculd::Plan
111
+ # @s00.plans[1].should be_kind_of Sculd::Plan
112
+ # @s00.plans[2].should be_kind_of Sculd::Plan
113
+ # @s00.plans[3].should be_kind_of Sculd::Plan
114
+ #
115
+ # result = @s00.load_file("spec/schedule/empty.dat")
116
+ # @s00.plans.size.should == 0
117
+ # end
118
+ # end
119
+ # end
120
+ #end
121
+ #
data/spec/plan_spec.rb ADDED
@@ -0,0 +1,36 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Sculd::Plan do # E.g., Klass
4
+ context 'Class method' do # 'when stack is empty'
5
+ describe '#parse' do # ''
6
+ context '[2012-10-23]! deadlineA' do
7
+ it 'should return Date, !, deadlineA' do
8
+ a, b, c = Sculd::Plan.parse('[2012-10-23]! deadlineA')
9
+ a.should == Date.new(2012, 10, 23)
10
+ b.should == "!"
11
+ c.should == ""
12
+ end
13
+ end
14
+
15
+ context ' [2012-10-23]! deadlineA with space at head' do
16
+ it 'should return Date, !, deadlineA' do
17
+ a, b, c = Sculd::Plan.parse(' [2012-10-23]! deadlineA with space at head')
18
+ a.should == Date.new(2012, 10, 23)
19
+ b.should == "!"
20
+ c.should == ""
21
+ end
22
+ end
23
+
24
+ context '[2012-10-23]!10 deadline with option value' do
25
+ it 'should return Date, !, deadlineA' do
26
+ a, b, c = Sculd::Plan.parse( '[2012-10-23]!10 deadline with option value')
27
+ a.should == Date.new(2012, 10, 23)
28
+ b.should == "!"
29
+ c.should == "10"
30
+ end
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+
@@ -0,0 +1,38 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Sculd::Plan::Reminder do # E.g., Klass
4
+ context 'Date[2012-10-23], 10, [2012-10-23]- reminderA' do
5
+
6
+ before do
7
+ date = Date.new(2012, 10, 23)
8
+ @r00 = Sculd::Plan::Reminder.new(date, 10, '[2012-10-23]- reminderA')
9
+ end
10
+
11
+ describe '#priority' do # ''
12
+ context '' do
13
+ it 'return REMINDER_PRIORITY when the day is today .' do
14
+ date = Date.new(2012, 10, 23)
15
+ @r00.priority(date).should == 10000
16
+ end
17
+
18
+ it 'return REMINDER_PRIORITY -1 when the day is yesterday .' do
19
+ date = Date.new(2012, 10, 24)
20
+ @r00.priority(date).should == 9999
21
+ end
22
+ end
23
+ end
24
+
25
+ describe '#events' do # ''
26
+ context '' do
27
+ it 'return a Sculd::Event instance.' do
28
+ result = @r00.events
29
+ result.class.should == Array
30
+ result.size.should == 1
31
+ result[0].class.should == Sculd::Event
32
+ result[0].datetime.to_date.should == Date.new(2012, 10, 23)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+
File without changes
@@ -0,0 +1,5 @@
1
+ [2012-09-15]@ schedule a
2
+ [2012-09-16]! deadline b
3
+ [2012-09-17]- reminder c
4
+ [2012-09-18]+ todo d
5
+ normal line
@@ -0,0 +1,30 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Sculd::Plan::Schedule do # E.g., Klass
4
+ context 'normal' do # 'when stack is empty'
5
+ before do
6
+ date = Date.new(2012, 10, 15)
7
+ @s00 = Sculd::Plan::Schedule.new(date, 0, "[2012-10-15]@ scheduleA")
8
+ end
9
+
10
+ describe '#priority' do # ''
11
+ context '' do
12
+ it 'should return 0' do
13
+ @s00.priority.should == 0
14
+ end
15
+ end
16
+ end
17
+
18
+ describe '#events' do # ''
19
+ context '' do
20
+ it 'should return Array of 1 item' do
21
+ @s00.events.class == Array
22
+ @s00.events.size == 1
23
+ @s00.events[0].date == Date.new(2012, 10, 15)
24
+ end
25
+ end
26
+ end
27
+
28
+ end
29
+ end
30
+
@@ -0,0 +1,4 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Sculd" do
4
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'sculd'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
data/spec/todo_spec.rb ADDED
@@ -0,0 +1,48 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Sculd::Plan::Todo do # E.g., Klass
4
+ context 'Date[2012-10-15], 10, [2012-10-15]+10 todoA' do
5
+
6
+ before do
7
+ today = Date.new(2012, 10, 15)
8
+ @t00 = Sculd::Plan::Todo.new(today, 10, '[2012-10-15]+10 todoA')
9
+ end
10
+
11
+ describe '#priority' do # ''
12
+ context '' do
13
+
14
+ it 'return 0 before the period.' do
15
+ today = Date.new(2012, 10, 1)
16
+ @t00.priority(today).should == 0
17
+ end
18
+
19
+ it 'return REMINDER_PRIORITY when the day is today.' do
20
+ today = Date.new(2012, 10, 15)
21
+ @t00.priority(today).should == 10000
22
+ end
23
+
24
+ it 'return values between REMINDER_PRIORITY and DEADLINE_PRIORITY during the period.' do
25
+ today = Date.new(2012, 10, 20)
26
+ @t00.priority(today).should == 15000
27
+ end
28
+
29
+ it 'return DEADLINE_PRIORITY when the day is past.' do
30
+ today = Date.new(2012, 10, 30)
31
+ @t00.priority(today).should == 20000
32
+ end
33
+
34
+ end
35
+ end
36
+
37
+ describe "#events" do
38
+ context '' do
39
+ it '' do
40
+ @t00.events.size.should == 2
41
+ @t00.events[0].date.should == Date.new(2012, 10, 15)
42
+ @t00.events[1].date.should == Date.new(2012, 10, 25)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sculd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - ippei94da
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &77033260 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.11.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *77033260
25
+ - !ruby/object:Gem::Dependency
26
+ name: rdoc
27
+ requirement: &77032900 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.12'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *77032900
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: &77032620 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.2.1
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *77032620
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &77032340 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.4
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *77032340
58
+ - !ruby/object:Gem::Dependency
59
+ name: simplecov
60
+ requirement: &77032060 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *77032060
69
+ description: ! 'Schedule management system using ''howm'' like format. Plans, i.e.,
70
+ schedule(@), reminder(-), deadline(!), and tood(+), make events and tasks. Command
71
+ ''sculd'' can output events on each date and tasks with high priority. '
72
+ email: ippei94da@gmail.com
73
+ executables:
74
+ - sculd
75
+ extensions: []
76
+ extra_rdoc_files:
77
+ - LICENSE.txt
78
+ - README.rdoc
79
+ files:
80
+ - .document
81
+ - .rspec
82
+ - CHANGES
83
+ - Gemfile
84
+ - LICENSE.txt
85
+ - README.rdoc
86
+ - Rakefile
87
+ - VERSION
88
+ - bin/sculd
89
+ - lib/sculd.rb
90
+ - lib/sculd/event.rb
91
+ - lib/sculd/manager.rb
92
+ - lib/sculd/plan.rb
93
+ - lib/sculd/plan/deadline.rb
94
+ - lib/sculd/plan/reminder.rb
95
+ - lib/sculd/plan/schedule.rb
96
+ - lib/sculd/plan/todo.rb
97
+ - lib/sculd/task.rb
98
+ - spec/command_spec.rb
99
+ - spec/deadline_spec.rb
100
+ - spec/event_spec.rb
101
+ - spec/job_spec.rb
102
+ - spec/manager_spec.rb
103
+ - spec/plan_spec.rb
104
+ - spec/reminder_spec.rb
105
+ - spec/schedule/empty.dat
106
+ - spec/schedule/schedule.dat
107
+ - spec/schedule_spec.rb
108
+ - spec/sculd_spec.rb
109
+ - spec/spec_helper.rb
110
+ - spec/todo_spec.rb
111
+ homepage: http://github.com/ippei94da/sculd
112
+ licenses:
113
+ - MIT
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ segments:
125
+ - 0
126
+ hash: 792041583
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 1.8.11
136
+ signing_key:
137
+ specification_version: 3
138
+ summary: Sculd, SChedULe Dealer.
139
+ test_files: []