Skip to content

Commit

Permalink
system : set
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Mar 9, 2011
1 parent 7100725 commit 33f2e93
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
14 changes: 9 additions & 5 deletions lib/register/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ def self.put_system(redis)
'_id' => 'system',
'_rev' => '0',

'put' => proc { |args|
item = args
#lock(item['_id']) do
# TODO
#end
'set' => proc { |args|
@redis.set(args['key'], Rufus::Json.encode(args['value']))
}.to_source,

#'put' => proc { |args|
# item = args
# lock(item['_id']) do
# # TODO
# end
#}.to_source,

'echo' => proc { |args|
args.collect { |a| a.to_s }.join(' ')
}.to_source
Expand Down
2 changes: 1 addition & 1 deletion lib/register/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def run
@running = true

loop do
break if @running = false
break if @running == false
step
end
end
Expand Down
13 changes: 13 additions & 0 deletions spec/system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,18 @@
cl.result(ticket).should == [ true, 'hello world' ]
end
end

describe "'set'" do

it 'sets a value' do

ticket = cl.call('system', 'set', 'key' => 'x', 'value' => %w[ y z ])

wo.send(:step)

cl.result(ticket).should == [ true, 'OK' ]
@r.get('x').should == Rufus::Json.encode(%w[ y z ])
end
end
end

13 changes: 5 additions & 8 deletions spec/worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@

describe '#step' do

it 'returns after 1 second when there are no calls' do

t = Time.now

wo.send(:step)

(Time.now - t).should > 1.0
end
#it 'returns after 1 second when there are no calls' do
# t = Time.now
# wo.send(:step)
# (Time.now - t).should > 1.0
#end

it 'process calls' do

Expand Down

0 comments on commit 33f2e93

Please sign in to comment.