redpomo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,101 @@
1
+ require 'spec_helper'
2
+ require 'tempfile'
3
+ require 'launchy'
4
+ require 'applescript'
5
+ require 'redpomo/cli'
6
+
7
+ describe Redpomo::CLI do
8
+
9
+ let(:todo_tasks) do
10
+ [
11
+ "Make screenshot #838 @cantiere",
12
+ "Fix #3290 @welaika",
13
+ "Another task @home"
14
+ ]
15
+ end
16
+
17
+ let(:todo_file) do
18
+ Tempfile.new('todo')
19
+ end
20
+
21
+ let(:config) do
22
+ {
23
+ "todo" => todo_file.path,
24
+ "cache" => false,
25
+ "trackers" => {
26
+ "cantiere" => {
27
+ "url" => "https://project.cantierecreativo.net",
28
+ "token" => "CANTIERE_TOKEN",
29
+ "default_project" => "cc",
30
+ "closed_status" => 5
31
+ },
32
+ "welaika" => {
33
+ "url" => "http://code.welaika.com",
34
+ "token" => "WELAIKA_TOKEN",
35
+ "default_project" => "welaika",
36
+ "closed_status" => 5
37
+ }
38
+ }
39
+ }
40
+ end
41
+
42
+ let(:config_file) do
43
+ Tempfile.new('config')
44
+ end
45
+
46
+ before(:each) do
47
+ todo_file.write(todo_tasks.join("\n"))
48
+ todo_file.close
49
+ config_file.write(config.to_yaml)
50
+ config_file.close
51
+ end
52
+
53
+ after(:each) do
54
+ todo_file.unlink
55
+ config_file.unlink
56
+ end
57
+
58
+ describe "push LOG" do
59
+ it "pushes the specified timelog to remote trackers" do
60
+ VCR.use_cassette('cli_push') do
61
+ output = capture(:stdout) do
62
+ Redpomo::CLI.start("push spec/fixtures/timelog.csv --config #{config_file.path}".split)
63
+ end
64
+ output.should == File.read("spec/fixtures/printer_output.txt")
65
+ end
66
+ end
67
+ end
68
+
69
+ describe "start ISSUE" do
70
+ it "starts the specified issue on Pomodoro.app" do
71
+ AppleScript.expects(:execute).with('tell application "Pomodoro" to start "Make screenshot #838 @cantiere"')
72
+ Redpomo::CLI.start("start 1 --config #{config_file.path}".split)
73
+ end
74
+ end
75
+
76
+ describe "open ISSUE" do
77
+ it "shows the specified issue on the browser" do
78
+ Launchy.expects(:open).with('https://project.cantierecreativo.net/issues/838')
79
+ Redpomo::CLI.start("open 1 --config #{config_file.path}".split)
80
+ end
81
+ end
82
+
83
+ describe "close ISSUE" do
84
+ it "closes issue on remote tracker and marks current task as done" do
85
+ VCR.use_cassette('cli_close') do
86
+ Redpomo::CLI.start("close 1 --config #{config_file.path}".split)
87
+ File.read(todo_file.path).should == File.read("spec/fixtures/close_results.txt")
88
+ end
89
+ end
90
+ end
91
+
92
+ describe "pull" do
93
+ it "fetches all the trackers and converts the issues in todo tasks" do
94
+ VCR.use_cassette('cli_pull') do
95
+ Redpomo::CLI.start("pull --config #{config_file.path}".split)
96
+ File.read(todo_file.path).should == File.read("spec/fixtures/pull_results.txt")
97
+ end
98
+ end
99
+ end
100
+
101
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+ require 'redpomo/fuzzy_converter'
3
+
4
+ describe Redpomo::FuzzyConverter do
5
+
6
+ let(:converted_entries) do
7
+ Redpomo::FuzzyConverter.convert(entries)
8
+ end
9
+
10
+ describe "#convert" do
11
+
12
+ context "if there's up to 1.5h of untracked time between entries" do
13
+ let(:entries) do
14
+ [
15
+ Redpomo::Entry.new("foo", DateTime.parse('5th feb 2012 09:00:00'), 25.minutes),
16
+ Redpomo::Entry.new("bar", DateTime.parse('5th feb 2012 10:00:00'), 25.minutes),
17
+ ]
18
+ end
19
+ it "fills up time between entries" do
20
+ converted_entries.first.duration.should == 1.hour
21
+ end
22
+ end
23
+
24
+ context "if there's more than 1.5h of untracked time between entries" do
25
+ let(:entries) do
26
+ [
27
+ Redpomo::Entry.new("foo", DateTime.parse('5th feb 2012 09:00:00'), 25.minutes),
28
+ Redpomo::Entry.new("bar", DateTime.parse('5th feb 2012 12:00:00'), 25.minutes),
29
+ ]
30
+ end
31
+ it "it adds 1.5 hours between entries" do
32
+ converted_entries.first.duration.should == (25.minutes + 1.5.hour)
33
+ end
34
+ end
35
+
36
+ context "on multiple consecutive entries with the same task" do
37
+ context "in the same day" do
38
+ let(:entries) do
39
+ [
40
+ Redpomo::Entry.new("foo", DateTime.parse('5th feb 2012 09:00:00'), 25.minutes),
41
+ Redpomo::Entry.new("foo", DateTime.parse('5th feb 2012 09:30:00'), 25.minutes),
42
+ Redpomo::Entry.new("bar", DateTime.parse('5th feb 2012 12:00:00'), 25.minutes),
43
+ ]
44
+ end
45
+ it "it joins them" do
46
+ converted_entries.first.duration.should == (30.minutes + 25.minutes + 1.5.hour)
47
+ end
48
+ end
49
+ context "on different days" do
50
+ let(:entries) do
51
+ [
52
+ Redpomo::Entry.new("foo", DateTime.parse('5th feb 2012 09:00:00'), 25.minutes),
53
+ Redpomo::Entry.new("foo", DateTime.parse('6th feb 2012 09:30:00'), 25.minutes),
54
+ ]
55
+ end
56
+ it "it keeps them separated" do
57
+ converted_entries.should have(2).entries
58
+ converted_entries.first.duration.should == 25.minutes
59
+ converted_entries.last.duration.should == 25.minutes
60
+ end
61
+ end
62
+ end
63
+
64
+ end
65
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+ require 'redpomo/task'
3
+
4
+ describe Redpomo::Task do
5
+
6
+ describe ".orig" do
7
+ it "returns the original line" do
8
+ Redpomo::Task.new(stub, "Foo bar #123 +one @two").orig.should == "Foo bar #123 +one @two"
9
+ end
10
+ end
11
+
12
+ describe ".url" do
13
+ context "if there's an issue" do
14
+ it "returns the URL to the issue" do
15
+ tracker = stub(base_url: "http://foo.bar")
16
+ task = Redpomo::Task.new(stub, "Foo #123 +project @tracker")
17
+ task.stubs(:tracker).returns(tracker)
18
+ task.url.should == "http://foo.bar/issues/123"
19
+ end
20
+ end
21
+ context "if there's a project" do
22
+ it "returns the URL to the project" do
23
+ tracker = stub(base_url: "http://foo.bar")
24
+ task = Redpomo::Task.new(stub, "Foo +project @tracker")
25
+ task.stubs(:tracker).returns(tracker)
26
+ task.url.should == "http://foo.bar/projects/project"
27
+ end
28
+ end
29
+ context "else" do
30
+ it "returns the URL to the tracker default project" do
31
+ tracker = stub(base_url: "http://foo.bar", default_project: 'bar')
32
+ task = Redpomo::Task.new(stub, "Foo @tracker")
33
+ task.stubs(:tracker).returns(tracker)
34
+ task.url.should == "http://foo.bar/projects/bar"
35
+ end
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+ require 'redpomo/tracker'
3
+
4
+ describe Redpomo::Tracker do
5
+
6
+ subject do
7
+ Redpomo::Tracker.new(
8
+ "welaika",
9
+ url: "http://code.welaika.com",
10
+ token: "WELAIKA_TOKEN",
11
+ closed_status: "5"
12
+ )
13
+ end
14
+
15
+ describe ".close_issue!" do
16
+ it "closes the issue with the specified message" do
17
+ VCR.use_cassette('close_issue') do
18
+ lambda {
19
+ subject.close_issue!("3290", "foobar")
20
+ }.should_not raise_error
21
+ end
22
+ end
23
+ end
24
+
25
+ describe ".issues" do
26
+ it "creates an Issue for each remote issue" do
27
+ VCR.use_cassette('issues') do
28
+ issues = subject.issues
29
+ issues.should have(7).issues
30
+ issues.first.tracker.should == subject
31
+ issues.first.project.should == 'dashboard-fiat'
32
+ issues.first.issue_id.should == 3316
33
+ issues.first.due_date.should be_nil
34
+ end
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ if ENV['SIMPLECOV']
5
+ require 'simplecov'
6
+ SimpleCov.start
7
+ end
8
+
9
+ Bundler.require(:default, :development)
10
+
11
+ RSpec.configure do |config|
12
+ config.mock_framework = :mocha
13
+ end
14
+
15
+ VCR.configure do |c|
16
+ c.cassette_library_dir = 'spec/fixtures/cassettes'
17
+ c.hook_into :webmock
18
+ c.default_cassette_options = {
19
+ match_requests_on: [:method, :host, :path, :body]
20
+ }
21
+ end
22
+
23
+ require 'support/capture'
@@ -0,0 +1,13 @@
1
+ require 'stringio'
2
+
3
+ def capture(*streams)
4
+ streams.map! { |stream| stream.to_s }
5
+ begin
6
+ result = StringIO.new
7
+ streams.each { |stream| eval "$#{stream} = result" }
8
+ yield
9
+ ensure
10
+ streams.each { |stream| eval("$#{stream} = #{stream.upcase}") }
11
+ end
12
+ result.string
13
+ end
metadata ADDED
@@ -0,0 +1,235 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redpomo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Stefano Verna
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: &70308384383300 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70308384383300
25
+ - !ruby/object:Gem::Dependency
26
+ name: thor
27
+ requirement: &70308384398840 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70308384398840
36
+ - !ruby/object:Gem::Dependency
37
+ name: todo-txt
38
+ requirement: &70308384398120 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70308384398120
47
+ - !ruby/object:Gem::Dependency
48
+ name: rest-client
49
+ requirement: &70308384397520 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70308384397520
58
+ - !ruby/object:Gem::Dependency
59
+ name: launchy
60
+ requirement: &70308384396940 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *70308384396940
69
+ - !ruby/object:Gem::Dependency
70
+ name: applescript
71
+ requirement: &70308384396040 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: *70308384396040
80
+ - !ruby/object:Gem::Dependency
81
+ name: terminal-table
82
+ requirement: &70308384393820 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: *70308384393820
91
+ - !ruby/object:Gem::Dependency
92
+ name: rspec
93
+ requirement: &70308384391400 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70308384391400
102
+ - !ruby/object:Gem::Dependency
103
+ name: vcr
104
+ requirement: &70308384406620 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *70308384406620
113
+ - !ruby/object:Gem::Dependency
114
+ name: webmock
115
+ requirement: &70308384404240 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *70308384404240
124
+ - !ruby/object:Gem::Dependency
125
+ name: mocha
126
+ requirement: &70308384402280 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: *70308384402280
135
+ - !ruby/object:Gem::Dependency
136
+ name: simplecov
137
+ requirement: &70308384401020 !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: *70308384401020
146
+ description: A nice little gem that integrates Redmine, Todo.txt and Pomodoro.app
147
+ email:
148
+ - stefano.verna@welaika.com
149
+ executables:
150
+ - redpomo
151
+ extensions: []
152
+ extra_rdoc_files: []
153
+ files:
154
+ - .gitignore
155
+ - .rspec
156
+ - Gemfile
157
+ - LICENSE
158
+ - README.md
159
+ - Rakefile
160
+ - bin/redpomo
161
+ - lib/redpomo.rb
162
+ - lib/redpomo/cli.rb
163
+ - lib/redpomo/config.rb
164
+ - lib/redpomo/entries_printer.rb
165
+ - lib/redpomo/entry.rb
166
+ - lib/redpomo/file_cache.rb
167
+ - lib/redpomo/fuzzy_converter.rb
168
+ - lib/redpomo/issue.rb
169
+ - lib/redpomo/null_cache.rb
170
+ - lib/redpomo/numeric_ext.rb
171
+ - lib/redpomo/puller.rb
172
+ - lib/redpomo/pusher.rb
173
+ - lib/redpomo/task.rb
174
+ - lib/redpomo/task_list.rb
175
+ - lib/redpomo/tracker.rb
176
+ - lib/redpomo/version.rb
177
+ - redpomo.gemspec
178
+ - spec/file_cache_spec.rb
179
+ - spec/fixtures/cassettes/cli_close.yml
180
+ - spec/fixtures/cassettes/cli_pull.yml
181
+ - spec/fixtures/cassettes/cli_push.yml
182
+ - spec/fixtures/cassettes/close_issue.yml
183
+ - spec/fixtures/cassettes/issues.yml
184
+ - spec/fixtures/close_results.txt
185
+ - spec/fixtures/printer_output.txt
186
+ - spec/fixtures/pull_results.txt
187
+ - spec/fixtures/timelog.csv
188
+ - spec/lib/redpomo/cli_spec.rb
189
+ - spec/lib/redpomo/fuzzy_converter_spec.rb
190
+ - spec/lib/redpomo/task_spec.rb
191
+ - spec/lib/redpomo/tracker_spec.rb
192
+ - spec/spec_helper.rb
193
+ - spec/support/capture.rb
194
+ homepage: ''
195
+ licenses: []
196
+ post_install_message:
197
+ rdoc_options: []
198
+ require_paths:
199
+ - lib
200
+ required_ruby_version: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ required_rubygems_version: !ruby/object:Gem::Requirement
207
+ none: false
208
+ requirements:
209
+ - - ! '>='
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ requirements: []
213
+ rubyforge_project:
214
+ rubygems_version: 1.8.11
215
+ signing_key:
216
+ specification_version: 3
217
+ summary: A nice little gem that integrates Redmine, Todo.txt and Pomodoro.app
218
+ test_files:
219
+ - spec/file_cache_spec.rb
220
+ - spec/fixtures/cassettes/cli_close.yml
221
+ - spec/fixtures/cassettes/cli_pull.yml
222
+ - spec/fixtures/cassettes/cli_push.yml
223
+ - spec/fixtures/cassettes/close_issue.yml
224
+ - spec/fixtures/cassettes/issues.yml
225
+ - spec/fixtures/close_results.txt
226
+ - spec/fixtures/printer_output.txt
227
+ - spec/fixtures/pull_results.txt
228
+ - spec/fixtures/timelog.csv
229
+ - spec/lib/redpomo/cli_spec.rb
230
+ - spec/lib/redpomo/fuzzy_converter_spec.rb
231
+ - spec/lib/redpomo/task_spec.rb
232
+ - spec/lib/redpomo/tracker_spec.rb
233
+ - spec/spec_helper.rb
234
+ - spec/support/capture.rb
235
+ has_rdoc: