redpomo 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -15,14 +15,14 @@ Redpomo is the classic "scratch your own itch" project:
15
15
 
16
16
  › redpomo help
17
17
  Tasks:
18
- redpomo add # creates a new task on Todo.txt, forwarding it to the remote tracker
19
- redpomo close TASK # marks a todo.txt task as complete, and closes the related Redmine issue
20
- redpomo help [TASK] # Describe available tasks or one specific task
21
- redpomo init # generates a .redpomo configuration file on your home directory
22
- redpomo open TASK # opens up the Redmine issue page of the selected task
23
- redpomo pull # imports Redmine open issues into local todo.txt
24
- redpomo push LOGFILE # parses Pomodoro export file and imports to Redmine clients
25
- redpomo start TASK # starts a Pomodoro session for the selected task
18
+ redpomo init # generates a .redpomo configuration file on your home directory
19
+ redpomo pull # imports Redmine open issues into local todo.txt
20
+ redpomo push [LOGFILE] # parses Pomodoro export file and imports to Redmine clients
21
+ redpomo add [TASK] # creates a new task on Todo.txt, forwarding it to the remote tracker
22
+ redpomo close TASK # marks a todo.txt task as complete, and closes the related Redmine issue
23
+ redpomo open TASK # opens up the Redmine issue page of the selected task
24
+ redpomo start TASK # starts a Pomodoro session for the selected task
25
+ redpomo help [TASK] # Describe available tasks or one specific task
26
26
 
27
27
  Options:
28
28
  -c, [--config=CONFIG] # Default: ~/.redpomo
data/lib/redpomo/cli.rb CHANGED
@@ -6,7 +6,6 @@ require 'redpomo/task_list'
6
6
  require 'redpomo/entry'
7
7
  require 'redpomo/entries_printer'
8
8
  require 'redpomo/fuzzy_converter'
9
- # require 'redpomo/issue_generator'
10
9
 
11
10
  module Redpomo
12
11
  class CLI < ::Thor
@@ -27,7 +26,7 @@ module Redpomo
27
26
  map "c" => :close
28
27
  map "a" => :add
29
28
 
30
- desc "add", "creates a new task on Todo.txt, forwarding it to the remote tracker"
29
+ desc "add [TASK]", "creates a new task on Todo.txt, forwarding it to the remote tracker"
31
30
  method_option :description, aliases: "-d"
32
31
  def add(subject = nil)
33
32
  description = @options[:description]
@@ -35,17 +34,22 @@ module Redpomo
35
34
  if subject.blank?
36
35
  message_path = Tempfile.new('issue').path + ".textile"
37
36
  template "issue_stub.textile", message_path, verbose: false
38
- subject, description = parse_message edit(message_path)
37
+ subject, description = parse_message open_editor(message_path)
39
38
  end
40
39
 
41
40
  issue = Task.new(nil, subject).to_issue
42
41
  issue.description = description
43
- issue.create!
44
42
 
45
- task = issue.to_task
46
- task.add!
43
+ if issue.tracker.present?
44
+ issue.create!
45
+ task = issue.to_task
46
+ task.add!
47
47
 
48
- Redpomo.ui.info "Issue created, see it at #{task.url}"
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
49
53
  end
50
54
 
51
55
  desc "pull", "imports Redmine open issues into local todo.txt"
@@ -116,15 +120,7 @@ module Redpomo
116
120
  def init(path = '~/.redpomo')
117
121
  path = File.expand_path(path)
118
122
  template "config.yml", path, verbose: false
119
-
120
- editor = [ENV['REDPOMO_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? }
121
- if editor
122
- command = "#{editor} #{path}"
123
- system(command)
124
- File.read(path)
125
- else
126
- Redpomo.ui.info("To open the .redpomo config file, set $EDITOR or $REDPOMO_EDITOR")
127
- end
123
+ open_editor(path)
128
124
  end
129
125
 
130
126
  private
@@ -152,5 +148,17 @@ module Redpomo
152
148
  [subject.strip, description.strip]
153
149
  end
154
150
 
151
+ def open_editor(path)
152
+ editor = [ENV['REDPOMO_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? }
153
+ if editor
154
+ command = "#{editor} #{path}"
155
+ system(command)
156
+ File.read(path)
157
+ else
158
+ Redpomo.ui.error("To open #{path}, set $EDITOR or $REDPOMO_EDITOR")
159
+ exit 1
160
+ end
161
+ end
162
+
155
163
  end
156
164
  end
@@ -27,7 +27,11 @@ module Redpomo
27
27
  end
28
28
 
29
29
  def existing_keys
30
- File.exists?(cache_path) ? (YAML::load_file(cache_path) || {}) : {}
30
+ if File.exists?(cache_path)
31
+ YAML::load_file(cache_path) || {}
32
+ else
33
+ {}
34
+ end
31
35
  end
32
36
 
33
37
  def set(key, val)
data/lib/redpomo/task.rb CHANGED
@@ -93,7 +93,7 @@ module Redpomo
93
93
  issue.subject = text
94
94
  issue.project_id = project
95
95
  issue.due_date = date
96
- issue.priority_id = tracker.issue_priority_id(priority)
96
+ issue.priority_id = tracker.issue_priority_id(priority) if tracker.present?
97
97
  issue
98
98
  end
99
99
 
@@ -1,3 +1,3 @@
1
1
  module Redpomo
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -6,11 +6,16 @@ describe Redpomo::FileCache do
6
6
 
7
7
  describe "#get" do
8
8
  it "executes the block on cache miss" do
9
- Redpomo::FileCache.instance.cache_path = Tempfile.new('cache').path
9
+ old_cache_path = Redpomo::FileCache.instance.cache_path
10
+ Redpomo::FileCache.instance.cache_path = tmp_path("cache_file")
11
+
10
12
  counter = Redpomo::FileCache.get("foobar") { 5 }
11
13
  counter.should == 5
14
+
12
15
  counter = Redpomo::FileCache.get("foobar") { 10 }
13
16
  counter.should == 5
17
+
18
+ Redpomo::FileCache.instance.cache_path = old_cache_path
14
19
  end
15
20
  end
16
21
 
@@ -0,0 +1,29 @@
1
+ require 'tempfile'
2
+ require 'spec_helper'
3
+
4
+ describe "redpomo add" do
5
+
6
+ let(:config_path) { tmp_path('redpomo') }
7
+
8
+ it "opens up a template file with REDPOMO_EDITOR as highest priority" do
9
+ redpomo "add", :env => {"EDITOR" => "echo editor", "VISUAL" => "echo visual", "REDPOMO_EDITOR" => "echo redpomo_editor"}
10
+ out.should =~ /^redpomo_editor .*issue.*\.textile/
11
+ end
12
+
13
+ it "opens up a template file with VISUAL as 2nd highest priority" do
14
+ redpomo "add", :env => {"EDITOR" => "echo editor", "VISUAL" => "echo visual", "REDPOMO_EDITOR" => ""}
15
+ out.should =~ /^visual .*issue.*\.textile/
16
+ end
17
+
18
+ it "opens up a template file with EDITOR as 3rd highest priority" do
19
+ redpomo "add", :env => {"EDITOR" => "echo editor", "VISUAL" => "", "REDPOMO_EDITOR" => ""}
20
+ out.should =~ /^editor .*issue.*\.textile/
21
+ end
22
+
23
+ it "complains if no EDITOR is set" do
24
+ redpomo "add", :env => {"EDITOR" => "", "VISUAL" => "", "REDPOMO_EDITOR" => ""}
25
+ out.should include "set $EDITOR or $REDPOMO_EDITOR"
26
+ end
27
+
28
+ end
29
+
@@ -3,12 +3,7 @@ require 'spec_helper'
3
3
 
4
4
  describe "redpomo init" do
5
5
 
6
- let(:config_path) {
7
- new_config = Tempfile.new('redpomo')
8
- new_config_path = new_config.path
9
- new_config.unlink
10
- new_config_path
11
- }
6
+ let(:config_path) { tmp_path('redpomo') }
12
7
 
13
8
  it "generates a .redpomo config file" do
14
9
  redpomo "init #{config_path}", env: { "EDITOR" => "echo editor" }
@@ -32,7 +27,7 @@ describe "redpomo init" do
32
27
 
33
28
  it "complains if no EDITOR is set" do
34
29
  redpomo "init #{config_path}", :env => {"EDITOR" => "", "VISUAL" => "", "REDPOMO_EDITOR" => ""}
35
- out.should == "To open the .redpomo config file, set $EDITOR or $REDPOMO_EDITOR"
30
+ out.should include "set $EDITOR or $REDPOMO_EDITOR"
36
31
  end
37
32
 
38
- end
33
+ end
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'redpomo/entry'
2
3
 
3
4
  describe Redpomo::Entry do
4
5
 
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'bundler'
3
+ require 'active_support/core_ext/object'
3
4
 
4
5
  if ENV['SIMPLECOV']
5
6
  require 'simplecov'
@@ -1,6 +1,13 @@
1
1
  module Spec
2
2
  module Fixtures
3
3
 
4
+ def tmp_path(name)
5
+ file = Tempfile.new(name)
6
+ path = file.path
7
+ file.unlink
8
+ path
9
+ end
10
+
4
11
  def tmp(path)
5
12
  File.expand_path("../../tmp/#{path}", __FILE__)
6
13
  end
@@ -15,6 +15,6 @@ class IO
15
15
  end
16
16
  end
17
17
 
18
- return buffer.join
18
+ buffer.join
19
19
  end
20
20
  end
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.9
4
+ version: 0.0.10
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-06-04 00:00:00.000000000 Z
12
+ date: 2012-06-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70364147396960 !ruby/object:Gem::Requirement
16
+ requirement: &70127037894840 !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: *70364147396960
24
+ version_requirements: *70127037894840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &70364147396120 !ruby/object:Gem::Requirement
27
+ requirement: &70127037894420 !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: *70364147396120
35
+ version_requirements: *70127037894420
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: todo-txt
38
- requirement: &70364147395680 !ruby/object:Gem::Requirement
38
+ requirement: &70127037894000 !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: *70364147395680
46
+ version_requirements: *70127037894000
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rest-client
49
- requirement: &70364147395260 !ruby/object:Gem::Requirement
49
+ requirement: &70127037893580 !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: *70364147395260
57
+ version_requirements: *70127037893580
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: launchy
60
- requirement: &70364147394760 !ruby/object:Gem::Requirement
60
+ requirement: &70127037893160 !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: *70364147394760
68
+ version_requirements: *70127037893160
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: applescript
71
- requirement: &70364147394100 !ruby/object:Gem::Requirement
71
+ requirement: &70127037892740 !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: *70364147394100
79
+ version_requirements: *70127037892740
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: terminal-table
82
- requirement: &70364147409820 !ruby/object:Gem::Requirement
82
+ requirement: &70127037892320 !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: *70364147409820
90
+ version_requirements: *70127037892320
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rspec
93
- requirement: &70364147409200 !ruby/object:Gem::Requirement
93
+ requirement: &70127037891900 !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: *70364147409200
101
+ version_requirements: *70127037891900
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: vcr
104
- requirement: &70364147408560 !ruby/object:Gem::Requirement
104
+ requirement: &70127037891480 !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: *70364147408560
112
+ version_requirements: *70127037891480
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: webmock
115
- requirement: &70364147407920 !ruby/object:Gem::Requirement
115
+ requirement: &70127037891060 !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: *70364147407920
123
+ version_requirements: *70127037891060
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: mocha
126
- requirement: &70364147407300 !ruby/object:Gem::Requirement
126
+ requirement: &70127037890640 !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: *70364147407300
134
+ version_requirements: *70127037890640
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: simplecov
137
- requirement: &70364147406680 !ruby/object:Gem::Requirement
137
+ requirement: &70127037890220 !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: *70364147406680
145
+ version_requirements: *70127037890220
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: rake
148
- requirement: &70364147406020 !ruby/object:Gem::Requirement
148
+ requirement: &70127037889800 !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: *70364147406020
156
+ version_requirements: *70127037889800
157
157
  description: A nice little gem that integrates Redmine, Todo.txt and Pomodoro.app
158
158
  email:
159
159
  - stefano.verna@welaika.com
@@ -205,6 +205,7 @@ files:
205
205
  - spec/fixtures/pull_results.txt
206
206
  - spec/fixtures/tasks.txt
207
207
  - spec/fixtures/timelog.csv
208
+ - spec/integration/add_spec.rb
208
209
  - spec/integration/init_spec.rb
209
210
  - spec/lib/redpomo/cli_spec.rb
210
211
  - spec/lib/redpomo/entry_spec.rb
@@ -258,6 +259,7 @@ test_files:
258
259
  - spec/fixtures/pull_results.txt
259
260
  - spec/fixtures/tasks.txt
260
261
  - spec/fixtures/timelog.csv
262
+ - spec/integration/add_spec.rb
261
263
  - spec/integration/init_spec.rb
262
264
  - spec/lib/redpomo/cli_spec.rb
263
265
  - spec/lib/redpomo/entry_spec.rb