redpomo-reloaded 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Dockerfile +5 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +139 -0
- data/Guardfile +23 -0
- data/LICENSE +22 -0
- data/README.md +176 -0
- data/Rakefile +6 -0
- data/bin/redpomo +7 -0
- data/docker-compose.yml +7 -0
- data/lib/redpomo.rb +10 -0
- data/lib/redpomo/cli.rb +172 -0
- data/lib/redpomo/config.rb +26 -0
- data/lib/redpomo/entries_printer.rb +33 -0
- data/lib/redpomo/entry.rb +65 -0
- data/lib/redpomo/file_cache.rb +44 -0
- data/lib/redpomo/fuzzy_converter.rb +68 -0
- data/lib/redpomo/issue.rb +38 -0
- data/lib/redpomo/null_cache.rb +9 -0
- data/lib/redpomo/numeric_ext.rb +30 -0
- data/lib/redpomo/task.rb +103 -0
- data/lib/redpomo/task_list.rb +61 -0
- data/lib/redpomo/templates/config.yml +47 -0
- data/lib/redpomo/templates/issue_stub.textile +7 -0
- data/lib/redpomo/tracker.rb +175 -0
- data/lib/redpomo/ui.rb +73 -0
- data/lib/redpomo/version.rb +3 -0
- data/redpomo.gemspec +33 -0
- data/spec/file_cache_spec.rb +22 -0
- data/spec/fixtures/add_results.txt +4 -0
- data/spec/fixtures/cassettes/cli_add.yml +102 -0
- data/spec/fixtures/cassettes/cli_close.yml +50 -0
- data/spec/fixtures/cassettes/cli_pull.yml +1222 -0
- data/spec/fixtures/cassettes/cli_push.yml +297 -0
- data/spec/fixtures/cassettes/close_issue.yml +50 -0
- data/spec/fixtures/cassettes/create_issue.yml +102 -0
- data/spec/fixtures/cassettes/issues.yml +449 -0
- data/spec/fixtures/cassettes/push_entry.yml +55 -0
- data/spec/fixtures/close_results.txt +2 -0
- data/spec/fixtures/config.yml +16 -0
- data/spec/fixtures/printer_output.txt +16 -0
- data/spec/fixtures/proper_timelog.csv +4 -0
- data/spec/fixtures/pull_results.txt +20 -0
- data/spec/fixtures/tasks.txt +3 -0
- data/spec/fixtures/timelog.csv +6 -0
- data/spec/integration/add_spec.rb +29 -0
- data/spec/integration/init_spec.rb +33 -0
- data/spec/lib/redpomo/cli_spec.rb +91 -0
- data/spec/lib/redpomo/entry_spec.rb +23 -0
- data/spec/lib/redpomo/fuzzy_converter_spec.rb +65 -0
- data/spec/lib/redpomo/task_spec.rb +39 -0
- data/spec/lib/redpomo/tracker_spec.rb +72 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/support/cli_helpers.rb +76 -0
- data/spec/support/fixtures.rb +24 -0
- data/spec/support/ruby_ext.rb +20 -0
- data/spec/tmp/REDME.md +0 -0
- metadata +296 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ba8c0ed292bc0c10264cb48240e0070fa13ba8dd
|
4
|
+
data.tar.gz: b9baf74829f4321029465182679b85e564b34e53
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 93cc72508d647adecf51896d5377da3d8e79fe2a730b55ef143850c63b632055cb00329ffba42544a95be5943c81a3627afe13fcaa51a589d7cb69cc0bb0c561
|
7
|
+
data.tar.gz: 271b0ebe542e6d88b70a49cd89a28e83e1501fc6bd9ad115f34b17cd47dfdb4eef35795bdbf306f037e604e6155812dd36c8ff8ff68b89de58b04d766a7d629f
|
data/Dockerfile
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
redpomo (0.0.13)
|
5
|
+
activesupport
|
6
|
+
applescript
|
7
|
+
launchy
|
8
|
+
rest-client
|
9
|
+
terminal-table
|
10
|
+
thor
|
11
|
+
todo-txt
|
12
|
+
|
13
|
+
GEM
|
14
|
+
remote: https://rubygems.org/
|
15
|
+
specs:
|
16
|
+
activesupport (5.0.1)
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
i18n (~> 0.7)
|
19
|
+
minitest (~> 5.1)
|
20
|
+
tzinfo (~> 1.1)
|
21
|
+
addressable (2.5.0)
|
22
|
+
public_suffix (~> 2.0, >= 2.0.2)
|
23
|
+
applescript (1.0)
|
24
|
+
coderay (1.1.1)
|
25
|
+
concurrent-ruby (1.0.4)
|
26
|
+
crack (0.4.3)
|
27
|
+
safe_yaml (~> 1.0.0)
|
28
|
+
diff-lcs (1.3)
|
29
|
+
docile (1.1.5)
|
30
|
+
domain_name (0.5.20161129)
|
31
|
+
unf (>= 0.0.5, < 1.0.0)
|
32
|
+
ffi (1.9.17)
|
33
|
+
formatador (0.2.5)
|
34
|
+
guard (2.14.1)
|
35
|
+
formatador (>= 0.2.4)
|
36
|
+
listen (>= 2.7, < 4.0)
|
37
|
+
lumberjack (~> 1.0)
|
38
|
+
nenv (~> 0.1)
|
39
|
+
notiffany (~> 0.0)
|
40
|
+
pry (>= 0.9.12)
|
41
|
+
shellany (~> 0.0)
|
42
|
+
thor (>= 0.18.1)
|
43
|
+
guard-compat (1.2.1)
|
44
|
+
guard-rspec (4.7.3)
|
45
|
+
guard (~> 2.1)
|
46
|
+
guard-compat (~> 1.1)
|
47
|
+
rspec (>= 2.99.0, < 4.0)
|
48
|
+
hashdiff (0.3.2)
|
49
|
+
http-cookie (1.0.3)
|
50
|
+
domain_name (~> 0.5)
|
51
|
+
i18n (0.8.0)
|
52
|
+
json (2.0.3)
|
53
|
+
launchy (2.4.3)
|
54
|
+
addressable (~> 2.3)
|
55
|
+
listen (3.1.5)
|
56
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
57
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
58
|
+
ruby_dep (~> 1.2)
|
59
|
+
lumberjack (1.0.11)
|
60
|
+
metaclass (0.0.4)
|
61
|
+
method_source (0.8.2)
|
62
|
+
mime-types (3.1)
|
63
|
+
mime-types-data (~> 3.2015)
|
64
|
+
mime-types-data (3.2016.0521)
|
65
|
+
minitest (5.10.1)
|
66
|
+
mocha (1.2.1)
|
67
|
+
metaclass (~> 0.0.1)
|
68
|
+
nenv (0.3.0)
|
69
|
+
netrc (0.11.0)
|
70
|
+
notiffany (0.1.1)
|
71
|
+
nenv (~> 0.1)
|
72
|
+
shellany (~> 0.0)
|
73
|
+
pry (0.10.4)
|
74
|
+
coderay (~> 1.1.0)
|
75
|
+
method_source (~> 0.8.1)
|
76
|
+
slop (~> 3.4)
|
77
|
+
public_suffix (2.0.5)
|
78
|
+
rake (12.0.0)
|
79
|
+
rb-fsevent (0.9.8)
|
80
|
+
rb-inotify (0.9.8)
|
81
|
+
ffi (>= 0.5.0)
|
82
|
+
rest-client (2.0.1)
|
83
|
+
http-cookie (>= 1.0.2, < 2.0)
|
84
|
+
mime-types (>= 1.16, < 4.0)
|
85
|
+
netrc (~> 0.8)
|
86
|
+
rspec (3.5.0)
|
87
|
+
rspec-core (~> 3.5.0)
|
88
|
+
rspec-expectations (~> 3.5.0)
|
89
|
+
rspec-mocks (~> 3.5.0)
|
90
|
+
rspec-core (3.5.4)
|
91
|
+
rspec-support (~> 3.5.0)
|
92
|
+
rspec-expectations (3.5.0)
|
93
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
94
|
+
rspec-support (~> 3.5.0)
|
95
|
+
rspec-mocks (3.5.0)
|
96
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
97
|
+
rspec-support (~> 3.5.0)
|
98
|
+
rspec-support (3.5.0)
|
99
|
+
ruby_dep (1.5.0)
|
100
|
+
safe_yaml (1.0.4)
|
101
|
+
shellany (0.0.1)
|
102
|
+
simplecov (0.13.0)
|
103
|
+
docile (~> 1.1.0)
|
104
|
+
json (>= 1.8, < 3)
|
105
|
+
simplecov-html (~> 0.10.0)
|
106
|
+
simplecov-html (0.10.0)
|
107
|
+
slop (3.6.0)
|
108
|
+
terminal-table (1.7.3)
|
109
|
+
unicode-display_width (~> 1.1.1)
|
110
|
+
thor (0.19.4)
|
111
|
+
thread_safe (0.3.5)
|
112
|
+
todo-txt (0.11)
|
113
|
+
tzinfo (1.2.2)
|
114
|
+
thread_safe (~> 0.1)
|
115
|
+
unf (0.1.4)
|
116
|
+
unf_ext
|
117
|
+
unf_ext (0.0.7.2)
|
118
|
+
unicode-display_width (1.1.3)
|
119
|
+
vcr (3.0.3)
|
120
|
+
webmock (2.3.2)
|
121
|
+
addressable (>= 2.3.6)
|
122
|
+
crack (>= 0.3.2)
|
123
|
+
hashdiff
|
124
|
+
|
125
|
+
PLATFORMS
|
126
|
+
ruby
|
127
|
+
|
128
|
+
DEPENDENCIES
|
129
|
+
guard-rspec
|
130
|
+
mocha
|
131
|
+
rake
|
132
|
+
redpomo!
|
133
|
+
rspec
|
134
|
+
simplecov
|
135
|
+
vcr
|
136
|
+
webmock
|
137
|
+
|
138
|
+
BUNDLED WITH
|
139
|
+
1.14.3
|
data/Guardfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
options = {
|
2
|
+
cmd: "bundle exec rspec",
|
3
|
+
all_on_start: true,
|
4
|
+
failed_mode: :focus,
|
5
|
+
focues: true
|
6
|
+
}
|
7
|
+
|
8
|
+
guard :rspec, options do
|
9
|
+
require "guard/rspec/dsl"
|
10
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
11
|
+
|
12
|
+
# Feel free to open issues for suggestions and improvements
|
13
|
+
|
14
|
+
# RSpec files
|
15
|
+
rspec = dsl.rspec
|
16
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
17
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
18
|
+
watch(rspec.spec_files)
|
19
|
+
|
20
|
+
# Ruby files
|
21
|
+
ruby = dsl.ruby
|
22
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
23
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Stefano Verna
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
# Redpomo: Redmine, Pomodoro.app and Todo-txt. Together.
|
2
|
+
|
3
|
+
[![Build Status](https://secure.travis-ci.org/stefanoverna/redpomo.png)](http://travis-ci.org/stefanoverna/redpomo)
|
4
|
+
|
5
|
+
## Redpomo is for you if...
|
6
|
+
|
7
|
+
* You're an hopeless nerd and like CLIs;
|
8
|
+
* You (or you company) use Redmine to track issues and time spent on projects;
|
9
|
+
* You heard about [Todo.txt](http://todotxt.com/) and the [Pomodoro technique](http://www.pomodorotechnique.com/);
|
10
|
+
|
11
|
+
Still here? Great!
|
12
|
+
|
13
|
+
## What Redpomo can do for me?
|
14
|
+
|
15
|
+
Redpomo is an opinionated CLI tool that makes it darmn easy to:
|
16
|
+
|
17
|
+
* Manage multiple Redmine instances at once;
|
18
|
+
* Create, close and navigate Redmine issues assigned to you;
|
19
|
+
* Push your completed pomodoros to remote Redmine as project time-tracks;
|
20
|
+
|
21
|
+
## It integrates nicely with [Todo.txt](http://todotxt.com/)!
|
22
|
+
|
23
|
+
Instead of reinventing yet another time the weel, Redpomo talks with
|
24
|
+
your remote Redmine instances, and syncs all the issues assigned to
|
25
|
+
your user with your local machine, converting them into Todo.txt tasks.
|
26
|
+
|
27
|
+
Just launch `redpomo` from your command line, and you're done:
|
28
|
+
|
29
|
+
```
|
30
|
+
$ redpomo
|
31
|
+
Pulled 4 issues.
|
32
|
+
|
33
|
+
$ todo.sh ls
|
34
|
+
01 Write Redpomo README #1340 +redpomo @welaika
|
35
|
+
02 Publish to App Store #1140 +love-this-song @welaika
|
36
|
+
03 Meeting with client #1490 +nike @welaika
|
37
|
+
04 Call mom
|
38
|
+
--
|
39
|
+
TODO: 4 of 4 tasks shown
|
40
|
+
```
|
41
|
+
|
42
|
+
The generic syntax for the imported task will be the following (thanks to
|
43
|
+
[asciiflow](http://www.asciiflow.com/) for the drawing):
|
44
|
+
|
45
|
+
```
|
46
|
+
(A) 2012-11-25 Make some delicious coffee #1800 +next-big-project @welaika
|
47
|
+
| | | | | |
|
48
|
+
| | | | | +-> Redmine instance identifier
|
49
|
+
| | | | |
|
50
|
+
| | | | +-> Redmine project for the issue
|
51
|
+
| | | |
|
52
|
+
| | +-> Issue title +-> Issue ID
|
53
|
+
| |
|
54
|
+
| +-> Issue expiration date (if present)
|
55
|
+
|
|
56
|
+
+-> Issue priority (A means Immediate)
|
57
|
+
```
|
58
|
+
|
59
|
+
### How to create new Redmine self-assigned issues
|
60
|
+
|
61
|
+
That's so simple:
|
62
|
+
|
63
|
+
```
|
64
|
+
$ redpomo add 'quote the project +random-project @welaika'
|
65
|
+
Issue created, see it at http://code.welaika.com/issues/3659
|
66
|
+
```
|
67
|
+
|
68
|
+
* If you specify a default project on your `~/.redpomo` configuration
|
69
|
+
file, you can even left out the `+random-project` part.
|
70
|
+
* If you don't specify a task, your predefined editor will pop up and
|
71
|
+
ask you to write the title and (optionally) the description for the
|
72
|
+
issue;
|
73
|
+
* On iTerm 2 terminals, just command + click on the URL to open up the
|
74
|
+
browser!
|
75
|
+
|
76
|
+
### How to close a Redmine issue
|
77
|
+
|
78
|
+
```
|
79
|
+
$ redpomo close 3 -m "Finally done"
|
80
|
+
Issue updated, see it at http://code.welaika.com/issues/1490
|
81
|
+
```
|
82
|
+
|
83
|
+
### Opening the browser to a specific Redmine issue
|
84
|
+
|
85
|
+
```
|
86
|
+
$ redpomo open 3
|
87
|
+
# -> takes your browser to http://code.welaika.com/issues/1490
|
88
|
+
```
|
89
|
+
|
90
|
+
## It integrates nicely with [Pomodoro.app](https://github.com/ugol/pomodoro)!
|
91
|
+
|
92
|
+
If you need to start working on some Redmine issue, just use the `start`
|
93
|
+
command:
|
94
|
+
|
95
|
+
```
|
96
|
+
$ redpomo start 3
|
97
|
+
```
|
98
|
+
|
99
|
+
This will communicate via Applescript with Pomodoro.app, and will automatically
|
100
|
+
start a new pomodoro for you: the description of the pomodoro will contain both
|
101
|
+
the ID of the Redmine issue (ie. #1234), and the Redmine instance identifier
|
102
|
+
(ie. @welaika).
|
103
|
+
|
104
|
+
This is important: in this way we will be able to remap completed pomodoros back
|
105
|
+
to Redmine issues later on!
|
106
|
+
|
107
|
+
### Pushing local pomodoros as Redmine time-tracks
|
108
|
+
|
109
|
+
Here comes the best one. Open the "Pomodoro Stats" panel, and click on
|
110
|
+
the Export button. This will generate a CSV file full of all your completed
|
111
|
+
pomodoros.
|
112
|
+
|
113
|
+
Now we can pass this file to Redpomo:
|
114
|
+
|
115
|
+
```
|
116
|
+
$ redpomo push --dry-run --fuzzy ~/pomodoros.csv
|
117
|
+
|
118
|
+
+----------+------------+---------+------------------------+----------+-------+-------+
|
119
|
+
| Monday 06/18/12 - 8 hours |
|
120
|
+
+----------+------------+---------+------------------------+----------+-------+-------+
|
121
|
+
| Context | Project | Issue # | Description | Duration | From | To |
|
122
|
+
+----------+------------+---------+------------------------+----------+-------+-------+
|
123
|
+
| welaika | nike | 1392 | Project publishing | 2 hours | 08:02 | 10:49 |
|
124
|
+
| welaika | nike | 1390 | Project subtitle | 2 hours | 10:49 | 13:05 |
|
125
|
+
| cantiere | railsyard | | Resource trees | 2 hours | 13:05 | 15:30 |
|
126
|
+
| welaika | nike | 1392 | Project publishing | 32 mins | 15:30 | 16:03 |
|
127
|
+
| cantiere | railsyard | | Resource trees | 25 mins | 16:03 | 16:28 |
|
128
|
+
+----------+------------+---------+------------------------+----------+-------+-------+
|
129
|
+
```
|
130
|
+
|
131
|
+
Isn't it awesome?!
|
132
|
+
|
133
|
+
* The `--dry-run` option tells Redpomo just to print out the parsed timetracks, without
|
134
|
+
pushing timetracks to the various Redmine instances yet;
|
135
|
+
* The `--fuzzy` option merges contiguous pomodoros related to the same Redmine issue;
|
136
|
+
|
137
|
+
## Installation and setup
|
138
|
+
|
139
|
+
Install it yourself as:
|
140
|
+
|
141
|
+
```
|
142
|
+
$ gem install redpomo
|
143
|
+
```
|
144
|
+
|
145
|
+
And then configure it with the following command:
|
146
|
+
|
147
|
+
```
|
148
|
+
$ redpomo init
|
149
|
+
```
|
150
|
+
|
151
|
+
This will create a new `.redpomo` skeleton file to your home directory, where
|
152
|
+
you'll need to specify all the details of your Redmine instances. Easy
|
153
|
+
stuff.
|
154
|
+
|
155
|
+
## Contributing
|
156
|
+
|
157
|
+
Redpomo is still in its early development. Any help would be much appreciated!
|
158
|
+
|
159
|
+
1. Fork it
|
160
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
161
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
162
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
163
|
+
5. Create new Pull Request
|
164
|
+
|
165
|
+
## License
|
166
|
+
|
167
|
+
(The MIT License)
|
168
|
+
|
169
|
+
Copyright © 2011 Stefano Verna
|
170
|
+
|
171
|
+
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:
|
172
|
+
|
173
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
174
|
+
|
175
|
+
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.
|
176
|
+
|
data/Rakefile
ADDED
data/bin/redpomo
ADDED
data/docker-compose.yml
ADDED
data/lib/redpomo.rb
ADDED
data/lib/redpomo/cli.rb
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
require 'redpomo/config'
|
5
|
+
require 'redpomo/task_list'
|
6
|
+
require 'redpomo/entry'
|
7
|
+
require 'redpomo/entries_printer'
|
8
|
+
require 'redpomo/fuzzy_converter'
|
9
|
+
|
10
|
+
module Redpomo
|
11
|
+
class CLI < ::Thor
|
12
|
+
include Thor::Actions
|
13
|
+
|
14
|
+
def initialize(*)
|
15
|
+
super
|
16
|
+
the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
|
17
|
+
Redpomo.ui = UI::Shell.new(the_shell)
|
18
|
+
configure!
|
19
|
+
end
|
20
|
+
|
21
|
+
default_task :pull
|
22
|
+
class_option "config", :aliases => "-c", default: '~/.redpomo'
|
23
|
+
class_option "no-color", :type => :boolean
|
24
|
+
|
25
|
+
map "o" => :open
|
26
|
+
map "c" => :close
|
27
|
+
map "a" => :add
|
28
|
+
|
29
|
+
desc "add [TASK]", "creates a new task on Todo.txt, forwarding it to the remote tracker"
|
30
|
+
method_option :description, aliases: "-d"
|
31
|
+
def add(subject = nil)
|
32
|
+
description = @options[:description]
|
33
|
+
|
34
|
+
if subject.blank?
|
35
|
+
message_path = Tempfile.new('issue').path + ".textile"
|
36
|
+
template "issue_stub.textile", message_path, verbose: false
|
37
|
+
subject, description = parse_message open_editor(message_path)
|
38
|
+
end
|
39
|
+
|
40
|
+
issue = Task.new(nil, subject).to_issue
|
41
|
+
issue.description = description
|
42
|
+
|
43
|
+
if issue.tracker.present?
|
44
|
+
issue.create!
|
45
|
+
task = issue.to_task
|
46
|
+
task.add!
|
47
|
+
|
48
|
+
Redpomo.ui.info "Issue created, see it at #{task.url}"
|
49
|
+
else
|
50
|
+
Redpomo.ui.error "Cannot create issue, unknown tracker."
|
51
|
+
exit 1
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "pull", "imports Redmine open issues into local todo.txt"
|
56
|
+
def pull
|
57
|
+
TaskList.pull_from_trackers!
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "push [LOGFILE]", "parses Pomodoro export file and imports to Redmine clients"
|
61
|
+
method_option :fuzzy, aliases: "-f", type: :boolean
|
62
|
+
method_option :dry_run, aliases: "-n", type: :boolean
|
63
|
+
def push(path = nil)
|
64
|
+
|
65
|
+
csv = if path.present?
|
66
|
+
File.read(File.expand_path(path))
|
67
|
+
else
|
68
|
+
require 'applescript'
|
69
|
+
AppleScript.execute('tell application "Pomodoro" to take log')
|
70
|
+
end
|
71
|
+
|
72
|
+
if csv.blank?
|
73
|
+
if path.present?
|
74
|
+
Redpomo.ui.error "Empty CSV provided!"
|
75
|
+
else
|
76
|
+
Redpomo.ui.error "Empty Pomodoro log!"
|
77
|
+
Redpomo.ui.info "Maybe you need to this Pomodoro fork? https://github.com/stefanoverna/pomodoro"
|
78
|
+
end
|
79
|
+
exit 1
|
80
|
+
end
|
81
|
+
|
82
|
+
entries = Entry.load_from_csv(csv)
|
83
|
+
entries = FuzzyConverter.convert(entries) if @options[:fuzzy]
|
84
|
+
|
85
|
+
unpushable_entries = entries.select {|entry| !entry.pushable? }
|
86
|
+
|
87
|
+
if unpushable_entries.any?
|
88
|
+
Redpomo.ui.error "Some pomodoros cannot be associated with a proper issue/project."
|
89
|
+
EntriesPrinter.print(unpushable_entries)
|
90
|
+
exit 1
|
91
|
+
end
|
92
|
+
|
93
|
+
if @options[:dry_run]
|
94
|
+
EntriesPrinter.print(entries)
|
95
|
+
else
|
96
|
+
entries.each(&:push!)
|
97
|
+
Redpomo.ui.info "Pushed #{entries.count} time entries"
|
98
|
+
if path.blank?
|
99
|
+
AppleScript.execute('tell application "Pomodoro" to clear')
|
100
|
+
Redpomo.ui.info "Cleared Pomodoro.app log"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
desc "open TASK", "opens up the Redmine issue page of the selected task"
|
106
|
+
def open(task_number)
|
107
|
+
task = TaskList.find(task_number)
|
108
|
+
task.open_in_browser!
|
109
|
+
end
|
110
|
+
|
111
|
+
desc "start TASK", "starts a Pomodoro session for the selected task"
|
112
|
+
def start(task_number)
|
113
|
+
task = TaskList.find(task_number)
|
114
|
+
task.start_pomodoro!
|
115
|
+
end
|
116
|
+
|
117
|
+
desc "close TASK", "marks a todo.txt task as complete, and closes the related Redmine issue"
|
118
|
+
method_option :message, aliases: "-m"
|
119
|
+
def close(task_number)
|
120
|
+
task = TaskList.find(task_number)
|
121
|
+
task.done!
|
122
|
+
task.close_issue!(@options[:message])
|
123
|
+
|
124
|
+
Redpomo.ui.info "Issue updated, see it at #{task.url}"
|
125
|
+
end
|
126
|
+
|
127
|
+
desc "init", "generates a .redpomo configuration file on your home directory"
|
128
|
+
def init(path = '~/.redpomo')
|
129
|
+
path = File.expand_path(path)
|
130
|
+
template "config.yml", path, verbose: false
|
131
|
+
open_editor(path)
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
def configure!
|
137
|
+
Config.load_from_yaml(options["config"])
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.source_root
|
141
|
+
File.dirname(__FILE__) + "/templates"
|
142
|
+
end
|
143
|
+
|
144
|
+
def parse_message(message)
|
145
|
+
# remove comments
|
146
|
+
message.gsub! /#.*$/, ''
|
147
|
+
# remove empty lines at beginning of string
|
148
|
+
message.gsub! /\A\n*/, ''
|
149
|
+
|
150
|
+
# first line is the subject, the rest is description
|
151
|
+
subject, description = message.split(/\n/, 2)
|
152
|
+
|
153
|
+
subject ||= ''
|
154
|
+
description ||= ''
|
155
|
+
|
156
|
+
[subject.strip, description.strip]
|
157
|
+
end
|
158
|
+
|
159
|
+
def open_editor(path)
|
160
|
+
editor = [ENV['REDPOMO_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? }
|
161
|
+
if editor
|
162
|
+
command = "#{editor} #{path}"
|
163
|
+
system(command)
|
164
|
+
File.read(path)
|
165
|
+
else
|
166
|
+
Redpomo.ui.error("To open #{path}, set $EDITOR or $REDPOMO_EDITOR")
|
167
|
+
exit 1
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
end
|