pomo 2.0.2 → 2.1.0

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.
@@ -1,9 +1,13 @@
1
+ require 'pomo/notifier/growl_notifier'
2
+ require 'pomo/notifier/libnotify_notifier'
3
+ require 'pomo/notifier/notification_center_notifier'
1
4
 
2
5
  module Pomo
3
6
  class Notifier
4
7
 
5
8
  ##
6
9
  # Initialize notifier library from configuration.
10
+
7
11
  def initialize(config)
8
12
  if config.notifier == 'notification_center'
9
13
  @notifier = Pomo::Notifier::NotificationCenterNotifier.new
@@ -18,6 +22,7 @@ module Pomo
18
22
 
19
23
  ##
20
24
  # Send message to notification library.
25
+
21
26
  def notify(message, opts = {})
22
27
  @notifier.notify(message, opts)
23
28
  end
@@ -1,3 +1,4 @@
1
+ require 'growl' if Pomo::OS.mac? || Pomo::OS.windows?
1
2
 
2
3
  module Pomo
3
4
  class Notifier
@@ -1,3 +1,4 @@
1
+ require 'libnotify' if Pomo::OS.linux?
1
2
 
2
3
  module Pomo
3
4
  class Notifier
@@ -1,3 +1,4 @@
1
+ require 'terminal-notifier' if Pomo::OS.mac?
1
2
 
2
3
  module Pomo
3
4
  class Notifier
@@ -1,3 +1,5 @@
1
+ require 'rbconfig'
2
+
1
3
  module Pomo
2
4
  module OS
3
5
  module_function
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
 
2
3
  module Pomo
3
4
  class Task
@@ -30,7 +31,7 @@ module Pomo
30
31
  ##
31
32
  # Initialize with _name_ and _options_.
32
33
 
33
- def initialize name = nil, options = {}
34
+ def initialize(name = nil, options = {})
34
35
  @name = name or raise '<task> required'
35
36
  @description = options.delete :description
36
37
  @length = options.fetch :length, 25
@@ -42,7 +43,7 @@ module Pomo
42
43
  # Quoted task name.
43
44
 
44
45
  def to_s
45
- name.inspect
46
+ name
46
47
  end
47
48
 
48
49
  ##
@@ -59,8 +60,19 @@ module Pomo
59
60
  complete
60
61
  end
61
62
 
63
+ ##
64
+ # Output verbose task information
65
+
66
+ def verbose_output(format)
67
+ say format % ['name', self]
68
+ say format % ['length', "#{length} minutes"]
69
+ say format % ['description', description] if description and not description.empty?
70
+ say format % ['complete', complete ? '[✓]' : '[ ]']
71
+ end
72
+
62
73
  ##
63
74
  # Start timing the task.
75
+
64
76
  def start(config, options = {})
65
77
  list = options[:list]
66
78
  progress = options[:progress]
@@ -95,7 +107,7 @@ module Pomo
95
107
  elsif remaining == 5
96
108
  notifier.notify 'Almost there!', :header => '5 minutes remaining'
97
109
  end
98
- sleep 60
110
+ sleep 60 unless ENV['POMO_ENV']=='test'
99
111
  { :remaining => remaining }
100
112
  end
101
113
 
@@ -123,7 +135,7 @@ module Pomo
123
135
  elsif remaining == 5
124
136
  notifier.notify 'Almost there!', :header => '5 minutes remaining'
125
137
  end
126
- sleep 60
138
+ sleep 60 unless ENV['POMO_ENV']=='test'
127
139
  end
128
140
 
129
141
  write_tmux_time(0) if config.tmux
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Pomo
3
- VERSION = '2.0.2'
3
+ VERSION = '2.1.0'
4
4
  end
@@ -1,6 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pomo/os'
4
5
  require 'pomo/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
@@ -22,9 +23,12 @@ Gem::Specification.new do |spec|
22
23
 
23
24
  spec.add_dependency('commander', '~> 4.1')
24
25
  spec.add_dependency('octokit', '~> 1.19')
25
- spec.add_dependency('terminal-notifier', '~> 1.4') if /darwin/ =~ RUBY_PLATFORM
26
- spec.add_dependency('growl', '~> 1.0') if /darwin/ =~ RUBY_PLATFORM
27
- spec.add_dependency('libnotify', '~> 0.8') if /linux/ =~ RUBY_PLATFORM
26
+ spec.add_dependency('terminal-notifier', '~> 1.4') if Pomo::OS.mac?
27
+ spec.add_dependency('growl', '~> 1.0') if Pomo::OS.mac? || Pomo::OS.windows?
28
+ spec.add_dependency('libnotify', '~> 0.8') if Pomo::OS.linux?
28
29
 
30
+ spec.add_development_dependency('aruba', '~> 0.5.1')
29
31
  spec.add_development_dependency('rspec', '~> 2.12')
32
+ spec.add_development_dependency('fakefs', '~> 0.4')
33
+ spec.add_development_dependency('yard')
30
34
  end
@@ -0,0 +1,108 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pomo::Configuration do
4
+
5
+ describe '#initialize' do
6
+ it 'instantiates object' do
7
+ options = {
8
+ :notifier => 'foo',
9
+ :progress => 'bar',
10
+ :tmux => 'baz'
11
+ }
12
+ config = Pomo::Configuration.new(options)
13
+ expect(config.notifier).to eq 'foo'
14
+ expect(config.progress).to eq 'bar'
15
+ expect(config.tmux).to eq 'baz'
16
+ end
17
+ end
18
+
19
+ describe '.load' do
20
+ context 'not given a configuration file' do
21
+ it 'returns Configuration object with default options' do
22
+ config = Pomo::Configuration.load
23
+ expect(config.notifier).to eq Pomo::Configuration.default_notifier
24
+ expect(config.progress).to be false
25
+ expect(config.tmux).to be false
26
+ end
27
+
28
+ it 'writes a configuration file with default options' do
29
+ Pomo::Configuration.load
30
+ expect(File.read(Pomo::Configuration.config_file)).to eq \
31
+ YAML::dump(Pomo::Configuration.default_options)
32
+ end
33
+ end
34
+
35
+ context 'given a configuration file' do
36
+ before(:each) do
37
+ opts = {
38
+ :notifier => 'foo',
39
+ :progress => 'bar',
40
+ :tmux => 'baz'
41
+ }
42
+ File.open(Pomo::Configuration.config_file, 'w') do |file|
43
+ YAML::dump(opts, file)
44
+ end
45
+ end
46
+
47
+ it 'returns Configuration object with options in file' do
48
+ config = Pomo::Configuration.load
49
+ expect(config.notifier).to eq 'foo'
50
+ expect(config.progress).to eq 'bar'
51
+ expect(config.tmux).to eq 'baz'
52
+ end
53
+
54
+ context 'given options' do
55
+ it 'overrides options in configuration file' do
56
+ options = {
57
+ :notifier => 'goo',
58
+ :progress => 'car',
59
+ :tmux => 'caz'
60
+ }
61
+ config = Pomo::Configuration.load(options)
62
+ expect(config.notifier).to eq 'goo'
63
+ expect(config.progress).to eq 'car'
64
+ expect(config.tmux).to eq 'caz'
65
+ end
66
+ end
67
+
68
+ end
69
+ end
70
+
71
+ describe '.save' do
72
+ let(:options) { {:notifier => 'foo', :progress => 'bar', :tmux => 'baz'} }
73
+
74
+ context 'not given a configuration file' do
75
+ it 'writes a configuration file with options' do
76
+ Pomo::Configuration.save(options)
77
+ expect(File.read(Pomo::Configuration.config_file)).to eq \
78
+ YAML::dump(options)
79
+ end
80
+ end
81
+
82
+ context 'given a configuration file' do
83
+ before(:each) do
84
+ opts = {
85
+ :notifier => 'goo',
86
+ :progress => 'car',
87
+ :tmux => 'caz'
88
+ }
89
+ File.open(Pomo::Configuration.config_file, 'w') do |file|
90
+ YAML::dump(opts, file)
91
+ end
92
+ end
93
+
94
+ it 'does not overwrite' do
95
+ Pomo::Configuration.save(options)
96
+ expect(File.read(Pomo::Configuration.config_file)).to_not eq \
97
+ YAML::dump(options)
98
+ end
99
+
100
+ it 'does overwrite if passed `force` option' do
101
+ Pomo::Configuration.save(options.merge(:force => true))
102
+ expect(File.read(Pomo::Configuration.config_file)).to eq \
103
+ YAML::dump(options)
104
+ end
105
+ end
106
+ end
107
+
108
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pomo::List do
4
+
5
+ let(:list) { Pomo::List.new }
6
+ let(:tasks) { [Pomo::Task.new('foo'), Pomo::Task.new('bar'), Pomo::Task.new('baz')] }
7
+
8
+ before(:each) do
9
+ list.tasks.concat(tasks)
10
+ end
11
+
12
+ describe '#find' do
13
+ context "given 'all'" do
14
+ it 'yields all tasks' do
15
+ expect { |b| list.find('all', 'first', 'last', &b) }.to yield_successive_args(tasks[0], tasks[1], tasks[2])
16
+ end
17
+ end
18
+
19
+ context "given 'first'" do
20
+ it 'yields the first task' do
21
+ expect { |b| list.find('first', &b) }.to yield_successive_args(tasks[0])
22
+ end
23
+ end
24
+
25
+ context "given 'last'" do
26
+ it 'yields the last task' do
27
+ expect { |b| list.find('last', &b) }.to yield_successive_args(tasks[2])
28
+ end
29
+ end
30
+
31
+ context "given 'complete'" do
32
+ it 'yields all completed tasks' do
33
+ list.tasks[0].complete = true
34
+ expect { |b| list.find('complete', &b) }.to yield_successive_args(tasks[0])
35
+ end
36
+ end
37
+
38
+ context "given 'incomplete'" do
39
+ it 'yields all incompleted tasks' do
40
+ list.tasks[0].complete = true
41
+ expect { |b| list.find('incomplete', &b) }.to yield_successive_args(tasks[1], tasks[2])
42
+ end
43
+ end
44
+
45
+ context "given a range e.g. '2..5'" do
46
+ it 'yields the given range of tasks' do
47
+ expect { |b| list.find('1..2', &b) }.to yield_successive_args(tasks[1], tasks[2])
48
+ end
49
+ end
50
+
51
+ context "given an index or multiple indexes e.g. '2 8 1'" do
52
+ it 'yields the tasks at the given index(es)' do
53
+ expect { |b| list.find('0', '2', &b) }.to yield_successive_args(tasks[0], tasks[2])
54
+ end
55
+ end
56
+
57
+ context 'given multiple arguments' do
58
+ it 'yields the tasks according to the above specs' do
59
+ expect { |b| list.find('first', 'last', &b) }.to yield_successive_args(tasks[0], tasks[2])
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pomo::Task do
4
+
5
+ let(:task) { Pomo::Task.new 'foo' }
6
+
7
+ describe '#start' do
8
+ it 'does nada'
9
+ end
10
+
11
+ describe '#stop' do
12
+ it 'does nada'
13
+ end
14
+
15
+ end
@@ -1,3 +1,41 @@
1
+ require 'pomo'
2
+ require 'fakefs/safe'
1
3
 
2
- $:.unshift File.dirname(__FILE__) + '/../lib'
3
- require 'pomo'
4
+ # Taken from Aruba::Api
5
+ class Pomo::RSpecHelper
6
+ def self.set_env(key, value)
7
+ $original_env ||= {}
8
+ $original_env[key] = ENV.delete(key)
9
+ ENV[key] = value
10
+ end
11
+
12
+ def self.restore_env
13
+ $original_env ||= {}
14
+ $original_env.each do |key, value|
15
+ ENV[key] = value
16
+ end
17
+ end
18
+ end
19
+
20
+ RSpec.configure do |config|
21
+ config.color = true
22
+ config.order = 'random'
23
+
24
+ config.before(:suite) do
25
+ Pomo::RSpecHelper.set_env('POMO_ENV', 'test')
26
+ end
27
+
28
+ config.before(:each) do
29
+ FakeFS.activate!
30
+ FileUtils.mkdir_p ENV['HOME']
31
+ end
32
+
33
+ config.after(:each) do
34
+ FakeFS.deactivate!
35
+ FakeFS::FileSystem.clear
36
+ end
37
+
38
+ config.after(:suite) do
39
+ Pomo::RSpecHelper.restore_env
40
+ end
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pomo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-18 00:00:00.000000000 Z
13
+ date: 2013-01-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: commander
@@ -76,6 +76,22 @@ dependencies:
76
76
  - - ~>
77
77
  - !ruby/object:Gem::Version
78
78
  version: '1.0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: aruba
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ~>
85
+ - !ruby/object:Gem::Version
86
+ version: 0.5.1
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: 0.5.1
79
95
  - !ruby/object:Gem::Dependency
80
96
  name: rspec
81
97
  requirement: !ruby/object:Gem::Requirement
@@ -92,6 +108,38 @@ dependencies:
92
108
  - - ~>
93
109
  - !ruby/object:Gem::Version
94
110
  version: '2.12'
111
+ - !ruby/object:Gem::Dependency
112
+ name: fakefs
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ~>
117
+ - !ruby/object:Gem::Version
118
+ version: '0.4'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ~>
125
+ - !ruby/object:Gem::Version
126
+ version: '0.4'
127
+ - !ruby/object:Gem::Dependency
128
+ name: yard
129
+ requirement: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ type: :development
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
95
143
  description: Pomodoro time management for the command-line
96
144
  email:
97
145
  - tj@vision-media.ca
@@ -102,14 +150,20 @@ extensions: []
102
150
  extra_rdoc_files: []
103
151
  files:
104
152
  - .gitignore
153
+ - .travis.yml
154
+ - CHANGELOG.md
105
155
  - CONTRIBUTING.md
106
156
  - DEVELOPMENT
107
157
  - Gemfile
108
- - HISTORY.md
109
- - LICENSE.txt
158
+ - LICENSE.md
110
159
  - README.md
111
160
  - Rakefile
112
161
  - bin/pomo
162
+ - features/configuration.feature
163
+ - features/manage_list.feature
164
+ - features/manage_tasks.feature
165
+ - features/step_definitions/pomo_steps.rb
166
+ - features/support/env.rb
113
167
  - lib/pomo.rb
114
168
  - lib/pomo/break.rb
115
169
  - lib/pomo/configuration.rb
@@ -124,7 +178,9 @@ files:
124
178
  - lib/pomo/task.rb
125
179
  - lib/pomo/version.rb
126
180
  - pomo.gemspec
127
- - spec/pomo_spec.rb
181
+ - spec/pomo/configuration_spec.rb
182
+ - spec/pomo/list_spec.rb
183
+ - spec/pomo/task_spec.rb
128
184
  - spec/spec_helper.rb
129
185
  homepage: https://github.com/visionmedia/pomo
130
186
  licenses: []
@@ -152,11 +208,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
208
  version: '0'
153
209
  requirements: []
154
210
  rubyforge_project: pomo
155
- rubygems_version: 1.8.24
211
+ rubygems_version: 1.8.23
156
212
  signing_key:
157
213
  specification_version: 3
158
- summary: pomo-2.0.2
214
+ summary: pomo-2.1.0
159
215
  test_files:
160
- - spec/pomo_spec.rb
216
+ - features/configuration.feature
217
+ - features/manage_list.feature
218
+ - features/manage_tasks.feature
219
+ - features/step_definitions/pomo_steps.rb
220
+ - features/support/env.rb
221
+ - spec/pomo/configuration_spec.rb
222
+ - spec/pomo/list_spec.rb
223
+ - spec/pomo/task_spec.rb
161
224
  - spec/spec_helper.rb
162
225
  has_rdoc: