Skip to content

Commit

Permalink
First cut of unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas E. Rabenau committed Jun 29, 2012
0 parents commit c90c674
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
@@ -0,0 +1,17 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
4 changes: 4 additions & 0 deletions Gemfile
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in twdeps.gemspec
gemspec
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
Copyright (c) 2012 Nicholas E. Rabenau

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 changes: 30 additions & 0 deletions README.md
@@ -0,0 +1,30 @@
# TaskWarrior Dependency Visualization

Visualizes dependencies between TaskWarrior tasks.

## Installation

$ gem install twdeps

## Usage

# Create a dependency graph as PNG and pipe it to a file
task export rc.json.array=on rc.verbose=nothing | twdeps > deps.png

# Same but override format. Use the file option to specify the file name to write to
task export rc.json.array=on rc.verbose=nothing | twdeps --format svg --file deps.svg

# Create a graph from a previously exported file
cat tasks.json | twdeps > deps.png

## Limitations

TaskWarrior 2.0 needs the command line options `rc.json.array=on` and `rc.verbose=nothing` due to [two](http://taskwarrior.org/issues/1017) [bugs](http://taskwarrior.org/issues/1013) in JSON export.

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
10 changes: 10 additions & 0 deletions Rakefile
@@ -0,0 +1,10 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
require 'rake/testtask'

Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test' << 'test/helpers'
test.test_files = FileList['test/**/test_*.rb']
end

task :default => :test
30 changes: 30 additions & 0 deletions bin/twdeps
@@ -0,0 +1,30 @@
#!/usr/bin/env ruby

require 'bundler'
Bundler.require

# require output file argument if $stdout.tty?, otherwise it's being piped
outfile = "#{ARGV.shift}.png"

g = GraphViz::new("G")

main = g.add_nodes("main")
parse = g.add_nodes("parse")
execute = g.add_nodes("execute")
init = g.add_nodes("init")
cleanup = g.add_nodes("cleanup")
make_string = g.add_nodes("make_string")
printf = g.add_nodes("printf")
compare = g.add_nodes("compare")

g.add_edges( main, parse )
g.add_edges( parse, execute )
g.add_edges( main, init )
g.add_edges( main, cleanup )
g.add_edges( execute, make_string )
g.add_edges( execute, printf )
g.add_edges( init, make_string )
g.add_edges( main, printf )
g.add_edges( execute, compare )

g.output(:png => outfile)
9 changes: 9 additions & 0 deletions lib/twdeps.rb
@@ -0,0 +1,9 @@
require "twdeps/version"

require "graphviz"

module TaskWarrior
module Dependencies
# Your code goes here...
end
end
5 changes: 5 additions & 0 deletions lib/twdeps/version.rb
@@ -0,0 +1,5 @@
module TaskWarrior
module Dependencies
VERSION = "0.0.1"
end
end
7 changes: 7 additions & 0 deletions test/fixtures/no_deps.json
@@ -0,0 +1,7 @@
[{"id":1,"description":"Select a free weekend in November","entry":"20120629T191421Z","priority":"H","project":"party","status":"pending","uuid":"6fd0ba4a-ab67-49cd-ac69-64aa999aff8a","annotations":[{"entry":"20120629T191534Z","description":"the 13th looks good"}]},
{"id":2,"description":"Select and book a venue","entry":"20120629T191634Z","priority":"H","project":"party","status":"pending","uuid":"c992448a-f1ea-4982-8461-47f0705ff509"},
{"id":3,"description":"Mail invitations","entry":"20120629T191919Z","project":"party","status":"pending","uuid":"3b53178e-d5a4-45e0-afc2-1292db58a59a"},
{"id":4,"description":"Select a caterer","entry":"20120629T191919Z","project":"party","status":"pending","uuid":"c590941b-eb10-4569-bdc9-0e339f79305e"},
{"id":5,"description":"Design invitations","entry":"20120629T191919Z","priority":"H","project":"party","status":"pending","tags":["mall"],"uuid":"e5a867b7-0116-457d-ba43-9ac2bee6ad2a"},
{"id":6,"description":"Print invitations","entry":"20120629T191920Z","project":"party","status":"pending","tags":["mall"],"uuid":"9f6f3738-1c08-4f45-8eb4-1e90864c7588"}
]
7 changes: 7 additions & 0 deletions test/fixtures/party.json
@@ -0,0 +1,7 @@
[{"id":1,"description":"Select a free weekend in November","entry":"20120629T191421Z","priority":"H","project":"party","status":"pending","uuid":"6fd0ba4a-ab67-49cd-ac69-64aa999aff8a","annotations":[{"entry":"20120629T191534Z","description":"the 13th looks good"}]},
{"id":2,"depends":"6fd0ba4a-ab67-49cd-ac69-64aa999aff8a","description":"Select and book a venue","entry":"20120629T191634Z","priority":"H","project":"party","status":"pending","uuid":"c992448a-f1ea-4982-8461-47f0705ff509"},
{"id":3,"depends":"9f6f3738-1c08-4f45-8eb4-1e90864c7588","description":"Mail invitations","entry":"20120629T191919Z","project":"party","status":"pending","uuid":"3b53178e-d5a4-45e0-afc2-1292db58a59a"},
{"id":4,"depends":"6fd0ba4a-ab67-49cd-ac69-64aa999aff8a","description":"Select a caterer","entry":"20120629T191919Z","project":"party","status":"pending","uuid":"c590941b-eb10-4569-bdc9-0e339f79305e"},
{"id":5,"depends":"c992448a-f1ea-4982-8461-47f0705ff509","description":"Design invitations","entry":"20120629T191919Z","priority":"H","project":"party","status":"pending","tags":["mall"],"uuid":"e5a867b7-0116-457d-ba43-9ac2bee6ad2a"},
{"id":6,"depends":"e5a867b7-0116-457d-ba43-9ac2bee6ad2a","description":"Print invitations","entry":"20120629T191920Z","project":"party","status":"pending","tags":["mall"],"uuid":"9f6f3738-1c08-4f45-8eb4-1e90864c7588"}
]
21 changes: 21 additions & 0 deletions test/test_helper.rb
@@ -0,0 +1,21 @@
# require 'bundler'
# Bundler.require

require 'twtest'
require 'twdeps'

module TaskWarrior
module Test
module Integration
class TestCase
def tasks
export_tasks
end

def fixture(name)
File.join(File.dirname(__FILE__), 'fixtures', name)
end
end
end
end
end
8 changes: 8 additions & 0 deletions test/unit/test_dependencies.rb
@@ -0,0 +1,8 @@
require 'test_helper'

class DependencyBuilderTest < TaskWarrior::Test::Integration::TestCase
def test_no_dependencies
exec("import #{fixture('no_deps.json')}")
assert_equal(6, tasks.size)
end
end
20 changes: 20 additions & 0 deletions twdeps.gemspec
@@ -0,0 +1,20 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/twdeps/version', __FILE__)

Gem::Specification.new do |gem|
gem.authors = ["Nicholas E. Rabenau"]
gem.email = ["nerab@gmx.net"]
gem.description = %q{TODO: Write a gem description}
gem.summary = %q{TODO: Write a gem summary}
gem.homepage = ""

gem.files = `git ls-files`.split($\)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.name = "twdeps"
gem.require_paths = ["lib"]
gem.version = TaskWarrior::Dependencies::VERSION

gem.add_dependency 'ruby-graphviz', '~> 1.0'
gem.add_development_dependency 'twtest'
end

0 comments on commit c90c674

Please sign in to comment.