mastodon 0.1.0 → 0.3.1

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.
@@ -0,0 +1,5 @@
1
+ README.md
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE.md
@@ -0,0 +1,23 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ doc
23
+ .yardoc
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2009 Colin Shea
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ **THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.**
@@ -0,0 +1,34 @@
1
+ # Mastodon
2
+ A [todo.txt][ttxt] parser.
3
+
4
+ [ttxt]: http://ginatrapani.github.com/todo.txt-cli/
5
+
6
+ ## Installation
7
+
8
+ sudo gem install mastodon
9
+
10
+ ## Usage
11
+
12
+ require 'mastodon'
13
+ mast = Mastodon.new(File.readlines("todo.txt"))
14
+ # List all the projects
15
+ mast.projects
16
+ # List all the contexts
17
+ mast.contexts
18
+
19
+
20
+ ## See Also
21
+ There are other links you can take a look at. If you care to, that is.
22
+
23
+ * [Run Code Run][rcr] (continuous integration)
24
+ * [Caliper & metric\_fu report][calip]
25
+ * [RDoc.info Documentation][rdoci] ([yardoc.org][yardoc])
26
+
27
+ [rcr]: http://runcoderun.com/evaryont/mastodon
28
+ [calip]: http://getcaliper.com/caliper/project?repo=git%3A%2F%2Fgithub.com%2Fevaryont%2Fmastodon.git
29
+ [rdoci]: http://rdoc.info/projects/evaryont/mastodon
30
+ [yardoc]: http://yardoc.org/docs/evaryont-mastodon
31
+
32
+ ## Copyright
33
+ Mastodon is released under the MIT license. Copyright (C) Colin Shea 2009. For
34
+ more information, consult LICENSE.txt for more information.
data/Rakefile CHANGED
@@ -1,55 +1,83 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ task :default => :test
5
+
1
6
  begin
2
7
  require 'jeweler'
8
+ Jeweler::Tasks.new do |gem|
9
+ gem.name = "mastodon"
10
+ gem.summary = %Q{A Ruby parser for todo.txt files}
11
+ gem.description = %Q{A Ruby parser for todo.txt files}
12
+ gem.email = "colin@evaryont.me"
13
+ gem.homepage = "http://evaryont.me"
14
+ gem.authors = ["Colin Shea"]
15
+ gem.add_development_dependency "riot", ">= 0"
16
+ gem.add_development_dependency "yard", ">= 0"
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
22
+
23
+ require 'rake/testtask'
24
+ Rake::TestTask.new(:test) do |test|
25
+ test.libs << 'lib' << 'test'
26
+ test.pattern = 'test/**/*_test.rb'
27
+ test.verbose = true
28
+ end
29
+ task :test => :check_dependencies
30
+
31
+ begin
32
+ require 'rcov/rcovtask'
33
+ Rcov::RcovTask.new do |test|
34
+ test.libs << 'test'
35
+ test.pattern = 'test/**/*_test.rb'
36
+ test.verbose = true
37
+ end
3
38
  rescue LoadError
4
- puts "Jeweler not available, but is required. Install it with: sudo gem install jeweler"
5
- exit 1
39
+ task :rcov do
40
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
41
+ end
6
42
  end
7
43
 
8
- @jtasks = Jeweler::Tasks.new do |gemspec|
9
- gemspec.name = "mastodon"
10
- gemspec.summary = "A ruby parser for todo.txt files"
11
- gemspec.description = "Mastodon: A ruby parser for todo.txt files.\n\nAnd the mastodon, like plain text, isn't extinct! (Yet.)"
12
- gemspec.email = "colin@evaryont.me"
13
- gemspec.homepage = "http://github.com/evaryont/mastodon/"
14
- gemspec.authors = ["Colin Shea"]
44
+ begin
45
+ require 'reek/adapters/rake_task'
46
+ Reek::RakeTask.new do |t|
47
+ t.fail_on_error = true
48
+ t.verbose = false
49
+ t.source_files = 'lib/**/*.rb'
50
+ end
51
+ rescue LoadError
52
+ task :reek do
53
+ abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
54
+ end
15
55
  end
16
- Jeweler::GemcutterTasks.new
17
- @jeweler = @jtasks.jeweler
18
-
19
- namespace :version do
20
- desc "DON'T CALL. Write the version to lib/#{@jeweler.gemspec_helper.spec.name}/version.rb"
21
- task :ruby do
22
- # TODO: This is hard coded but it should be dynamic, given
23
- # the gem spec
24
- file = File.open("lib/#{@jeweler.gemspec_helper.spec.name}/version.rb", "w")
25
- # TODO: and so should this class template
26
- file.write <<-CLASS
27
- # Automatically generated by `rake version:ruby' - use version:bump to change
28
- # this, do not edit this directly, as it will be overwritten!
29
- class #{@jeweler.gemspec_helper.spec.name.capitalize}
30
- VERSION = [#{@jeweler.major_version}, #{@jeweler.minor_version}, #{@jeweler.patch_version}]
56
+
57
+ begin
58
+ require 'roodi'
59
+ require 'roodi_task'
60
+ RoodiTask.new do |t|
61
+ t.verbose = false
62
+ end
63
+ rescue LoadError
64
+ task :roodi do
65
+ abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
66
+ end
31
67
  end
32
- CLASS
33
- system("git commit --file='.git/COMMIT_EDITMSG' --amend -q -o 'lib/#{@jeweler.gemspec_helper.spec.name}/version.rb'")
34
- end
35
-
36
- # Take advantage of Rake not overwriting tasks.
37
- #
38
- # After the 'real' task has been called, write version.rb as well.
39
- namespace :bump do
40
- task :major do
41
- Rake::Task["version:ruby"].execute
42
- end
43
- task :minor do
44
- Rake::Task["version:ruby"].execute
45
- end
46
- task :patch do
47
- Rake::Task["version:ruby"].execute
48
- end
49
- end
68
+
69
+ begin
70
+ require 'yard'
71
+ YARD::Rake::YardocTask.new do |t|
72
+ t.files = ["lib/**/*.rb"]
73
+ end
74
+ rescue LoadError
75
+ task :yard do
76
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
77
+ end
50
78
  end
51
79
 
52
- desc "Run the nanotest suite"
53
- task :test do
54
- system("ruby -I'lib:test' test/run_tests.rb")
80
+ namespace :release do
81
+ desc "Release to all locations: Git, GitHub and GemCutter"
82
+ task :all => ["git:release", "github:release", "gemcutter:release"]
55
83
  end
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 1
4
- :patch: 0
3
+ :minor: 3
4
+ :patch: 1
5
5
  :build:
@@ -0,0 +1,15 @@
1
+ class String
2
+ # Given 'string', find all matches of regular expression (removed from
3
+ # +string+) and return them as an array of strings.
4
+ def pull_regex(regexp)
5
+ found_values = []
6
+
7
+ until ((value = self[regexp]).nil?)
8
+ vindex = index(value)
9
+ self[ vindex .. (vindex + value.length) ] = ""
10
+ found_values << value.match(regexp)[1]
11
+ end
12
+
13
+ return found_values
14
+ end
15
+ end
@@ -1,8 +1,8 @@
1
1
  require 'set'
2
- require 'pp'
2
+
3
+ require 'core_ext/string/pull_regex'
3
4
 
4
5
  require 'mastodon/todo'
5
- require 'mastodon/version'
6
6
 
7
7
  class Mastodon
8
8
  # A context is: An at-sign (@) followed by one or more non-whitespace characters.
@@ -16,14 +16,17 @@ class Mastodon
16
16
 
17
17
  # +todo+: An array of strings (each being an individual todo item)
18
18
  def initialize(todos)
19
- parse! todos.map{|line| line.strip}
20
- end
21
-
22
- def parse!(todos)
23
19
  @contexts = Set.new
24
20
  @projects = Set.new
25
21
  @todos = []
26
22
 
23
+ parse! todos.map{|line| line.strip}
24
+
25
+ @contexts = @contexts.to_a
26
+ @projects = @projects.to_a
27
+ end
28
+
29
+ def parse!(todos)
27
30
  todos.each do |todo|
28
31
  # Looping through the string, find the metadata (context, project,
29
32
  # priority). Store it in a temporary variable, then clear it from
@@ -31,31 +34,22 @@ class Mastodon
31
34
 
32
35
  current_contexts = []
33
36
  current_projects = []
34
- current_priority, priority = nil, nil
37
+ current_priority = nil
35
38
 
36
- until ((context = todo[Context_Regex]).nil?)
37
- index = todo.index(context)
38
- todo[index..(index+context.length)] = ""
39
- current_contexts << context.match(Context_Regex)[1]
40
- contexts << context.match(Context_Regex)[1]
39
+ current_contexts = todo.pull_regex(Context_Regex)
40
+ unless current_contexts.empty?
41
+ @contexts.merge(current_contexts)
41
42
  end
42
43
 
43
- until ((project = todo[Project_Regex]).nil?)
44
- index = todo.index(project)
45
- todo[index..(index+project.length)] = ""
46
- current_projects << project.match(Project_Regex)[1]
47
- projects << project.match(Project_Regex)[1]
44
+ current_projects = todo.pull_regex(Project_Regex)
45
+ unless current_projects.empty?
46
+ @projects.merge(current_projects)
48
47
  end
49
48
 
50
- priority = todo[Priority_Regex]
51
- unless priority.nil?
52
- index = todo.index(priority)
53
- todo[index..(index+priority.length)] = ""
54
- current_priority = priority.match(Priority_Regex)[1]
55
- end
49
+ current_priority = todo.pull_regex(Priority_Regex)
56
50
 
57
51
  todo.strip!
58
- @todos << Mastodon::Todo.new(todo, current_contexts, current_projects, current_priority)
52
+ @todos << Mastodon::Todo.new(todo, current_contexts, current_projects, current_priority.first)
59
53
  end
60
54
  end
61
55
 
@@ -4,7 +4,10 @@ class Mastodon
4
4
 
5
5
  def to_s
6
6
  pri = priority ? "(#{priority})" : ""
7
- "#{pri} #{text} @#{contexts.join(' @')} +#{projects.join(' +')}".strip
7
+ ctx = contexts.empty? ? "" : "@#{contexts.join(' @')}"
8
+ prj = projects.empty? ? "" : "+#{projects.join(' +')}"
9
+
10
+ "#{pri} #{text} #{ctx} #{prj}".strip
8
11
  end
9
12
 
10
13
  def inspect
@@ -0,0 +1,60 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{mastodon}
8
+ s.version = "0.3.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Colin Shea"]
12
+ s.date = %q{2009-12-29}
13
+ s.description = %q{A Ruby parser for todo.txt files}
14
+ s.email = %q{colin@evaryont.me}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.md",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE.md",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION.yml",
26
+ "lib/core_ext/string/pull_regex.rb",
27
+ "lib/mastodon.rb",
28
+ "lib/mastodon/todo.rb",
29
+ "mastodon.gemspec",
30
+ "test/mastodon_test.rb",
31
+ "test/teststrap.rb",
32
+ "test/todo.txt"
33
+ ]
34
+ s.homepage = %q{http://evaryont.me}
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.5}
38
+ s.summary = %q{A Ruby parser for todo.txt files}
39
+ s.test_files = [
40
+ "test/mastodon_test.rb",
41
+ "test/teststrap.rb"
42
+ ]
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
+ s.add_development_dependency(%q<riot>, [">= 0"])
50
+ s.add_development_dependency(%q<yard>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<riot>, [">= 0"])
53
+ s.add_dependency(%q<yard>, [">= 0"])
54
+ end
55
+ else
56
+ s.add_dependency(%q<riot>, [">= 0"])
57
+ s.add_dependency(%q<yard>, [">= 0"])
58
+ end
59
+ end
60
+
@@ -0,0 +1,139 @@
1
+ require 'teststrap'
2
+
3
+ context "Mastodon" do
4
+ setup do
5
+ @todos = File.readlines(File.join(File.dirname(__FILE__), "todo.txt"))
6
+ Mastodon.new(@todos)
7
+ end
8
+
9
+ context "Projects" do
10
+ setup do
11
+ topic.projects
12
+ end
13
+
14
+ asserts_topic.equals ["proj", "proj2", "proj+phone", "proj/foo", "p_r_o_j", "p-r-o-j", "+proj", "@proj"]
15
+
16
+ asserts_topic.kind_of? Array
17
+ end
18
+
19
+ context "Contexts" do
20
+ setup do
21
+ topic.contexts
22
+ end
23
+
24
+ asserts_topic.equals ["con", "con2", "con@phone", "con/foo", "c_o_n", "c-o-n", "@con", "+con"]
25
+
26
+ asserts_topic.kind_of? Array
27
+ end
28
+
29
+ asserts "Non-existent contexts should return an empty array" do
30
+ topic.find_context("nosuchthing") == []
31
+ end
32
+ asserts "Non-existent projects should return an empty array" do
33
+ topic.find_project("thisprojectdoesntexist") == []
34
+ end
35
+
36
+ context "Context #2" do
37
+ setup do
38
+ topic.find_context("con2")
39
+ end
40
+ asserts "Context size should be greater than zero" do
41
+ topic.size > 0
42
+ end
43
+ asserts "First todo with the context 'con2' should be 'Multiple contexts'" do
44
+ topic.first.text == "Multiple contexts"
45
+ end
46
+ end
47
+
48
+ context "Project #2" do
49
+ setup do
50
+ topic.find_project("proj2")
51
+ end
52
+ should "greater than zero" do
53
+ topic.size > 0
54
+ end
55
+ asserts "First todo with the project 'proj2' should be 'Multiple projects'" do
56
+ topic.first.text == "Multiple projects"
57
+ end
58
+ end
59
+
60
+ context "Todo" do
61
+ #asserts(:size).equals @todos.size
62
+
63
+ asserts "all todos are of type Mastodon::Todo" do
64
+ !(topic.todos.map do |todo|
65
+ todo.is_a? Mastodon::Todo
66
+ end.index(false))
67
+ end
68
+
69
+ context "Lossless parsing: 1st Todo: Normal example" do
70
+ setup do
71
+ @todo = @todos[0].strip
72
+ topic[0]
73
+ end
74
+
75
+ should "be the same characters" do
76
+ topic.to_s.chars.to_a == @todo.chars.to_a
77
+ end
78
+ should "be the same length" do
79
+ topic.to_s.length == @todo.length
80
+ end
81
+ end
82
+
83
+ context "Lossless parsing: 8th Todo: Normal example, with priority" do
84
+ setup do
85
+ @todo = @todos[7].strip
86
+ topic[7]
87
+ end
88
+
89
+ should "be the same characters" do
90
+ topic.to_s.chars.to_a == @todo.chars.to_a
91
+ end
92
+ should "be the same length" do
93
+ topic.to_s.length == @todo.length
94
+ end
95
+ end
96
+
97
+ context "Lossless parsing: 17th Todo: Example without any metadata" do
98
+ setup do
99
+ @todo = @todos[16].strip
100
+ topic[16]
101
+ end
102
+
103
+ should "be the same characters" do
104
+ topic.to_s.chars.to_a == @todo.chars.to_a
105
+ end
106
+ should "be the same length" do
107
+ topic.to_s.length == @todo.length
108
+ end
109
+ end
110
+ end
111
+
112
+ asserts "13th todo should have the context 'con'" do
113
+ topic[13].contexts = ["con"]
114
+ end
115
+ asserts "14th todo should have the project 'proj'" do
116
+ topic[14].projects = ["proj"]
117
+ end
118
+
119
+ context "Priority" do
120
+ asserts "3rd todo should have no priority" do
121
+ topic[3].priority.nil?
122
+ end
123
+ asserts "4th todo should have no priority" do
124
+ topic[4].priority.nil?
125
+ end
126
+ asserts "5th todo should have priority A" do
127
+ topic[5].priority = "A"
128
+ end
129
+ asserts "6th todo should have priority Z" do
130
+ topic[6].priority = "Z"
131
+ end
132
+ asserts "7th todo should have priority Q" do
133
+ topic[7].priority = "Q"
134
+ end
135
+ asserts "8th todo should have no priority" do
136
+ topic[8].priority.nil?
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'riot'
3
+ require 'mastodon'
4
+ require 'pp'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mastodon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin Shea
@@ -9,34 +9,54 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-23 00:00:00 -05:00
12
+ date: 2009-12-29 00:00:00 -05:00
13
13
  default_executable:
14
- dependencies: []
15
-
16
- description: |-
17
- Mastodon: A ruby parser for todo.txt files.
18
-
19
- And the mastodon, like plain text, isn't extinct! (Yet.)
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: riot
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: yard
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description: A Ruby parser for todo.txt files
20
36
  email: colin@evaryont.me
21
37
  executables: []
22
38
 
23
39
  extensions: []
24
40
 
25
41
  extra_rdoc_files:
26
- - README.mkd
42
+ - LICENSE.md
43
+ - README.md
27
44
  files:
45
+ - .document
46
+ - .gitignore
47
+ - LICENSE.md
48
+ - README.md
28
49
  - Rakefile
29
50
  - VERSION.yml
51
+ - lib/core_ext/string/pull_regex.rb
30
52
  - lib/mastodon.rb
31
53
  - lib/mastodon/todo.rb
32
- - lib/mastodon/version.rb
33
- - test/run_tests.rb
34
- - test/test_helper.rb
35
- - test/test_mastodon.rb
54
+ - mastodon.gemspec
55
+ - test/mastodon_test.rb
56
+ - test/teststrap.rb
36
57
  - test/todo.txt
37
- - README.mkd
38
58
  has_rdoc: true
39
- homepage: http://github.com/evaryont/mastodon/
59
+ homepage: http://evaryont.me
40
60
  licenses: []
41
61
 
42
62
  post_install_message:
@@ -62,8 +82,7 @@ rubyforge_project:
62
82
  rubygems_version: 1.3.5
63
83
  signing_key:
64
84
  specification_version: 3
65
- summary: A ruby parser for todo.txt files
85
+ summary: A Ruby parser for todo.txt files
66
86
  test_files:
67
- - test/run_tests.rb
68
- - test/test_helper.rb
69
- - test/test_mastodon.rb
87
+ - test/mastodon_test.rb
88
+ - test/teststrap.rb
data/README.mkd DELETED
@@ -1,9 +0,0 @@
1
- # Mastodon
2
-
3
- A todo.txt[1] parser.
4
-
5
- [1]: http://ginatrapani.github.com/todo.txt-cli/
6
-
7
- ## Installation
8
-
9
- sudo gem install mastodon
@@ -1,5 +0,0 @@
1
- # Automatically generated by `rake version:ruby' - use version:bump to change
2
- # this, do not edit this directly, as it will be overwritten!
3
- class Mastodon
4
- VERSION = [0, 1, 0]
5
- end
@@ -1,2 +0,0 @@
1
- require 'test_helper'
2
- require 'test_mastodon'
@@ -1,14 +0,0 @@
1
- require 'nanotest'
2
-
3
- begin # Optional dependencies
4
- require 'nanotest/stats' # Gets some nice speed stats.
5
- require 'redgreen' # Pretty colors!
6
- rescue LoadError
7
- end
8
- include Nanotest
9
-
10
- # Include the library
11
- require File.dirname(__FILE__) + "/../lib/mastodon.rb"
12
-
13
- SAMPLE_TODOS = File.readlines(File.join(File.dirname(__FILE__), "todo.txt")) unless Kernel.const_defined? :SAMPLE_TODOS
14
- @mast = Mastodon.new(SAMPLE_TODOS)
@@ -1,37 +0,0 @@
1
- require 'test_helper'
2
-
3
- # Test searching and caching.
4
- assert { @mast.projects.to_a == ["proj", "proj2", "proj+phone", "proj/foo", "p_r_o_j", "p-r-o-j", "+proj", "@proj"] }
5
- assert { @mast.contexts.to_a == ["con", "con2", "con@phone", "con/foo", "c_o_n", "c-o-n", "@con", "+con"] }
6
-
7
- # Finding existing items
8
- assert { @mast.find_context("con2").size > 0 }
9
- assert { @mast.find_context("con2").first.text == "Multiple contexts" }
10
- assert { @mast.find_project("proj2").size > 0 }
11
- assert { @mast.find_project("proj2").first.text == "Multiple projects" }
12
-
13
- # Finding non-existing items
14
- assert { @mast.find_context("nosuchthing") == [] }
15
- assert { @mast.find_project("thisprojectdoesntexist") == [] }
16
-
17
- # General utility methods.
18
- assert { @mast.size == SAMPLE_TODOS.size }
19
- # While I can't guarantee a 1:1 match, nothing should be lost. Just possibly rearranged.
20
- assert { (@mast[0].to_s.chars.to_a == SAMPLE_TODOS[0].strip.chars.to_a) and (@mast[0].to_s.length == SAMPLE_TODOS[0].strip.length) }
21
-
22
- # Test if correct classes are returned
23
- assert { @mast.projects.is_a? Set }
24
- assert { @mast.contexts.is_a? Set }
25
- assert { @mast[0].is_a? Mastodon::Todo }
26
-
27
- # Test if matching at the beginning of a line works
28
- assert { @mast[13].contexts = ["con"] }
29
- assert { @mast[14].projects = ["proj"] }
30
-
31
- # Test priority detection
32
- assert { @mast[3].priority.nil? }
33
- assert { @mast[4].priority.nil? }
34
- assert { @mast[5].priority = "A" }
35
- assert { @mast[6].priority = "Z" }
36
- assert { @mast[7].priority = "Q" }
37
- assert { @mast[8].priority.nil? }