taskwarrior 0.0.4 → 0.0.5
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.
- data/.travis.yml +2 -0
- data/README.md +4 -0
- data/lib/taskwarrior.rb +5 -0
- data/lib/taskwarrior/annotation.rb +0 -3
- data/lib/taskwarrior/attributes.rb +19 -0
- data/lib/taskwarrior/project.rb +0 -2
- data/lib/taskwarrior/repository.rb +1 -3
- data/lib/taskwarrior/tag.rb +0 -2
- data/lib/taskwarrior/task.rb +20 -20
- data/lib/taskwarrior/version.rb +1 -1
- data/taskwarrior.gemspec +2 -1
- metadata +20 -3
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -18,6 +18,10 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install taskwarrior
|
20
20
|
|
21
|
+
## Platforms
|
22
|
+
|
23
|
+
This gem is tested on Ruby 1.9.3. Please see the [build status](http://travis-ci.org/nerab/taskwarrior) for the status of other rubies.
|
24
|
+
|
21
25
|
## Usage
|
22
26
|
|
23
27
|
`TaskWarrior::Repository` is the main entry point. It expects an array of JSON objects, typically produced by `task export`. Technically, anything that can be consumed by `JSON.parse` is fine as long as it follows the format TaskWarrior uses.
|
data/lib/taskwarrior.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module TaskWarrior
|
2
|
+
module Attributes
|
3
|
+
module ClassMethods
|
4
|
+
def attributes(*attr)
|
5
|
+
if attr.nil? or attr.empty?
|
6
|
+
@attributes
|
7
|
+
else
|
8
|
+
@attributes = attr
|
9
|
+
@attributes.each{|attr| self.send('attr_accessor', attr)}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# http://blog.jayfields.com/2006/12/ruby-instance-and-class-methods-from.html
|
15
|
+
def self.included(base)
|
16
|
+
base.extend(ClassMethods)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/taskwarrior/project.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
1
|
module TaskWarrior
|
4
2
|
class Repository
|
5
3
|
def initialize(input)
|
@@ -7,7 +5,7 @@ module TaskWarrior
|
|
7
5
|
@projects = Hash.new{|hash, key| hash[key] = Project.new(key)}
|
8
6
|
@tags = Hash.new{|hash, key| hash[key] = Tag.new(key)}
|
9
7
|
|
10
|
-
|
8
|
+
MultiJson.load(input).each{|json|
|
11
9
|
task = TaskWarrior::TaskMapper.map(json)
|
12
10
|
@tasks[task.uuid] = task
|
13
11
|
@projects[task.project].tasks << task if task.project
|
data/lib/taskwarrior/tag.rb
CHANGED
data/lib/taskwarrior/task.rb
CHANGED
@@ -1,28 +1,34 @@
|
|
1
|
-
require 'active_model'
|
2
|
-
|
3
1
|
module TaskWarrior
|
4
2
|
class Task
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
include TaskWarrior::Attributes
|
4
|
+
|
5
|
+
attributes :description, :id, :entry, :status, :uuid, :project, :dependencies, :parent, :children,
|
6
|
+
:priority, :tags, :annotations, :start_at, :wait_at, :end_at, :due_at
|
9
7
|
|
10
8
|
include ActiveModel::Validations
|
11
9
|
|
12
10
|
validates :description, :id, :entry, :status, :uuid, :presence => true
|
13
11
|
|
14
|
-
validates :id, :numericality => {
|
12
|
+
validates :id, :numericality => {
|
13
|
+
:only_integer => true,
|
14
|
+
:greater_than => 0
|
15
|
+
}
|
15
16
|
|
16
|
-
validates :uuid, :format => {
|
17
|
-
|
17
|
+
validates :uuid, :format => {
|
18
|
+
:with => /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/,
|
19
|
+
:message => "'%{value}' does not match the expected format of a UUID"
|
20
|
+
}
|
18
21
|
|
19
|
-
validates :status, :inclusion => {
|
22
|
+
validates :status, :inclusion => {
|
23
|
+
:in => [:pending, :waiting, :complete],
|
24
|
+
:message => "%{value} is not a valid status"
|
25
|
+
}
|
20
26
|
|
21
27
|
validates :priority, :inclusion => {
|
22
|
-
:in
|
23
|
-
:allow_nil
|
28
|
+
:in => [:high, :medium, :low],
|
29
|
+
:allow_nil => true,
|
24
30
|
:allow_blank => true,
|
25
|
-
:message
|
31
|
+
:message => "%{value} is not a valid priority"
|
26
32
|
}
|
27
33
|
|
28
34
|
include TaskWarrior::Validations
|
@@ -46,13 +52,7 @@ module TaskWarrior
|
|
46
52
|
|
47
53
|
# other may have the same uuid, but if its attributes differ, it will not be equal
|
48
54
|
def eql?(other)
|
49
|
-
|
50
|
-
# Maybe Virtus?
|
51
|
-
# http://solnic.eu/2012/01/10/ruby-datamapper-status.html
|
52
|
-
[:description, :id, :entry, :status, :uuid,
|
53
|
-
:project, :dependencies, :parent, :children,
|
54
|
-
:priority, :tags, :annotations, :start_at, :wait_at,
|
55
|
-
:end_at, :due_at].each do |attr|
|
55
|
+
self.class.attributes.each do |attr|
|
56
56
|
return false unless send(attr).eql?(other.send(attr))
|
57
57
|
end
|
58
58
|
end
|
data/lib/taskwarrior/version.rb
CHANGED
data/taskwarrior.gemspec
CHANGED
@@ -15,9 +15,10 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.version = TaskWarrior::VERSION
|
16
16
|
|
17
17
|
gem.add_dependency 'activemodel', '~> 3.2'
|
18
|
+
gem.add_dependency 'multi_json', '~> 1.3'
|
18
19
|
|
19
20
|
gem.add_development_dependency 'activesupport', '~> 3.2'
|
20
|
-
gem.add_development_dependency 'twtest', '~> 0.0.
|
21
|
+
gem.add_development_dependency 'twtest', '~> 0.0.6'
|
21
22
|
gem.add_development_dependency 'guard-test', '~> 0.5'
|
22
23
|
gem.add_development_dependency 'guard-bundler', '~> 1.0'
|
23
24
|
gem.add_development_dependency 'rake', '~> 0.9'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taskwarrior
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '3.2'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: multi_json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.3'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.3'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: activesupport
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +66,7 @@ dependencies:
|
|
50
66
|
requirements:
|
51
67
|
- - ~>
|
52
68
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.0.
|
69
|
+
version: 0.0.6
|
54
70
|
type: :development
|
55
71
|
prerelease: false
|
56
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +74,7 @@ dependencies:
|
|
58
74
|
requirements:
|
59
75
|
- - ~>
|
60
76
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.0.
|
77
|
+
version: 0.0.6
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: guard-test
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,6 +158,7 @@ files:
|
|
142
158
|
- lib/taskwarrior.rb
|
143
159
|
- lib/taskwarrior/annotation.rb
|
144
160
|
- lib/taskwarrior/annotation_mapper.rb
|
161
|
+
- lib/taskwarrior/attributes.rb
|
145
162
|
- lib/taskwarrior/priority_mapper.rb
|
146
163
|
- lib/taskwarrior/project.rb
|
147
164
|
- lib/taskwarrior/repository.rb
|