<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,11 +3,16 @@ require 'main'
 require 'highline/import'
 require 'ftools'
 
-def read_file(environment)
+def read_list(environment)
   file = environment.nil? ? Todo::Store.read('.todo/list.yml') : Todo::Store.read(environment)
+  if file
+    yield(file)
+  else
+    say &quot;Todo list file is invalid or do not exist.&quot;
+  end
 end
 
-def write_file(list, environment)
+def write_list(list, environment)
   file = environment.nil? ? Todo::Store.write(list, '.todo/list.yml') : Todo::Store.write(list, environment)
 end
 
@@ -53,14 +58,9 @@ Main {
                str.split(/,\s*/) })
        end
        
-       #read the YAML file
-       if list=read_file(params['FILE'].value)
-        #add the task
+       read_list(params['FILE'].value) do |list|
         list.add(params['item'].value, tags)
-        #write the changes
-        say &quot;Successfully added your task.&quot; if write_file(list, params['FILE'].value)
-       else
-        say &quot;Todo list file is invalid or do not exist.&quot;
+        say &quot;Successfully added your task.&quot; if write_list(list, params['FILE'].value)
        end
     end
   end
@@ -84,14 +84,12 @@ Main {
     }
        
     def run
-      if list=read_file(params['FILE'].value)
+      read_list(params['FILE'].value) do |list|
         if list.remove(params['item'].value || params['index'].value)
-          say &quot;Removed item from the list.&quot; if write_file(list, params['FILE'].value)
+          say &quot;Removed item from the list.&quot; if write_list(list, params['FILE'].value)
         else 
           say &quot;Could not find item to remove.&quot;
         end
-      else
-        say &quot;Todo list file is invalid or do not exist.&quot;
       end      
     end
   end
@@ -114,7 +112,7 @@ Main {
     }
         
     def run
-      if list=read_file(params['FILE'].value)
+      read_list(params['FILE'].value) do |list|
       
         if params['tag'].given?
           title = &quot;Listing todos tagged '#{params['tag'].value}'&quot;
@@ -129,8 +127,7 @@ Main {
           tag_string = (&quot;(#{tags.join(&quot;, &quot;)})&quot;) unless tags.include?(nil)
           say &quot; - #{task} #{tag_string} \n&quot;
         end
-      else
-        say &quot;Todo list file is invalid or do not exist.&quot;
+      
       end
     end  
   end</diff>
      <filename>lib/todo/cli.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@ module Todo
   module VERSION #:nodoc:
     MAJOR = 0
     MINOR = 0
-    TINY  = 3
+    TINY  = 4
 
     STRING = [MAJOR, MINOR, TINY].join('.')
   end</diff>
      <filename>lib/todo/version.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,11 @@
 (in /home/lakshan/projects/ruby-samples/todo)
 Gem::Specification.new do |s|
   s.name = %q{todo}
-  s.version = &quot;0.0.3&quot;
+  s.version = &quot;0.0.4&quot;
 
   s.required_rubygems_version = Gem::Requirement.new(&quot;&gt;= 0&quot;) if s.respond_to? :required_rubygems_version=
   s.authors = [&quot;Lakshan Perera&quot;]
-  s.date = %q{2008-08-28}
+  s.date = %q{2008-08-29}
   s.default_executable = %q{todo}
   s.description = %q{simple command line todo list manager}
   s.email = [&quot;lakshan@web2media.net&quot;]</diff>
      <filename>todo.gemspec</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4bdafadc5f5b34ce7ec7850c2cc0a9e66f172a95</id>
    </parent>
  </parents>
  <author>
    <name>Lakshan Perera</name>
    <email>lakshan@web2media.net</email>
  </author>
  <url>http://github.com/laktek/todo/commit/6a6f17da0f826331e938f5c711c71281200887f3</url>
  <id>6a6f17da0f826331e938f5c711c71281200887f3</id>
  <committed-date>2008-08-28T19:14:32-07:00</committed-date>
  <authored-date>2008-08-28T19:14:32-07:00</authored-date>
  <message>Refactored list read/write methods</message>
  <tree>b65a8daa4822b6e05c1a73ec0cfbcfd04ae2b4bb</tree>
  <committer>
    <name>Lakshan Perera</name>
    <email>lakshan@web2media.net</email>
  </committer>
</commit>
