Skip to content

Commit

Permalink
Repeat interval raised to 15 minutes.
Browse files Browse the repository at this point in the history
Fixed say it at new line submit button.
Will say new line when it is added.
  • Loading branch information
marano committed Feb 24, 2011
1 parent e2472b1 commit 46ec269
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
5 changes: 5 additions & 0 deletions editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

require 'erb'

require 'speaker'

include Speaker

set :app_file, __FILE__

get '/' do
Expand All @@ -16,6 +20,7 @@
end

post '/lines' do
say params[:body]
save_to_file([ params[:body] ] << lines_from_file)
redirect '/lines'
end
Expand Down
14 changes: 3 additions & 11 deletions papagaio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@

Bundler.require :scheduler

require 'os_functions'
require 'speaker'

include OsFunctions

def say line
if is_mac?
system "say \"#{line}\""
elsif is_linux?
system "espeak \"#{line}\""
end
end
include Speaker

scheduler = Rufus::Scheduler.start_new

scheduler.every '5m', :first_in => '1s' do
scheduler.every '15m', :first_in => '1s' do
lines = File.readlines 'lines.txt'
lines.empty? and return
say lines[rand(lines.size)]
Expand Down
16 changes: 16 additions & 0 deletions speaker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'os_functions'

include OsFunctions

module Speaker

def say line
if is_mac?
system "say \"#{line}\""
elsif is_linux?
system "espeak \"#{line}\""
end
end

end

2 changes: 1 addition & 1 deletion views/lines.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</head>
<body>
<form action'/lines' method='POST' >
<label>New line</label> <input type='text' name='body' style='width: 250px;' /> <input type='submit'>Say it!</input>
<label>New line</label> <input type='text' name='body' style='width: 250px;' /> <input type='submit' value='Say it!' />
</form>
<ul>
<% lines.each_with_index do |line, index| %>
Expand Down

0 comments on commit 46ec269

Please sign in to comment.