I want use whenever and every 5 min (ex)0,5,10,15,20 ... 55) json parse site and input my database..
and instantly processing script...
config/schedule.rb
every '0,5,10,15,20,25,30,35,40,45,50,55 * * * *' do
rake "do_something"
end
Rakefile
task :do_something do
<%a = JSON.parse( open("http://named.com/page/ladder/ajax/result.php").read )%>
<% b=a['times'] %>
<% c=a['start_point'] %>
<% if c == 'first' %>
<% c='left' %>
<% else %>
<% c= 'right' %>
<% end %>
<% d=a['ladder_type'] %>
<% if d == 'type1' %>
<% d='3' %>
<% else %>
<% d= '4' %>
<% end %>
<% e=a['answer'] %>
<% if e == 'EVEN' %>
<% e='2' %>
<% else %>
<% e= '1' %>
<% end %>
=begin
I want input this result in db.
=end
end
and this is schedule script.
a.rb
class Ladder
include DataMapper::Resource
property :id, Serial
property :ladder_type, String
property :start_point, String
property :times, String
end
class User
include DataMapper::Resource
property :id, Serial
property :email, String
property :password, String
property :ladder_type, String
property :start_point, String
property :times, String
end
i want input database..
ex) whenever parse and input my database and instantly processing this script.
if u.times == l.times
puts "good"
else
puts "lose"
end