smart_asana 0.0.1 → 0.0.2
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/README.md +18 -6
- data/bin/asana +1 -13
- data/lib/smart_asana.rb +67 -32
- data/lib/smart_asana/version.rb +1 -1
- data/smart_asana.gemspec +2 -2
- metadata +5 -6
data/README.md
CHANGED
@@ -28,10 +28,7 @@ variable. This will be used to construct a new connection to Asana.
|
|
28
28
|
Once the environmental variable is configured, you can add your tasks
|
29
29
|
from the command-line.
|
30
30
|
|
31
|
-
$ asana
|
32
|
-
|
33
|
-
**Note:** You must include single-quotes around the task entry. Shells
|
34
|
-
like zsh try to parse the indicator characters without them.
|
31
|
+
$ asana This is a new task #TheWorkspace +1
|
35
32
|
|
36
33
|
### Specifying Indicators
|
37
34
|
|
@@ -43,7 +40,7 @@ You can assign a task to today, upcoming, or later. All other tasks are
|
|
43
40
|
dropped into your inbox. For more information about these status types,
|
44
41
|
check out the [Tasks documentation][].
|
45
42
|
|
46
|
-
$ asana
|
43
|
+
$ asana This task is for today +1
|
47
44
|
|
48
45
|
```text
|
49
46
|
1 - today
|
@@ -53,11 +50,26 @@ check out the [Tasks documentation][].
|
|
53
50
|
|
54
51
|
You can also assign a task to a specific workspace.
|
55
52
|
|
56
|
-
$ asana
|
53
|
+
$ asana This task is in #MyWorkspace
|
57
54
|
|
58
55
|
Since workspace names can contain multiple words, you'll want to use
|
59
56
|
`MixedCase` indicators. Also, workspace indicators are not case-sensitive.
|
60
57
|
|
58
|
+
If you want to assign a due date to a task, you can specify it in
|
59
|
+
a variety of ways.
|
60
|
+
|
61
|
+
```text
|
62
|
+
today - today's date
|
63
|
+
tomorrow - tomorrow's date
|
64
|
+
friday - Friday's date (other days of the week work, as well)
|
65
|
+
```
|
66
|
+
|
67
|
+
$ asana This task is due ^today
|
68
|
+
|
69
|
+
It is also possible to enter an arbitrary date for a task.
|
70
|
+
|
71
|
+
$ asana This task is due on ^2013-01-01
|
72
|
+
|
61
73
|
|
62
74
|
## Contributing
|
63
75
|
|
data/bin/asana
CHANGED
@@ -2,20 +2,8 @@
|
|
2
2
|
require 'asana'
|
3
3
|
require 'smart_asana'
|
4
4
|
|
5
|
-
attrs = SmartAsana.parse(ARGV[0])
|
6
|
-
|
7
5
|
Asana.configure do |client|
|
8
6
|
client.api_key = ENV['ASANA_API_KEY']
|
9
7
|
end
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
workspace = workspaces.select{ |w|
|
14
|
-
w.name.downcase == attrs[:workspace].downcase
|
15
|
-
}.first
|
16
|
-
|
17
|
-
attrs.delete(:workspace)
|
18
|
-
|
19
|
-
workspace ||= workspaces.first
|
20
|
-
|
21
|
-
workspace.create_task(attrs)
|
9
|
+
SmartAsana.create_task(ARGV)
|
data/lib/smart_asana.rb
CHANGED
@@ -1,49 +1,41 @@
|
|
1
1
|
require 'active_support/core_ext/string/inflections'
|
2
|
-
|
3
2
|
require "smart_asana/version"
|
4
3
|
|
5
4
|
module SmartAsana
|
6
5
|
|
7
|
-
INDICATOR_CHARACTERS = %w{
|
6
|
+
INDICATOR_CHARACTERS = %w{+ # ^}
|
7
|
+
DAYS_OF_WEEK = %w{monday tuesday wednesday thursday friday saturday sunday}
|
8
8
|
|
9
9
|
class << self
|
10
10
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
hash[:name] = name
|
17
|
-
end
|
11
|
+
def create_task(attrs)
|
12
|
+
attrs = parse(attrs)
|
13
|
+
workspace = workspace(attrs)
|
14
|
+
attrs.delete(:workspace)
|
15
|
+
workspace.create_task(attrs)
|
18
16
|
end
|
19
17
|
|
20
18
|
private
|
21
19
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
else
|
31
|
-
'inbox'
|
20
|
+
def workspace(attrs)
|
21
|
+
workspaces = Asana::Workspace.all
|
22
|
+
|
23
|
+
if attrs[:workspace]
|
24
|
+
workspace = workspaces.select { |w|
|
25
|
+
w.name.downcase == attrs[:workspace].downcase
|
26
|
+
}.first
|
27
|
+
return workspace unless !workspace
|
32
28
|
end
|
29
|
+
|
30
|
+
workspaces.first
|
33
31
|
end
|
34
32
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
array[:assignee_status] = assignee_status(attr)
|
42
|
-
when '#'
|
43
|
-
array[:workspace] = attr.titleize
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
33
|
+
def parse(words)
|
34
|
+
indicators = indicators(words)
|
35
|
+
name = name(words, indicators)
|
36
|
+
attributes(indicators).tap { |hash|
|
37
|
+
hash[:name] = name
|
38
|
+
}
|
47
39
|
end
|
48
40
|
|
49
41
|
def indicators(words)
|
@@ -64,6 +56,49 @@ module SmartAsana
|
|
64
56
|
}.join(' ')
|
65
57
|
end
|
66
58
|
|
67
|
-
|
59
|
+
def attributes(indicators)
|
60
|
+
attrs = {}.tap { |array|
|
61
|
+
indicators.each do |ind|
|
62
|
+
attr = ind[1..ind.length]
|
63
|
+
case ind[0]
|
64
|
+
when '+'
|
65
|
+
array[:assignee_status] = assignee_status(attr)
|
66
|
+
when '#'
|
67
|
+
array[:workspace] = attr.titleize
|
68
|
+
when '^'
|
69
|
+
array[:due_on] = due_on(attr)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
def assignee_status(attr)
|
76
|
+
case attr
|
77
|
+
when '1'
|
78
|
+
'today'
|
79
|
+
when '2'
|
80
|
+
'upcoming'
|
81
|
+
when '3'
|
82
|
+
'later'
|
83
|
+
else
|
84
|
+
'inbox'
|
85
|
+
end
|
86
|
+
end
|
68
87
|
|
88
|
+
def due_on(attr)
|
89
|
+
if attr == 'today'
|
90
|
+
Date.today
|
91
|
+
elsif attr == 'tomorrow'
|
92
|
+
Date.today.next_day
|
93
|
+
elsif DAYS_OF_WEEK.include?(attr)
|
94
|
+
1.upto(7).each do |i|
|
95
|
+
date = Date.today.next_day(i)
|
96
|
+
return date if date.send("#{attr}?".to_sym)
|
97
|
+
end
|
98
|
+
else
|
99
|
+
Date.parse(attr)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
69
104
|
end
|
data/lib/smart_asana/version.rb
CHANGED
data/smart_asana.gemspec
CHANGED
@@ -4,8 +4,8 @@ require File.expand_path('../lib/smart_asana/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Ryan Bright"]
|
6
6
|
gem.email = ["ryan@rbright.net"]
|
7
|
-
gem.description = %q{Add Asana
|
8
|
-
gem.summary = %q{Add Asana
|
7
|
+
gem.description = %q{Add Asana tasks using Remember the Milk's Smart Add syntax}
|
8
|
+
gem.summary = %q{Add Asana tasks using Remember the Milk's Smart Add syntax}
|
9
9
|
gem.homepage = "http://github.com/rbright/smart_asana"
|
10
10
|
|
11
11
|
gem.add_dependency 'activesupport', '~> 3.2.3'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_asana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 0.0.3
|
46
|
-
description: Add Asana
|
46
|
+
description: Add Asana tasks using Remember the Milk's Smart Add syntax
|
47
47
|
email:
|
48
48
|
- ryan@rbright.net
|
49
49
|
executables:
|
@@ -80,9 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project:
|
83
|
-
rubygems_version: 1.8.
|
83
|
+
rubygems_version: 1.8.23
|
84
84
|
signing_key:
|
85
85
|
specification_version: 3
|
86
|
-
summary: Add Asana
|
86
|
+
summary: Add Asana tasks using Remember the Milk's Smart Add syntax
|
87
87
|
test_files: []
|
88
|
-
has_rdoc:
|