redpomo 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/redpomo/cli.rb +26 -4
- data/lib/redpomo/entry.rb +11 -3
- data/lib/redpomo/templates/config.yml +11 -4
- data/lib/redpomo/tracker.rb +5 -0
- data/lib/redpomo/version.rb +1 -1
- data/spec/fixtures/proper_timelog.csv +4 -0
- data/spec/lib/redpomo/cli_spec.rb +1 -1
- data/spec/lib/redpomo/entry_spec.rb +22 -0
- metadata +32 -28
data/lib/redpomo/cli.rb
CHANGED
@@ -53,18 +53,40 @@ module Redpomo
|
|
53
53
|
TaskList.pull_from_trackers!
|
54
54
|
end
|
55
55
|
|
56
|
-
desc "push LOGFILE", "parses Pomodoro export file and imports to Redmine clients"
|
56
|
+
desc "push [LOGFILE]", "parses Pomodoro export file and imports to Redmine clients"
|
57
57
|
method_option :fuzzy, aliases: "-f", type: :boolean
|
58
58
|
method_option :dry_run, aliases: "-n", type: :boolean
|
59
|
-
def push(path)
|
60
|
-
|
59
|
+
def push(path = nil)
|
60
|
+
|
61
|
+
csv = if path.present?
|
62
|
+
File.read(File.expand_path(path))
|
63
|
+
else
|
64
|
+
require 'applescript'
|
65
|
+
AppleScript.execute('tell application "Pomodoro" to take log')
|
66
|
+
end
|
67
|
+
|
68
|
+
if csv.blank?
|
69
|
+
if path.present?
|
70
|
+
Redpomo.ui.error "Empty CSV provided!"
|
71
|
+
else
|
72
|
+
Redpomo.ui.error "Empty Pomodoro log!"
|
73
|
+
Redpomo.ui.info "Maybe you need to this Pomodoro fork? https://github.com/stefanoverna/pomodoro"
|
74
|
+
end
|
75
|
+
exit 1
|
76
|
+
end
|
77
|
+
|
78
|
+
entries = Entry.load_from_csv(csv)
|
61
79
|
entries = FuzzyConverter.convert(entries) if @options[:fuzzy]
|
62
80
|
|
63
81
|
if @options[:dry_run]
|
64
82
|
EntriesPrinter.print(entries)
|
65
83
|
else
|
66
84
|
entries.each(&:push!)
|
67
|
-
Redpomo.ui.info "Pushed #{entries.count} time entries
|
85
|
+
Redpomo.ui.info "Pushed #{entries.count} time entries"
|
86
|
+
if path.blank?
|
87
|
+
AppleScript.execute('tell application "Pomodoro" to clear')
|
88
|
+
Redpomo.ui.info "Cleared Pomodoro.app log"
|
89
|
+
end
|
68
90
|
end
|
69
91
|
end
|
70
92
|
|
data/lib/redpomo/entry.rb
CHANGED
@@ -3,10 +3,18 @@ require 'csv'
|
|
3
3
|
module Redpomo
|
4
4
|
class Entry
|
5
5
|
|
6
|
-
def self.load_from_csv(
|
7
|
-
|
6
|
+
def self.load_from_csv(text)
|
7
|
+
csv_rows(text).map do |data|
|
8
8
|
Entry.new(data[0], DateTime.parse(data[1]), data[2].to_i * 60.0)
|
9
|
-
end.sort_by { |entry| entry.datetime }
|
9
|
+
end.compact.sort_by { |entry| entry.datetime }
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.csv_rows(text)
|
13
|
+
if text.match /^Export data created/
|
14
|
+
CSV.parse text.split("\n")[4..-1].join("\n")
|
15
|
+
else
|
16
|
+
CSV.parse text
|
17
|
+
end
|
10
18
|
end
|
11
19
|
|
12
20
|
attr_reader :text, :datetime, :duration
|
@@ -11,19 +11,25 @@ trackers:
|
|
11
11
|
token: "" # Find this at the following URL:
|
12
12
|
# http://mytracker.com/my/account
|
13
13
|
|
14
|
+
default_activity_id: 9 # Choose a timetrack activity ID from one
|
15
|
+
# of those specified at:
|
16
|
+
# http://mytracker.com/enumerations
|
17
|
+
#
|
18
|
+
# -- 9 is "Development" on clean Redmine
|
19
|
+
|
14
20
|
default_project_id: "project" # If timetracks you're pushing don't have
|
15
21
|
# a +project specified, use this.
|
16
22
|
|
17
23
|
default_priority_id: 4 # If issues you're adding don't have a
|
18
24
|
# priority specified, then use this.
|
19
25
|
#
|
20
|
-
# -- 4
|
26
|
+
# -- 4 is "Normal" on clean Redmine
|
21
27
|
|
22
28
|
closed_status_id: 5 # Identifier of the status used to mark
|
23
29
|
# issues as closed. Find this ID here:
|
24
30
|
# http://mytracker.com/issue_statuses
|
25
31
|
#
|
26
|
-
# -- 5
|
32
|
+
# -- 5 is "Closed" on clean Redmine
|
27
33
|
|
28
34
|
priority_ids: # Map a Todo.txt priority with a Redmine
|
29
35
|
# priority ID.
|
@@ -36,5 +42,6 @@ trackers:
|
|
36
42
|
# Find those IDs at the following URL:
|
37
43
|
# http://mytracker.com/enumerations
|
38
44
|
#
|
39
|
-
# -- 7, 6 and 5
|
40
|
-
#
|
45
|
+
# -- 7, 6 and 5 are "Immediate", "Urgent"
|
46
|
+
# and "High" on clean Redmine
|
47
|
+
|
data/lib/redpomo/tracker.rb
CHANGED
@@ -30,6 +30,7 @@ module Redpomo
|
|
30
30
|
@default_project_id = options[:default_project_id]
|
31
31
|
@default_priority_id = options[:default_priority_id]
|
32
32
|
@closed_status_id = options[:closed_status_id].to_i
|
33
|
+
@default_activity_id = options[:default_activity_id]
|
33
34
|
@priorities = options[:priority_ids]
|
34
35
|
end
|
35
36
|
|
@@ -84,6 +85,10 @@ module Redpomo
|
|
84
85
|
time_entry[:hours] = entry.duration / 3600.0
|
85
86
|
time_entry[:comments] = task.text
|
86
87
|
|
88
|
+
if @default_activity_id.present?
|
89
|
+
time_entry[:activity_id] = @default_activity_id.to_i
|
90
|
+
end
|
91
|
+
|
87
92
|
post("/time_entries", time_entry: time_entry)
|
88
93
|
end
|
89
94
|
|
data/lib/redpomo/version.rb
CHANGED
@@ -0,0 +1,4 @@
|
|
1
|
+
esportazione #1036 +giunti-web @cantiere,2012-05-15 23:10:44 +0000,10
|
2
|
+
Dialog Partner aggiuntivi #1016 @cantiere,2012-05-16 08:42:51 +0000,25
|
3
|
+
Dialog Partner aggiuntivi #1016 @cantiere,2012-05-16 09:21:35 +0000,25
|
4
|
+
Scorrimento barra orizzontale #1059 @cantiere,2012-05-16 10:01:09 +0000,25
|
@@ -26,7 +26,7 @@ describe Redpomo::CLI do
|
|
26
26
|
it "pushes the specified timelog to remote trackers" do
|
27
27
|
VCR.use_cassette('cli_push') do
|
28
28
|
cli_redpomo "push #{fixture("timelog.csv")}"
|
29
|
-
out.strip.should == "Pushed 2 time entries
|
29
|
+
out.strip.should == "Pushed 2 time entries"
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Redpomo::Entry do
|
4
|
+
|
5
|
+
describe "#csv_rows" do
|
6
|
+
|
7
|
+
it "parses Pomodoro's classic invalid CSV format" do
|
8
|
+
text = File.read(fixture("timelog.csv"))
|
9
|
+
rows = Redpomo::Entry.csv_rows(text)
|
10
|
+
rows.should have(2).rows
|
11
|
+
end
|
12
|
+
|
13
|
+
it "parses my Pomodoro fork proper CSV format" do
|
14
|
+
text = File.read(fixture("proper_timelog.csv"))
|
15
|
+
rows = Redpomo::Entry.csv_rows(text)
|
16
|
+
rows.should have(4).rows
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redpomo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70342142019580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70342142019580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: thor
|
27
|
-
requirement: &
|
27
|
+
requirement: &70342142019160 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70342142019160
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: todo-txt
|
38
|
-
requirement: &
|
38
|
+
requirement: &70342142018740 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70342142018740
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rest-client
|
49
|
-
requirement: &
|
49
|
+
requirement: &70342142018320 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70342142018320
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: launchy
|
60
|
-
requirement: &
|
60
|
+
requirement: &70342142017900 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70342142017900
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: applescript
|
71
|
-
requirement: &
|
71
|
+
requirement: &70342142017480 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70342142017480
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: terminal-table
|
82
|
-
requirement: &
|
82
|
+
requirement: &70342142017060 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70342142017060
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rspec
|
93
|
-
requirement: &
|
93
|
+
requirement: &70342142016640 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70342142016640
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: vcr
|
104
|
-
requirement: &
|
104
|
+
requirement: &70342142016220 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70342142016220
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: webmock
|
115
|
-
requirement: &
|
115
|
+
requirement: &70342142015800 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70342142015800
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: mocha
|
126
|
-
requirement: &
|
126
|
+
requirement: &70342142015380 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *70342142015380
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: simplecov
|
137
|
-
requirement: &
|
137
|
+
requirement: &70342142031320 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: '0'
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *70342142031320
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: rake
|
148
|
-
requirement: &
|
148
|
+
requirement: &70342142030900 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,7 +153,7 @@ dependencies:
|
|
153
153
|
version: '0'
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *70342142030900
|
157
157
|
description: A nice little gem that integrates Redmine, Todo.txt and Pomodoro.app
|
158
158
|
email:
|
159
159
|
- stefano.verna@welaika.com
|
@@ -201,11 +201,13 @@ files:
|
|
201
201
|
- spec/fixtures/close_results.txt
|
202
202
|
- spec/fixtures/config.yml
|
203
203
|
- spec/fixtures/printer_output.txt
|
204
|
+
- spec/fixtures/proper_timelog.csv
|
204
205
|
- spec/fixtures/pull_results.txt
|
205
206
|
- spec/fixtures/tasks.txt
|
206
207
|
- spec/fixtures/timelog.csv
|
207
208
|
- spec/integration/init_spec.rb
|
208
209
|
- spec/lib/redpomo/cli_spec.rb
|
210
|
+
- spec/lib/redpomo/entry_spec.rb
|
209
211
|
- spec/lib/redpomo/fuzzy_converter_spec.rb
|
210
212
|
- spec/lib/redpomo/task_spec.rb
|
211
213
|
- spec/lib/redpomo/tracker_spec.rb
|
@@ -252,11 +254,13 @@ test_files:
|
|
252
254
|
- spec/fixtures/close_results.txt
|
253
255
|
- spec/fixtures/config.yml
|
254
256
|
- spec/fixtures/printer_output.txt
|
257
|
+
- spec/fixtures/proper_timelog.csv
|
255
258
|
- spec/fixtures/pull_results.txt
|
256
259
|
- spec/fixtures/tasks.txt
|
257
260
|
- spec/fixtures/timelog.csv
|
258
261
|
- spec/integration/init_spec.rb
|
259
262
|
- spec/lib/redpomo/cli_spec.rb
|
263
|
+
- spec/lib/redpomo/entry_spec.rb
|
260
264
|
- spec/lib/redpomo/fuzzy_converter_spec.rb
|
261
265
|
- spec/lib/redpomo/task_spec.rb
|
262
266
|
- spec/lib/redpomo/tracker_spec.rb
|