to-do 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
- #to-do 1.1.0
1
+ #to-do 1.1.1
2
2
 
3
- A simple command line todo application.
3
+ A simple command line todo application.
4
4
 
5
- ##What's New in 1.1.0
5
+ ##What's new in 1.1.1
6
+ * Bug fixes
7
+
8
+ ##What's new in 1.1
6
9
  * Command shortcuts
7
10
  * Undo completing an item
8
11
  * Colored Display
@@ -35,27 +38,27 @@ A simple command line todo application.
35
38
  todo add Write Paper
36
39
  todo a Do Laundy
37
40
  todo a Clean Things
38
-
41
+
39
42
  ###Display the current list
40
-
43
+
41
44
  todo display
42
45
  todo d
43
-
46
+
44
47
  ********************************
45
48
  * My New Todo List *
46
49
  ********************************
47
-
50
+
48
51
  1. Cook Dinner
49
52
  2. Write Paper
50
53
  3. Do Laundry
51
54
  4. Clean Things
52
-
55
+
53
56
  Completed: 0/4
54
-
57
+
55
58
  ###Finish a task
56
59
  todo finish -n 2
57
60
  todo f Clean Things
58
-
61
+
59
62
  ********************************
60
63
  * My New Todo List *
61
64
  ********************************
@@ -66,24 +69,24 @@ A simple command line todo application.
66
69
  Completed: 2/4
67
70
  2. Write Paper
68
71
  4. Clean Things
69
-
72
+
70
73
  ###Undo completing a task
71
74
  todo undo write paper
72
75
  todo u -n 2
73
-
74
- ###Clear completed tasks
75
-
76
+
77
+ ###Clear completed tasks
78
+
76
79
  todo clear
77
80
 
78
81
  ###Clear the entire list and reset the count
79
82
 
80
83
  todo clear -a
81
-
84
+
82
85
  ###View usage details
83
-
86
+
84
87
  todo -h
85
88
  todo --help
86
-
89
+
87
90
  ###View verison
88
91
  todo -v
89
92
  todo --version
@@ -95,7 +98,7 @@ A simple command line todo application.
95
98
  * Tab Completion
96
99
 
97
100
  ##Contributing to to-do
98
-
101
+
99
102
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
100
103
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
101
104
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
data/bin/todo CHANGED
@@ -6,4 +6,4 @@ else
6
6
  require File.join(File.dirname(__FILE__),'..','lib','to-do')
7
7
  end
8
8
 
9
- Todo::CLI.parse
9
+ Todo::CLI.parse
data/lib/to-do/cli.rb CHANGED
@@ -7,59 +7,59 @@ $settings = ENV["HOME"]+"/.todo/config.yml"
7
7
  module Todo
8
8
  module CLI
9
9
  extend self
10
- # Displays the given todo list
11
- WORKING_LIST=YAML.load_file(File.join(Config[:lists_directory],
12
- Config[:working_list_name]+'.yml')) if File.exists?(File.join(Config[:lists_directory],
10
+ # Displays the given todo list
11
+ WORKING_LIST=YAML.load_file(File.join(Config[:lists_directory],
12
+ Config[:working_list_name]+'.yml')) if File.exists?(File.join(Config[:lists_directory],
13
13
  Config[:working_list_name]+'.yml'))
14
14
 
15
- def display name
15
+ def display list = WORKING_LIST
16
16
  puts "********************************".colorize(:light_red)
17
- puts name.center(32).colorize(:light_cyan)
17
+ puts list.name.center(32).colorize(:light_cyan)
18
18
  puts "********************************".colorize(:light_red)
19
19
  puts
20
20
  puts "Todo:".colorize(:light_green)
21
- WORKING_LIST.tasks.each do |k,v|
21
+ list.tasks.each do |k,v|
22
22
  printf "%4d. ".to_s.colorize(:light_yellow), k
23
23
  puts v
24
24
  end
25
25
  print "\nCompleted:".colorize(:light_green)
26
- printf "%36s\n", "#{WORKING_LIST.completed_count}/#{WORKING_LIST.count}".colorize(:light_cyan)
27
- WORKING_LIST.completed_tasks.each do |k,v|
26
+ printf "%36s\n", "#{list.completed_count}/#{list.count}".colorize(:light_cyan)
27
+ list.completed_tasks.each do |k,v|
28
28
  printf "%4d. ".to_s.colorize(:light_yellow), k
29
29
  puts v
30
30
  end
31
31
  puts
32
32
  end
33
33
 
34
- #use Option parser to parse command line arguements
34
+ #use option parser to parse command line arguments
35
35
  def parse
36
36
  options = {
37
37
  :is_num => false,
38
38
  :clear_all => false
39
39
  }
40
40
  optparse = OptionParser.new do |opts|
41
- opts.version = "1.1.0"
41
+ version_path = File.expand_path("../../VERSION", File.dirname(__FILE__))
42
+ opts.version = File.exist?(version_path) ? File.read(version_path) : ""
42
43
  opts.banner = "Usage: todo [COMMAND] [option] [arguments]"
43
44
  opts.separator "Commands:"
44
- opts.separator " add, a adds the task to the working list"
45
- opts.separator " finish, f marks the task as completed"
46
- opts.separator " clear clears completed tasks"
47
- opts.separator " undo, u undos a completed task"
48
- opts.separator " create creates a new list or switches to existing"
49
- opts.separator " switch creates a new list or switches to existing"
50
- opts.separator " display, d displays the list"
45
+ opts.separator " <blank>, display, d displays the current list"
46
+ opts.separator " add, a <task> adds the task to the current list"
47
+ opts.separator " finish, f [option] <task> marks the task as completed"
48
+ opts.separator " clear [option] clears completed tasks"
49
+ opts.separator " undo, u [option] <task> undos a completed task"
50
+ opts.separator " create, switch <list_name> creates a new list or switches to an existing one"
51
51
  opts.separator "Options: "
52
- opts.on('-n', 'finish or undo, the task given is a number') do
52
+ opts.on('-n', 'with finish or undo, references a task by its number') do
53
53
  options[:is_num] = true
54
54
  end
55
- opts.on('-a', 'for clear, will reset the entire list') do
55
+ opts.on('-a', 'with clear, resets the entire list') do
56
56
  options[:clear_all] = true
57
57
  end
58
- opts.on('-h', '--help', 'Display this screen' ) do
58
+ opts.on('-h', '--help', 'displays this screen' ) do
59
59
  puts opts
60
- return
60
+ return
61
61
  end
62
- opts.on('-w', "display the current working list") do
62
+ opts.on('-w', "displays the name of the current list") do
63
63
  puts "Working list is #{WORKING_LIST.name}"
64
64
  return
65
65
  end
@@ -69,28 +69,38 @@ module Todo
69
69
  case ARGV[0]
70
70
  when "add", "a"
71
71
  ARGV.count > 1 ? WORKING_LIST.add(ARGV[1..-1].join(' ')) : puts("Invalid Command")
72
- self.display WORKING_LIST.name
72
+ self.display
73
73
  when "finish", "f"
74
74
  WORKING_LIST.finish ARGV[1..-1].join(' '), options[:is_num]
75
- self.display WORKING_LIST.name
75
+ self.display
76
76
  when "clear"
77
77
  WORKING_LIST.clear options[:clear_all]
78
78
  when "display", "d"
79
- self.display WORKING_LIST.name
79
+ self.display
80
80
  when "create", "switch"
81
81
  if File.exists?(File.join(Config[:lists_directory], ARGV[1..-1].join('_').downcase + '.yml'))
82
82
  Config[:working_list_name] = ARGV[1..-1].join('_').downcase
83
83
  puts "Switch to #{ARGV[1..-1].join(' ')}"
84
- self.display WORKING_LIST.name
84
+ new_list = YAML.load_file(File.join(Config[:lists_directory],
85
+ Config[:working_list_name]+'.yml')) if File.exists?(File.join(Config[:lists_directory],
86
+ Config[:working_list_name]+'.yml'))
87
+ self.display new_list
85
88
  else
86
89
  ARGV.count > 1 ? List.new(ARGV[1..-1].join(' ')) : puts("Invalid Command")
90
+ new_list = YAML.load_file(File.join(Config[:lists_directory],
91
+ Config[:working_list_name]+'.yml')) if File.exists?(File.join(Config[:lists_directory],
92
+ Config[:working_list_name]+'.yml'))
93
+ self.display new_list
87
94
  end
88
95
  when "undo", "u"
89
96
  WORKING_LIST.undo ARGV[1..-1].join(' '), options[:is_num]
90
- self.display WORKING_LIST.name
97
+ self.display
91
98
  else
92
99
  puts "Invalid Command"
93
100
  end
101
+ else
102
+ #if no ARGs are given, do what "display" would do
103
+ self.display WORKING_LIST.name
94
104
  end
95
105
  end
96
106
  end
data/lib/to-do/config.rb CHANGED
@@ -6,12 +6,12 @@ module Todo
6
6
  module Config
7
7
  extend self
8
8
  PATH = File.join(ENV['HOME'], '.to-do', 'config.yml')
9
-
9
+
10
10
  #default values
11
11
  def defaults
12
12
  {
13
13
  # the location of all all your list yaml files
14
- :lists_directory => File.join(ENV["HOME"],".to-do","lists"),
14
+ :lists_directory => File.join(ENV["HOME"],".to-do","lists"),
15
15
  # the current working list
16
16
  :working_list_name => "default_list"
17
17
  }
@@ -37,7 +37,7 @@ module Todo
37
37
  def write
38
38
  configs = if File.exist? PATH
39
39
  defaults.merge(YAML.load_file PATH)
40
- else
40
+ else
41
41
  defaults
42
42
  end
43
43
  File.open(PATH, 'w') do |fh|
data/lib/to-do/list.rb CHANGED
@@ -7,7 +7,7 @@ module Todo
7
7
 
8
8
  #Create a new list
9
9
  def initialize name
10
- @tasks = Hash.new
10
+ @tasks = Hash.new
11
11
  @completed_tasks = Hash.new
12
12
  @count = 0
13
13
  @completed_count = 0
@@ -22,7 +22,7 @@ module Todo
22
22
  end
23
23
 
24
24
  # updates the yaml
25
- def update
25
+ def update
26
26
  path = File.join(Config[:lists_directory], @name.downcase.gsub(/ /, '_') +'.yml')
27
27
  File.open(path, 'w') do |fh|
28
28
  fh.puts(self.to_yaml)
@@ -37,7 +37,7 @@ module Todo
37
37
  update
38
38
  end
39
39
 
40
- # finish the task. task is either a case insensitive task on the list or
40
+ # finish the task. task is either a case insensitive task on the list or
41
41
  # the task number
42
42
  def finish task, is_num
43
43
  if is_num
@@ -64,7 +64,7 @@ module Todo
64
64
  puts "Finished #{@completed_tasks[num]}."
65
65
  else
66
66
  puts "Task #{task} is not in list."
67
- end
67
+ end
68
68
  end
69
69
  update
70
70
  end
@@ -94,7 +94,7 @@ module Todo
94
94
  puts "Undo completeing #{@tasks[num]}."
95
95
  else
96
96
  puts "Task #{task} is not in list."
97
- end
97
+ end
98
98
  end
99
99
  update
100
100
  end
@@ -108,7 +108,7 @@ module Todo
108
108
  #clears all of the tasks and resets the count to 0
109
109
  def clear clear_all
110
110
  clear_completed
111
- if clear_all
111
+ if clear_all
112
112
  @tasks = Hash.new
113
113
  @completed_count = 0
114
114
  @count = 0
data/test/test_to-do.rb CHANGED
@@ -2,13 +2,13 @@ require File.join(File.dirname(__FILE__), 'helper')
2
2
  require '../lib/to-do.rb'
3
3
 
4
4
  class TestToDo < Test::Unit::TestCase
5
- context "Test list" do
6
- setup do
5
+ context "Test list" do
6
+ setup do
7
7
  @list_name = Todo::Config[:working_list_name]
8
8
  @list = Todo::List.new "Test List"
9
9
  end
10
10
 
11
- should "list is empty" do
11
+ should "list is empty" do
12
12
  assert_equal 0, @list.count
13
13
  assert_equal 0, @list.completed_count
14
14
  assert_equal 0, @list.tasks.count
@@ -24,18 +24,18 @@ class TestToDo < Test::Unit::TestCase
24
24
  assert_equal 0, @list.completed_tasks.count
25
25
  end
26
26
 
27
- should "finish some tasks" do
28
- add_tasks
27
+ should "finish some tasks" do
28
+ add_tasks
29
29
  finish_tasks
30
30
  @list.finish "This task doesn't exist", false
31
31
  @list.finish 40, true
32
32
  assert_equal 5, @list.count
33
33
  assert_equal 3, @list.completed_count
34
- assert_equal 2, @list.tasks.count
34
+ assert_equal 2, @list.tasks.count
35
35
  assert_equal 3, @list.completed_tasks.count
36
36
  end
37
37
 
38
- should "undo some tasks" do
38
+ should "undo some tasks" do
39
39
  add_tasks
40
40
  finish_tasks
41
41
  @list.undo 2, true
@@ -44,7 +44,7 @@ class TestToDo < Test::Unit::TestCase
44
44
  @list.undo 40, true
45
45
  assert_equal 5, @list.count
46
46
  assert_equal 1, @list.completed_count
47
- assert_equal 4, @list.tasks.count
47
+ assert_equal 4, @list.tasks.count
48
48
  assert_equal 1, @list.completed_tasks.count
49
49
  end
50
50
 
@@ -54,7 +54,7 @@ class TestToDo < Test::Unit::TestCase
54
54
  @list.clear false
55
55
  assert_equal 5, @list.count
56
56
  assert_equal 3, @list.completed_count
57
- assert_equal 2, @list.tasks.count
57
+ assert_equal 2, @list.tasks.count
58
58
  assert_equal 0, @list.completed_tasks.count
59
59
  @list.finish 3, true
60
60
  @list.clear true
data/to-do.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "to-do"
8
- s.version = "1.1.0"
8
+ s.version = "1.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristen Mills"]
12
- s.date = "2012-07-10"
12
+ s.date = "2012-07-14"
13
13
  s.description = "A simple command line todo application"
14
14
  s.email = "kristen@kristen-mills.com"
15
15
  s.executables = ["todo"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to-do
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-10 00:00:00.000000000 Z
12
+ date: 2012-07-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
16
- requirement: &70207567186320 !ruby/object:Gem::Requirement
16
+ requirement: &70243001200440 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70207567186320
24
+ version_requirements: *70243001200440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &70207567185800 !ruby/object:Gem::Requirement
27
+ requirement: &70243001199920 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.12'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70207567185800
35
+ version_requirements: *70243001199920
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70207567185280 !ruby/object:Gem::Requirement
38
+ requirement: &70243001199420 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70207567185280
46
+ version_requirements: *70243001199420
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &70207567184780 !ruby/object:Gem::Requirement
49
+ requirement: &70243001198900 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.8.4
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70207567184780
57
+ version_requirements: *70243001198900
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &70207567184220 !ruby/object:Gem::Requirement
60
+ requirement: &70243001198380 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70207567184220
68
+ version_requirements: *70243001198380
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: colorize
71
- requirement: &70207567183300 !ruby/object:Gem::Requirement
71
+ requirement: &70243001197880 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70207567183300
79
+ version_requirements: *70243001197880
80
80
  description: A simple command line todo application
81
81
  email: kristen@kristen-mills.com
82
82
  executables:
@@ -116,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  segments:
118
118
  - 0
119
- hash: -1801318960934950244
119
+ hash: -982776220175623031
120
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  none: false
122
122
  requirements: