taskwarrior 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,8 @@ language: ruby
2
2
 
3
3
  rvm:
4
4
  - 1.9.3
5
+ - jruby-19mode
6
+ - 1.8.7
5
7
 
6
8
  before_script:
7
9
  - mkdir ~/.task
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.
@@ -1,6 +1,11 @@
1
+ require 'active_model'
2
+ require 'multi_json'
3
+ require 'date'
4
+
1
5
  require "taskwarrior/version"
2
6
 
3
7
  require "taskwarrior/validations"
8
+ require "taskwarrior/attributes"
4
9
 
5
10
  require "taskwarrior/repository"
6
11
  require "taskwarrior/task"
@@ -1,6 +1,3 @@
1
- require 'active_model'
2
- require 'date'
3
-
4
1
  module TaskWarrior
5
2
  class Annotation
6
3
  attr_accessor :entry, :description
@@ -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
@@ -1,5 +1,3 @@
1
- require 'active_model'
2
-
3
1
  module TaskWarrior
4
2
  class Project
5
3
  attr_reader :name, :tasks
@@ -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
- JSON.parse(input).each{|json|
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
@@ -1,5 +1,3 @@
1
- require 'active_model'
2
-
3
1
  module TaskWarrior
4
2
  class Tag
5
3
  attr_reader :name
@@ -1,28 +1,34 @@
1
- require 'active_model'
2
-
3
1
  module TaskWarrior
4
2
  class Task
5
- attr_accessor :description, :id, :entry, :status, :uuid,
6
- :project, :dependencies, :parent, :children,
7
- :priority, :tags, :annotations,
8
- :start_at, :wait_at, :end_at, :due_at
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 => { :only_integer => true, :greater_than => 0}
12
+ validates :id, :numericality => {
13
+ :only_integer => true,
14
+ :greater_than => 0
15
+ }
15
16
 
16
- validates :uuid, :format => {:with => /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/,
17
- :message => "'%{value}' does not match the expected format of a UUID"}
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 => {:in => [:pending, :waiting, :complete], :message => "%{value} is not a valid status"}
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 => [:high, :medium, :low],
23
- :allow_nil => true,
28
+ :in => [:high, :medium, :low],
29
+ :allow_nil => true,
24
30
  :allow_blank => true,
25
- :message => "%{value} is not a valid priority"
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
- # TODO Find a way to call attributes instead of listing them here again
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
@@ -1,3 +1,3 @@
1
1
  module TaskWarrior
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -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.5'
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
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.5
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.5
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