todo 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- data.tar.gz: 59080b13500a1e05d58a5505d101d870732b1bd8
4
- metadata.gz: aed1b7b5805537d015c1402c8d297d237ca32542
5
- SHA512:
6
- data.tar.gz: a93f3040b469d5cc553c5bef1983285052d5faafe568265df8085f382d160d72aaa108f916137dd4d5e23027c3269516a7c476e7487a14438a5fec3081f22efa
7
- metadata.gz: 586f3e600d86f9da380b5981add91118957cb9dedccf3c367df97958bd1d1bba4f4205a6d291073a516630ce8be1f1a83ce863671b0b5c7ff2646b5b76fae959
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 24203ee1ee57fddc956f45411f545fc2424435c9
4
+ data.tar.gz: 0852e391ab564895c1dc0b36bd9c7f085cacd442
5
+ SHA512:
6
+ metadata.gz: a4313713da987294539c5da5e65efbaede7e2643832048a95b705af8469a2030508addbfb83d8176e0004accb1485ad52a062279b6f2d328ae0050bd31fbb14b
7
+ data.tar.gz: 288e3c1f27a9263de0a21bf4246ab956e3342a70df6204a99547eac422bb7742ba007f28ff7d986940a43241c95bb42e27ba4e1f74090102d049e07cce190b3d
@@ -4,51 +4,38 @@ Really want to get things done? Don't want to juggle with web based todo lists?
4
4
  Get your things done with command-line. No hassle, no distraction - Try out todo ruby gem.
5
5
 
6
6
 
7
- == FEATURES:
7
+ == Features
8
8
 
9
9
  * Uses human readable YAML to store the todo lists (You could edit the todo list manually)
10
- * Supportss project specific todo lists. (Just run 'todo create' in your project directory)
11
- * Supports tagging.
10
+ * Supports project specific todo lists.
11
+ (Creates automatically a file '.todo.yml' in the project-directory you are using it)
12
+ * Supports tagging
12
13
 
13
14
  == Install
14
15
 
15
- First make sure you install the dependency gems.
16
- sudo gem install main
17
- sudo gem install highline
16
+ gem install todo
18
17
 
19
- then;
20
- sudo gem install todo
21
-
22
- You can also install from github:
23
- gem sources -a http://gems.github.com
24
- sudo gem install laktek-todo
25
-
26
- == Example:
18
+ == Example
27
19
 
28
20
  Here is a small sample on how to use todo gem
29
21
 
30
22
  #visit your project folder
31
23
  cd projects/newapp
32
24
 
33
- #create a new todo list for the project
34
- todo create
35
-
36
- #add a new task
25
+ #add a task
37
26
  todo add "write the specs"
38
- - add tags : important, due:24/08/2008
27
+ - add tags : important, due:24/08/2014
39
28
 
40
29
  #listing all tasks
41
- todo list --all
30
+ todo list
42
31
 
43
32
  #listing tasks tagged 'important'
44
33
  todo list --tag important
45
34
 
46
- #removing a task by name
47
- todo remove "write the specs"
48
-
49
- #removing a task by index
50
- todo remove -i 1
35
+ #removing a task by his number (index)
36
+ todo remove 1
51
37
 
52
38
  == Issues/Improvements
53
39
 
54
- Todo is still its infant days and have very minimum functionality. If you come across any issues or like to suggest any improvements, please feel free to contact me : lakshan [at] web2media [dot] net
40
+ Todo is very minimalistic by its nature.
41
+ Feel free to try, fork and send PRs.
@@ -1,6 +1,5 @@
1
1
  require 'todo/version'
2
- require 'todo/list'
3
- require 'todo/store'
2
+ require 'todo/controller'
4
3
 
5
4
  module Todo
6
5
 
@@ -1,134 +1,65 @@
1
1
  require 'rubygems'
2
2
  require 'main'
3
- require 'highline/import'
4
3
  require 'fileutils'
4
+ require 'highline/import'
5
5
 
6
- def read_list(environment)
7
- file = environment.nil? ? Todo::Store.read('.todo/list.yml') : Todo::Store.read(environment)
8
- if file
9
- yield(file)
10
- else
11
- say "Todo list file is invalid or do not exist."
12
- end
13
- end
14
-
15
- def write_list(list, environment)
16
- file = environment.nil? ? Todo::Store.write(list, '.todo/list.yml') : Todo::Store.write(list, environment)
17
- end
6
+ #
7
+ TODO_FILE = '.todo.yml'
8
+ ADD_DESC = "Adds a new task"
9
+ REMOVE_DESC = "Removes a task from this todo list"
10
+ LIST_DESC = "Lists the tasks"
11
+ #
18
12
 
19
13
  Main {
14
+
20
15
  def run
21
16
  puts "todo [command] --help for usage instructions."
22
- puts "The available commands are: \n add, remove, list, modify."
23
- end
24
-
25
- mode 'create' do
26
- description 'Creates a new todo list for this directory'
27
-
28
- def run
29
- unless File.exist?(".todo/list.yml")
30
- FileUtils.makedirs(".todo")
31
- newfile = File.new(".todo/list.yml", "w+")
32
- say "Created a new todo list inside this directory" if newfile
33
- newfile.close
34
- else
35
- say "Todo list already exists inside this directory"
36
- end
37
- end
17
+ puts
18
+ puts "The available commands are:"
19
+ puts " - add => #{ADD_DESC}"
20
+ puts " - remove => #{REMOVE_DESC}"
21
+ puts " - list => #{LIST_DESC}"
22
+ puts
38
23
  end
39
24
 
40
25
  mode 'add' do
41
- description 'Adds a new todo item'
42
- argument('item'){
43
- description 'todo item to add'
44
- }
26
+ description ADD_DESC
27
+ argument('task'){ description 'Task to add' }
45
28
 
46
- environment('FILE'){
47
- synopsis 'export FILE=path'
48
- }
49
-
50
- option('notags', 'n'){
29
+ option('notags', 'n'){
51
30
  cast :bool
52
31
  default false
53
- }
54
-
55
- def run
56
- unless params['notags'].value
57
- tags = ask("Enter tags for this item (separate with commas) ", lambda {|str|
58
- str.split(/,\s*/) })
59
- end
32
+ }
60
33
 
61
- read_list(params['FILE'].value) do |list|
62
- list.add(params['item'].value, tags)
63
- say "Successfully added your task." if write_list(list, params['FILE'].value)
64
- end
65
- end
34
+ define_method(:run) { say(Todo::add_task(TODO_FILE,
35
+ params['notags'].value,
36
+ params['task'].value)) }
66
37
  end
67
38
 
68
39
  mode 'remove' do
69
- description 'Removes an item from todo list'
70
-
71
- environment('FILE'){
72
- synopsis 'export FILE=path'
73
- }
40
+ description REMOVE_DESC
74
41
 
75
- argument('item'){
76
- argument_optional
77
- description 'Name of the todo item to remove'
78
- }
79
-
80
- option('index', 'i'){
42
+ argument('index'){
43
+ required
81
44
  cast :int
82
- argument :required
83
- description 'Index of the todo item to remove (starting from 1). Use instead of item name'
45
+ validate { |index| index>0 }
46
+ description 'Task number to remove'
84
47
  }
85
48
 
86
- def run
87
- read_list(params['FILE'].value) do |list|
88
- if list.remove(params['item'].value || params['index'].value)
89
- say "Removed item from the list." if write_list(list, params['FILE'].value)
90
- else
91
- say "Could not find item to remove."
92
- end
93
- end
94
- end
49
+ define_method(:run) { say(Todo::del_task(TODO_FILE,params['index'].value)) }
95
50
  end
96
51
 
97
52
  mode 'list' do
98
- description 'Lists todo items'
99
-
100
- environment('FILE'){
101
- synopsis 'export barfoo=value'
102
- }
53
+ description LIST_DESC
103
54
 
104
- option('tag', 't'){
105
- argument_required
106
- }
55
+ option('tag', 't') { argument_required }
107
56
 
108
- option('all=[all]', 'a'){ # note shortcut syntax for optional args
109
- #argument_optional # we could also use this method
110
- cast :bool
111
- default false
57
+ option('all=[all]', 'a'){
58
+ cast :bool
59
+ default false
112
60
  }
113
61
 
114
- def run
115
- read_list(params['FILE'].value) do |list|
116
-
117
- if params['tag'].given?
118
- title = "Listing todos tagged '#{params['tag'].value}'"
119
- tasks = list.tagged(params['tag'].value)
120
- else
121
- title = "Listing all todos"
122
- tasks = list
123
- end
124
-
125
- say title
126
- tasks.each do |task, tags|
127
- tag_string = ("(#{tags.join(", ")})") unless tags.include?(nil)
128
- say " - #{task} #{tag_string} \n"
129
- end
62
+ define_method(:run) { say(Todo::show_tasks(TODO_FILE,params['tag'].value)) }
130
63
 
131
- end
132
- end
133
64
  end
134
65
  }
@@ -0,0 +1,70 @@
1
+ require 'fileutils'
2
+ require 'highline/import'
3
+ require 'SecureRandom'
4
+ require 'yaml'
5
+
6
+ module Todo
7
+
8
+ def self.add_task(filename,notags,description,taskid=SecureRandom.hex(4),created_at=Time.now.to_s)
9
+ tags = []
10
+ _tasks = load_tasks(filename)
11
+ tags = ask("(optional) Enter comma-separated tags: ", lambda {|s| s.split(/,\s*/) }) unless notags
12
+
13
+ _tasks << {
14
+ "taskid" => taskid,
15
+ "created_at" => created_at,
16
+ "description" => description,
17
+ "tags" => tags
18
+ }
19
+
20
+ "<%= color('Task added', :green) %>" if(save_tasks(filename,_tasks))
21
+ end
22
+
23
+ def self.del_task(filename,index)
24
+ _tasks=load_tasks(filename)
25
+ if(_tasks.delete_at(index-1) && save_tasks(filename,_tasks))
26
+ "<%= color('Task deleted', :yellow) %>"
27
+ else
28
+ "<%= color('No task deleted', :red) %>"
29
+ end
30
+ end
31
+
32
+ def self.show_tasks(filename,tag)
33
+ _tasks=load_tasks(filename)
34
+
35
+ _rtn = "Listing tasks (#{tag ? tag.to_s : 'all'})\n"
36
+ _tasks.each_with_index do |task, i|
37
+ next if(tag && !(task["tags"].include?(tag)))
38
+ _rtn += "(#{i+1})\n"
39
+ _rtn += "\t taskid : #{task['taskid']}\n"
40
+ _rtn += "\t created_at : #{task['created_at']}\n"
41
+ _rtn += "\t description : <%= color('"+task['description']+"', :yellow) %>\n"
42
+ unless(task['tags'].empty?)
43
+ _rtn += "\t tags : #{task['tags']}\n\n"
44
+ end
45
+ end
46
+ _rtn
47
+ end
48
+
49
+ #
50
+
51
+ def self.save_tasks(filename,tasks,file=File)
52
+ begin
53
+ File.open(filename,"w+") { |f| f << tasks.to_yaml }
54
+ rescue
55
+ nil
56
+ end
57
+ end
58
+
59
+ def self.load_tasks(filename)
60
+ begin
61
+ _tasks = YAML::load(File.open(filename))
62
+ rescue
63
+ nil
64
+ end
65
+ _tasks ? _tasks : []
66
+ end
67
+
68
+ private_class_method :save_tasks, :load_tasks
69
+
70
+ end
@@ -1,6 +1,6 @@
1
1
  module Todo
2
2
  MAJOR = 0
3
- MINOR = 1
3
+ MINOR = 2
4
4
  TINY = 0
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join('.')
@@ -0,0 +1,70 @@
1
+ require 'todo/controller'
2
+
3
+ RSpec.describe 'Todo::Controller' do
4
+
5
+ let(:filename) { ".todo.yml" }
6
+
7
+ let(:empty_task_list) { [] }
8
+ let(:created_at) { Time.now.to_s }
9
+ let(:one_todo_item) { [{ "taskid"=>"123abc",
10
+ "created_at"=>created_at,
11
+ "description"=>":-)",
12
+ "tags"=>[]}] }
13
+ let(:new_task_list) { [
14
+ { "taskid"=>"123abc",
15
+ "created_at"=>created_at,
16
+ "description"=>":-)",
17
+ "tags"=>[] },
18
+ { "taskid"=>"456def",
19
+ "created_at"=>created_at,
20
+ "description"=>":-D",
21
+ "tags"=>[] },
22
+ ] }
23
+
24
+ context "add task" do
25
+ it "should create the file if it does not exist" do
26
+ expect(Todo).to receive(:load_tasks).with(filename).and_return(empty_task_list)
27
+ expect(Todo).to receive(:save_tasks).with(filename,one_todo_item).and_return(true)
28
+ expect(Todo::add_task(filename,true,":-)","123abc",created_at)).to eq("<%= color('Task added', :green) %>")
29
+ end
30
+
31
+ it "should add another task to the existing ones" do
32
+ expect(Todo).to receive(:load_tasks).with(filename).and_return(one_todo_item)
33
+ expect(Todo).to receive(:save_tasks).with(filename,new_task_list).and_return(true)
34
+ expect(Todo::add_task(filename,true,":-D","456def")).to eq("<%= color('Task added', :green) %>")
35
+ end
36
+ end
37
+
38
+ context "del task" do
39
+ it "should delete a task" do
40
+ expect(Todo).to receive(:load_tasks).with(filename).and_return(new_task_list)
41
+ expect(Todo).to receive(:save_tasks).with(filename,one_todo_item).and_return(true)
42
+ expect(Todo::del_task(filename,2)).to eq("<%= color('Task deleted', :yellow) %>")
43
+ end
44
+
45
+ it "should delete nothing if wrong index" do
46
+ expect(Todo).to receive(:load_tasks).with(filename).and_return(new_task_list)
47
+ expect(Todo).not_to receive(:save_tasks).with(any_args)
48
+ expect(Todo::del_task(filename,99)).to eq("<%= color('No task deleted', :red) %>")
49
+ end
50
+ end
51
+
52
+ context "show tasks" do
53
+ it "should show nothing when no tasks in the list" do
54
+ expect(Todo).to receive(:load_tasks).with(filename).and_return(empty_task_list)
55
+ expect(Todo::show_tasks(filename,nil)).to eq("Listing tasks (all)\n")
56
+ end
57
+
58
+ it "should show all tasks when no tag given" do
59
+ expect(Todo).to receive(:load_tasks).with(filename).and_return(one_todo_item)
60
+ final = "Listing tasks (all)\n(1)\n\t taskid : 123abc\n\t created_at : #{created_at}\n\t description : <%= color(':-)', :yellow) %>\n"
61
+ expect(Todo::show_tasks(filename,nil)).to eq(final)
62
+ end
63
+
64
+ it "should show only tagged tasks when tag given" do
65
+ expect(Todo).to receive(:load_tasks).with(filename).and_return(new_task_list)
66
+ expect(Todo::show_tasks(filename,["a"])).to eq("Listing tasks ([\"a\"])\n")
67
+ end
68
+ end
69
+
70
+ end
@@ -6,11 +6,11 @@ require 'todo/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "todo"
8
8
  spec.version = Todo::VERSION
9
- spec.authors = ["Lakshan Perera", "Aniket Pant"]
10
- spec.email = ["lakshan@web2media.net", "me@aniketpant.com"]
9
+ spec.authors = ["Lakshan Perera", "Aniket Pant", "Dennis Theisen"]
10
+ spec.email = ["lakshanlaktek.com"]
11
11
  spec.description = %q{simple command line todo list manager}
12
12
  spec.summary = %q{simple command line todo list manager}
13
- spec.homepage = %q{http://todo.rubyforge.org}
13
+ spec.homepage = %q{http://github.com/laktek/todo}
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec", "~> 2.6"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
24
 
25
25
  spec.add_runtime_dependency "main", ">= 2.8.2"
26
26
  spec.add_runtime_dependency "highline", ">= 1.4.0"
metadata CHANGED
@@ -1,80 +1,96 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: todo
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Lakshan Perera
8
8
  - Aniket Pant
9
+ - Dennis Theisen
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
-
13
- date: 2013-05-23 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
13
+ date: 2014-07-21 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- requirements:
20
- - - ~>
21
- - !ruby/object:Gem::Version
22
- version: "1.3"
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
23
22
  type: :development
24
- version_requirements: *id001
25
- - !ruby/object:Gem::Dependency
26
- name: rake
27
23
  prerelease: false
28
- requirement: &id002 !ruby/object:Gem::Requirement
29
- requirements:
30
- - &id006
31
- - ">="
32
- - !ruby/object:Gem::Version
33
- version: "0"
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '1.3'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rake
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
34
36
  type: :development
35
- version_requirements: *id002
36
- - !ruby/object:Gem::Dependency
37
- name: rspec
38
37
  prerelease: false
39
- requirement: &id003 !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- version: "2.6"
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rspec
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.0'
44
50
  type: :development
45
- version_requirements: *id003
46
- - !ruby/object:Gem::Dependency
47
- name: main
48
51
  prerelease: false
49
- requirement: &id004 !ruby/object:Gem::Requirement
50
- requirements:
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '3.0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: main
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
51
61
  - - ">="
52
- - !ruby/object:Gem::Version
62
+ - !ruby/object:Gem::Version
53
63
  version: 2.8.2
54
64
  type: :runtime
55
- version_requirements: *id004
56
- - !ruby/object:Gem::Dependency
57
- name: highline
58
65
  prerelease: false
59
- requirement: &id005 !ruby/object:Gem::Requirement
60
- requirements:
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 2.8.2
71
+ - !ruby/object:Gem::Dependency
72
+ name: highline
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
61
75
  - - ">="
62
- - !ruby/object:Gem::Version
76
+ - !ruby/object:Gem::Version
63
77
  version: 1.4.0
64
78
  type: :runtime
65
- version_requirements: *id005
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 1.4.0
66
85
  description: simple command line todo list manager
67
- email:
68
- - lakshan@web2media.net
69
- - me@aniketpant.com
70
- executables:
86
+ email:
87
+ - lakshanlaktek.com
88
+ executables:
71
89
  - todo
72
90
  extensions: []
73
-
74
91
  extra_rdoc_files: []
75
-
76
- files:
77
- - .gitignore
92
+ files:
93
+ - ".gitignore"
78
94
  - Gemfile
79
95
  - History.txt
80
96
  - LICENSE.txt
@@ -83,35 +99,33 @@ files:
83
99
  - bin/todo
84
100
  - lib/todo.rb
85
101
  - lib/todo/cli.rb
86
- - lib/todo/list.rb
87
- - lib/todo/store.rb
102
+ - lib/todo/controller.rb
88
103
  - lib/todo/version.rb
89
- - spec/todo_list_spec.rb
90
- - spec/todo_store_spec.rb
104
+ - spec/todo_controller_spec.rb
91
105
  - todo.gemspec
92
- homepage: http://todo.rubyforge.org
93
- licenses:
106
+ homepage: http://github.com/laktek/todo
107
+ licenses:
94
108
  - MIT
95
109
  metadata: {}
96
-
97
110
  post_install_message:
98
111
  rdoc_options: []
99
-
100
- require_paths:
112
+ require_paths:
101
113
  - lib
102
- required_ruby_version: !ruby/object:Gem::Requirement
103
- requirements:
104
- - *id006
105
- required_rubygems_version: !ruby/object:Gem::Requirement
106
- requirements:
107
- - *id006
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
108
124
  requirements: []
109
-
110
125
  rubyforge_project:
111
- rubygems_version: 2.0.3
126
+ rubygems_version: 2.2.0
112
127
  signing_key:
113
128
  specification_version: 4
114
129
  summary: simple command line todo list manager
115
- test_files:
116
- - spec/todo_list_spec.rb
117
- - spec/todo_store_spec.rb
130
+ test_files:
131
+ - spec/todo_controller_spec.rb
@@ -1,25 +0,0 @@
1
- module Todo
2
-
3
- class List < Hash
4
-
5
- def tagged(tag)
6
- self.reject do |name, tags|
7
- not tags.include?(tag)
8
- end
9
- end
10
-
11
- def add(task, *tags)
12
- self.store(task, tags.flatten)
13
- self
14
- end
15
-
16
- #Returns the list after removing specific item
17
- def remove(task)
18
- #find key by index
19
- task = self.keys[task - 1] if task.instance_of? Fixnum
20
- self if self.delete(task)
21
- end
22
-
23
- end
24
- end
25
-
@@ -1,26 +0,0 @@
1
- require 'rubygems'
2
- require 'yaml'
3
-
4
- module Todo
5
- class Store
6
- def self.read(file)
7
- begin
8
- loaded_list = YAML::load( File.open( file ) )
9
- loaded_list ? List[loaded_list] : List.new
10
- rescue
11
- nil
12
- end
13
- end
14
-
15
- def self.write(list, file)
16
- begin
17
- File.open( file, 'w' ) do |f|
18
- f << list.to_yaml
19
- end
20
- rescue
21
- nil
22
- end
23
- end
24
-
25
- end
26
- end
@@ -1,63 +0,0 @@
1
- require 'todo/list'
2
-
3
- describe "Todo::List" do
4
-
5
- describe "filtering by tag" do
6
- before(:each) do
7
- @todolist = Todo::List["dummy task" => ["added:31-07-2008", "important"], "Buy milk" => ["important", "home"]]
8
- @list_with_task_tagged_home = {"Buy milk" => ["important", "home"]}
9
- end
10
-
11
- it "should return matched items by tag" do
12
- @todolist.tagged("important").should == @todolist
13
- end
14
-
15
- it "should filter items by tags" do
16
- @todolist.tagged("home").should == @list_with_task_tagged_home
17
- end
18
-
19
- it "should be able to apply chain of filters" do
20
- @todolist.tagged("important").tagged("home").should == @list_with_task_tagged_home
21
- end
22
-
23
- end
24
-
25
- describe "add" do
26
- before(:each) do
27
- @todolist =Todo::List["dummy task" => ["added:31-07-2008", "important"]]
28
- @after_list =Todo::List["dummy task" => ["added:31-07-2008", "important"], "Buy milk" => []]
29
- end
30
-
31
- it "should add new item to the exisitng task list" do
32
- @todolist.add("Buy milk").should == @after_list
33
- end
34
-
35
- it "should accept list of tags with the item" do
36
- list_with_tags_added = {"dummy task" => ["added:31-07-2008", "important"], "Buy milk" => ["important", "assigned:mom"]}
37
-
38
- @todolist.add("Buy milk", "important", "assigned:mom").should == list_with_tags_added
39
- end
40
-
41
- end
42
-
43
- describe "remove" do
44
- before(:each) do
45
- @todolist =Todo::List["dummy task" => ["added:31-07-2008", "important"], "Buy milk" => []]
46
- @after_list =Todo::List["dummy task" => ["added:31-07-2008", "important"]]
47
- end
48
-
49
- it "should remove a task by name" do
50
- @todolist.remove("Buy milk").should == @after_list
51
- end
52
-
53
- it "should remove a task by its index" do
54
- @todolist.remove(2).should == @after_list
55
- end
56
-
57
- it "should return nil if the task is not found" do
58
- @todolist.remove("not done").should == nil
59
- end
60
-
61
- end
62
-
63
- end
@@ -1,8 +0,0 @@
1
- require 'todo/store'
2
-
3
- describe "Todo::CLI" do
4
- it "should read the YAML file and output Todo::List hash" do
5
- #list = {"Buy milk" => ["important", "home"]}
6
- #Todo::Store.read(list.to_yaml).should be_an_instance_of(Todo::List)
7
- end
8
- end