Permalink
Browse files

Replace GTD.get_contexts with the new GTDContexts.contexts

git-svn-id: http://svn.textmate.org/trunk/Bundles/GTDAlt.tmbundle@6147 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
1 parent 2b9412d commit 8ef034ba1bb715472c9860518ea0d1d2ecfae2fd Charilaos Skiadas committed Nov 15, 2006
Showing with 18 additions and 16 deletions.
  1. +1 −1 Support/bin/get_lists.rb
  2. +1 −1 Support/bin/process_inbox.rb
  3. +3 −4 Support/lib/GTDUtils.rb
  4. +11 −8 Support/tests/test_gtd.rb
  5. +2 −2 Support/tests/test_utils.rb
View
@@ -6,7 +6,7 @@
include GTD
GTD.process_directory
all_actions = GTD.actions
-contexts = GTD.get_contexts
+contexts = GTDContexts.contexts
contxts = []
def esc(str)
str.gsub('"','\\"')
@@ -24,7 +24,7 @@ class NormalException < Exception
inbox_object = objects.find{|o| o.file == tempInboxFilename}
objects << (inbox_object = GTDFile.new(tempInboxFilename)) unless inbox_object
projects = GTD.projects
-contexts = GTD.get_contexts
+contexts = GTDContexts.contexts
f = File.open(inboxfile, "r")
lines = f.readlines.map{|i| i.chomp}
f.close
View
@@ -5,13 +5,12 @@ class GTDContexts
class << self
def contexts
@@contexts ||= self.get_env_contexts
+ @@contexts.uniq!
+ @@contexts.sort!
+ @@contexts
end
def contexts=(newContexts)
@@contexts = newContexts
- unless @@contexts.nil?
- @@contexts.uniq!
- @@contexts.sort!
- end
end
def get_env_contexts
contexts = ("#{ENV['TM_GTD_CONTEXT']} #{ENV['TM_GTD_CONTEXTS']}").chomp.split(" ").compact.sort
View
@@ -1,11 +1,15 @@
require "test/unit"
-$:.unshift File.join(File.dirname(__FILE__), "..", "bin")
+$:.unshift "../lib"
ENV['TM_GTD_CONTEXT'] = "hello there"
+ENV['TM_GTD_CONTEXTS'] = "hello there"
require "GTD.rb"
include GTD
class TestGTD < Test::Unit::TestCase
+ def setup
+ GTDContexts.contexts = nil
+ end
def test_action
- ENV['TM_GTD_CONTEXTS'] = "hello there"
+ assert_equal(["hello","there"], GTDContexts.contexts)
@a = Action.new(:name => "the name", :context => "thecontext", :parent => "project", :file => "2005-03-05")
assert_not_nil(@a)
assert_equal("the name", @a.name)
@@ -17,8 +21,10 @@ def test_action
assert_equal(nil, @b.project)
assert_equal(["file2",15], [@b.file,@b.line])
assert_equal(nil,@b.due)
+ assert_equal(["hello", "there"],GTDContexts.contexts)
end
def test_GTD_parse
+ assert_equal(["hello","there"],GTDContexts.contexts)
File.open("test_example.gtd") do |f|
@data = f.read
end
@@ -38,8 +44,8 @@ def test_GTDFile_initialize
assert_equal(["World domination","A subproject"], @object.projects.map{|i| i.name})
assert_equal(5, @object.actions.length)
assert_equal(["Create giant laser beam","Threaten to destroy Barbados","An action","Take over world","Hello there"], @object.actions.map{|i| i.name})
- assert_equal(["email","email-task","errand","hello","testing","there","work"], GTD.contexts)
- assert_equal(7, GTD.contexts.length)
+ assert_equal(["email","email-task","errand","hello","testing","there","work"], GTDContexts.contexts)
+ assert_equal(7, GTDContexts.contexts.length)
end
def test_projects
test_GTDFile_initialize
@@ -84,11 +90,8 @@ def test_dump_object
end
end
def test_GTD_singleton_calls
- contexts = GTD.get_contexts
+ contexts = GTDContexts.contexts
GTD.process_directory
@na = GTD.next_actions
- assert_equal(7, @na.length) # Careful. This relies on the contexts of test_example
- GTD.clear_contexts
- GTD.add_contexts(*contexts)
end
end
@@ -22,9 +22,9 @@ def test_contexts
assert_equal(2, GTDContexts.get_env_contexts.length)
assert_equal(2, GTDContexts.contexts.length)
GTDContexts.contexts=["hi","you", "there"]
- assert_equal(3, GTDContexts.contexts.length)
+ assert_equal(["hi","there", "you"], GTDContexts.contexts)
GTDContexts.contexts += ["you", "there", "foo"]
- assert_equal(4, GTDContexts.contexts.length)
+ assert_equal(["foo", "hi","there", "you"], GTDContexts.contexts)
GTDContexts.contexts << "bar"
assert_equal(5, GTDContexts.contexts.length)
GTDContexts.contexts = nil

0 comments on commit 8ef034b

Please sign in to comment.