Permalink
Browse files

fix config bug

  • Loading branch information...
1 parent b64e459 commit cb7e9347698b6401b678469864e823eeee921020 @txus committed Aug 28, 2011
View
Deleted file not rendered
View
Deleted file not rendered
View
@@ -2,9 +2,12 @@ module Domodoro
class Channel < EM::Channel
def broadcast(hour, min)
if ENV['DEBUG']
+ puts 'debug mode'
if min % 2 == 0
+ puts "#{Time.now} - Starting pomodoro!"
self << :start
else
+ puts "#{Time.now} - Pomodoro break!"
self << :stop
end
return
@@ -19,17 +22,21 @@ def broadcast(hour, min)
def morning(min)
case min
when 0, 30
+ puts "#{Time.now} - Starting pomodoro!"
self << :start
when 25, 55
+ puts "#{Time.now} - Pomodoro break!"
self << :stop
end
end
def afternoon(min)
case min
when 20, 50
+ puts "#{Time.now} - Starting pomodoro!"
self << :start
when 45, 15
+ puts "#{Time.now} - Pomodoro break!"
self << :stop
end
end
View
@@ -13,8 +13,10 @@ def start(host, port)
def c.receive_line(line)
case line
when /start/
+ puts "#{Time.now} - Starting pomodoro!"
Client.work
when /stop/
+ puts "#{Time.now} - Pomdoro break!"
Client.break
end
end
View
@@ -11,6 +11,9 @@ def load
self.visual = file['visual']
self.sound = file['sound']
+ else
+ self.visual = true
+ self.sound = true
end
end
end
View
@@ -3,7 +3,8 @@ class Server < EM::Connection
attr_reader :channel, :sid
class << self
- def start(host, port)
+ def start(host='127.0.0.1', port='9111')
+ puts "#{Time.now} - Domodoro serving at #{host}:#{port}"
EM.run do
channel = Channel.new
@@ -2,16 +2,29 @@
module Domodoro
describe Config do
- it 'loads the config from a ~/.domodororc file' do
- File.stubs(:exist?).returns true
- File.stubs(:read).returns """
-visual: true
-sound: false
- """
- Domodoro::Config.load
+ describe 'if ~/.domodororc exists' do
+ it 'loads the config from a ~/.domodororc file' do
+ File.stubs(:exist?).returns true
+ File.stubs(:read).returns """
+ visual: true
+ sound: false
+ """
+ Domodoro::Config.load
- assert_equal true, Domodoro::Config.visual
- assert_equal false, Domodoro::Config.sound
+ assert_equal true, Domodoro::Config.visual
+ assert_equal false, Domodoro::Config.sound
+ end
+ end
+
+ describe 'otherwise' do
+ it 'sets both options to true' do
+ File.stubs(:exist?).returns false
+
+ Domodoro::Config.load
+
+ assert_equal true, Domodoro::Config.visual
+ assert_equal true, Domodoro::Config.sound
+ end
end
end
end

0 comments on commit cb7e934

Please sign in to comment.