rtasklib 0.1.2.pre.alpha → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +9 -0
- data/lib/rtasklib/controller.rb +72 -3
- data/lib/rtasklib/models.rb +11 -11
- data/lib/rtasklib/version.rb +1 -1
- data/lib/rtasklib.rb +5 -3
- data/rtasklib.gemspec +2 -0
- metadata +8 -9
- data/rtasklib-0.1.0.gem +0 -0
- data/rubygem-rtasklib_0.1.0_all.deb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6594a20f1c965ccf953918bf9fb7eba89832dc70
|
4
|
+
data.tar.gz: 6c889440f54c76d7eac9f46e62ad1d7300e44399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23c9ecccf416dcf6e94835258096ec96dc5257d9ee1109a31014c11100bfd329b11b02ca42a59d2c72c095b6f360b21ddbdc5db1726cdf0c21dc61a6fb127b5b
|
7
|
+
data.tar.gz: b9962b934cca761f7a8e3c7ad623d76238a1b10722e0e1eb876c75d06640cf5b326e9339f31da34cfe73c12669f7b322d7e1f2652eef35afaf0c1782380aa670
|
data/Rakefile
CHANGED
data/lib/rtasklib/controller.rb
CHANGED
@@ -6,6 +6,10 @@ module Rtasklib
|
|
6
6
|
module Controller
|
7
7
|
extend self
|
8
8
|
|
9
|
+
# Retrieves the current task list from the TW database
|
10
|
+
#
|
11
|
+
# @return [Array<Models::TaskModel>]
|
12
|
+
# @api public
|
9
13
|
def all
|
10
14
|
all = []
|
11
15
|
Execute.task_popen3(*@override_a, "export") do |i, o, e, t|
|
@@ -16,19 +20,73 @@ module Rtasklib
|
|
16
20
|
all
|
17
21
|
end
|
18
22
|
|
19
|
-
def
|
23
|
+
def filter ids: nil, tags: nil, query: nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def add!
|
27
|
+
end
|
28
|
+
|
29
|
+
# def modify! attr:, val:, ids: nil, tags: nil, query: nil
|
30
|
+
# end
|
31
|
+
|
32
|
+
def undo!
|
33
|
+
end
|
34
|
+
|
35
|
+
def update_config! attr, val
|
20
36
|
Execute.task_popen3(*override_a, "config #{attr} #{val}") do |i, o, e, t|
|
21
37
|
return t.value
|
22
38
|
end
|
23
39
|
end
|
24
40
|
|
41
|
+
# Retrieves an array of hashes with info about the udas currently available
|
25
42
|
def get_udas
|
43
|
+
taskrc.config.attributes
|
44
|
+
.select { |attr, val| uda_attr? attr }
|
45
|
+
.sort
|
46
|
+
.chunk { |attr, val| arbitrary_attr attr }
|
47
|
+
.map do |attr, arr|
|
48
|
+
uda = arr.map do |pair|
|
49
|
+
key = deep_attr(pair[0])
|
50
|
+
val = pair[1]
|
51
|
+
[key, val]
|
52
|
+
end
|
53
|
+
{attr.to_sym => Hash[uda]}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Is a given attribute dealing with udas?
|
58
|
+
def uda_attr? attr
|
59
|
+
attr.to_s.start_with? "uda"
|
60
|
+
end
|
61
|
+
private :uda_attr?
|
62
|
+
|
63
|
+
# Returns part of attribute at a given depth
|
64
|
+
def arbitrary_attr attr, depth: 1
|
65
|
+
attr.to_s.split("_")[depth]
|
66
|
+
end
|
67
|
+
|
68
|
+
# Returns all attribute string after given depth
|
69
|
+
def deep_attr attr, depth: 2
|
70
|
+
attr.to_s.split("_")[depth..-1].join("_")
|
71
|
+
end
|
72
|
+
private :deep_attr
|
73
|
+
|
74
|
+
|
75
|
+
# Retrieve an array of the uda names
|
76
|
+
#
|
77
|
+
# @return [Array<String>]
|
78
|
+
# @api public
|
79
|
+
def get_uda_names
|
26
80
|
Execute.task_popen3(*@override_a, "_udas") do |i, o, e, t|
|
27
81
|
return o.read.each_line.map { |l| l.chomp }
|
28
82
|
end
|
29
83
|
end
|
30
84
|
|
31
85
|
# Checks if a given uda exists in the current task database
|
86
|
+
#
|
87
|
+
# @param uda_name [String] the uda name to check for
|
88
|
+
# @return [Boolean] whether it matches or not
|
89
|
+
# @api public
|
32
90
|
def check_uda uda_name
|
33
91
|
if get_udas.any? { |uda| uda == uda_name }
|
34
92
|
true
|
@@ -37,9 +95,16 @@ module Rtasklib
|
|
37
95
|
end
|
38
96
|
end
|
39
97
|
|
40
|
-
def create_uda name,
|
98
|
+
def create_uda name, type: "string", label: nil, values: nil,
|
99
|
+
default: nil, urgency: nil
|
41
100
|
label = name if label.nil?
|
42
101
|
p name, label, values, default, urgency
|
102
|
+
|
103
|
+
update_config "uda.#{name}.type", type
|
104
|
+
update_config "uda.#{name}.label", label
|
105
|
+
update_config "uda.#{name}.values", values unless values.nil?
|
106
|
+
update_config "uda.#{name}.default", default unless default.nil?
|
107
|
+
update_config "uda.#{name}.urgency", urgency unless urgency.nil?
|
43
108
|
end
|
44
109
|
|
45
110
|
def get_rc
|
@@ -58,10 +123,14 @@ module Rtasklib
|
|
58
123
|
version
|
59
124
|
end
|
60
125
|
|
61
|
-
#
|
126
|
+
# Converts a string of format "1.6.2 (adf342jsd)" to Gem::Version object
|
127
|
+
#
|
128
|
+
#
|
62
129
|
def to_gem_version raw
|
63
130
|
std_ver = raw.chomp.gsub(' ','.').delete('(').delete(')')
|
64
131
|
Gem::Version.new std_ver
|
65
132
|
end
|
133
|
+
private :to_gem_version
|
134
|
+
|
66
135
|
end
|
67
136
|
end
|
data/lib/rtasklib/models.rb
CHANGED
@@ -30,7 +30,7 @@ module Rtasklib::Models
|
|
30
30
|
class TaskModel
|
31
31
|
include Virtus.model
|
32
32
|
# perhaps use Veto
|
33
|
-
include ActiveModel::Validations
|
33
|
+
# include ActiveModel::Validations
|
34
34
|
|
35
35
|
# Default attributes from TW
|
36
36
|
# Should match: http://taskwarrior.org/docs/design/task.html
|
@@ -40,12 +40,12 @@ module Rtasklib::Models
|
|
40
40
|
# But on creation these should be set by `task`
|
41
41
|
attribute :status, String
|
42
42
|
attribute :uuid, String
|
43
|
-
attribute :entry,
|
43
|
+
attribute :entry, DateTime
|
44
44
|
|
45
45
|
# Optional for every task
|
46
|
-
attribute :start,
|
47
|
-
attribute :until,
|
48
|
-
attribute :scheduled,
|
46
|
+
attribute :start, DateTime
|
47
|
+
attribute :until, DateTime
|
48
|
+
attribute :scheduled, DateTime
|
49
49
|
attribute :annotation, Array[String]
|
50
50
|
attribute :tags, Array[String]
|
51
51
|
attribute :project, String
|
@@ -55,24 +55,24 @@ module Rtasklib::Models
|
|
55
55
|
attribute :priority, String
|
56
56
|
|
57
57
|
# Required only for tasks that are Deleted or Completed
|
58
|
-
attribute :end,
|
58
|
+
attribute :end, DateTime
|
59
59
|
|
60
60
|
# Required only for tasks that are Waiting
|
61
|
-
attribute :wait,
|
61
|
+
attribute :wait, DateTime
|
62
62
|
|
63
63
|
# Required only for tasks that are Recurring or have Recurring Parent
|
64
|
-
attribute :recur,
|
64
|
+
attribute :recur, DateTime
|
65
65
|
|
66
66
|
# Optional except for tasks with Recurring Parents
|
67
|
-
attribute :due,
|
67
|
+
attribute :due, DateTime
|
68
68
|
|
69
69
|
# Required only for tasks that have Recurring Child
|
70
|
-
attribute :parent,
|
70
|
+
attribute :parent, String
|
71
71
|
|
72
72
|
# Internal attributes should be read-only
|
73
73
|
attribute :mask, String
|
74
74
|
attribute :imask, String
|
75
|
-
attribute :modified,
|
75
|
+
attribute :modified, DateTime
|
76
76
|
|
77
77
|
# TODO: handle arbitrary UDA's
|
78
78
|
|
data/lib/rtasklib/version.rb
CHANGED
data/lib/rtasklib.rb
CHANGED
@@ -2,7 +2,6 @@ require_relative "rtasklib/version"
|
|
2
2
|
require_relative "rtasklib/models"
|
3
3
|
require_relative "rtasklib/execute"
|
4
4
|
require_relative "rtasklib/controller"
|
5
|
-
require_relative "rtasklib/serializer"
|
6
5
|
require_relative "rtasklib/taskrc"
|
7
6
|
|
8
7
|
require "open3"
|
@@ -11,7 +10,7 @@ require "pathname"
|
|
11
10
|
module Rtasklib
|
12
11
|
|
13
12
|
class TaskWarrior
|
14
|
-
attr_reader :version, :data_location, :taskrc,
|
13
|
+
attr_reader :version, :data_location, :taskrc,
|
15
14
|
:override, :override_a, :override_str
|
16
15
|
|
17
16
|
include Controller
|
@@ -31,7 +30,7 @@ module Rtasklib
|
|
31
30
|
override_h = DEFAULTS.merge({data_location: data}).merge(opts)
|
32
31
|
@override = Taskrc.new(override_h, :hash)
|
33
32
|
@override_a = override.model_to_rc
|
34
|
-
@
|
33
|
+
@taskrc = get_rc
|
35
34
|
|
36
35
|
# Check TaskWarrior version, and throw warning if unavailable
|
37
36
|
begin
|
@@ -48,4 +47,7 @@ module Rtasklib
|
|
48
47
|
version
|
49
48
|
end
|
50
49
|
end
|
50
|
+
|
51
|
+
# Add a convenience alias
|
52
|
+
TW = TaskWarrior
|
51
53
|
end
|
data/rtasklib.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.bindir = "exe"
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
|
+
spec.required_ruby_version = '>= 2.1'
|
22
|
+
spec.requirements << 'taskwarrior, >=2.4.0'
|
21
23
|
|
22
24
|
spec.add_dependency "virtus"
|
23
25
|
spec.add_dependency "activesupport"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rtasklib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Paul
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -249,9 +249,7 @@ files:
|
|
249
249
|
- lib/rtasklib/serializer.rb
|
250
250
|
- lib/rtasklib/taskrc.rb
|
251
251
|
- lib/rtasklib/version.rb
|
252
|
-
- rtasklib-0.1.0.gem
|
253
252
|
- rtasklib.gemspec
|
254
|
-
- rubygem-rtasklib_0.1.0_all.deb
|
255
253
|
- spec/controller_spec.rb
|
256
254
|
- spec/data/.task/backlog.data
|
257
255
|
- spec/data/.task/completed.data
|
@@ -276,15 +274,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
276
274
|
requirements:
|
277
275
|
- - ">="
|
278
276
|
- !ruby/object:Gem::Version
|
279
|
-
version: '
|
277
|
+
version: '2.1'
|
280
278
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
281
279
|
requirements:
|
282
|
-
- - "
|
280
|
+
- - ">="
|
283
281
|
- !ruby/object:Gem::Version
|
284
|
-
version:
|
285
|
-
requirements:
|
282
|
+
version: '0'
|
283
|
+
requirements:
|
284
|
+
- taskwarrior, >=2.4.0
|
286
285
|
rubyforge_project:
|
287
|
-
rubygems_version: 2.
|
286
|
+
rubygems_version: 2.4.5
|
288
287
|
signing_key:
|
289
288
|
specification_version: 4
|
290
289
|
summary: A Ruby wrapper around the TaskWarrior CLI
|
data/rtasklib-0.1.0.gem
DELETED
Binary file
|
Binary file
|