Skip to content

Commit

Permalink
removed messagepack dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
vikhyat committed Jul 18, 2012
1 parent 4e538d6 commit bd250ab
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
1 change: 0 additions & 1 deletion Gemfile
@@ -1,5 +1,4 @@
source :rubygems

gem 'rspec'
gem 'msgpack'
gem 'sinatra'
20 changes: 20 additions & 0 deletions example/web_scraper.rb
@@ -0,0 +1,20 @@
require_relative '../lib/stormy-cloud'
require 'net/http'

StormyCloud.new("web_scraper", "localhost") do |c|
c.split { (2..5).to_a }

c.map do |roll_number|
uri = URI('http://results.herokuapp.com/result')
res = Net::HTTP.post_form(uri, 'rno' => roll_number.to_s)
res.body.split('</strong>')[0..1].map {|x| x.split('<strong>')[1] } * ' '
end

c.reduce do |roll_number, result|
puts "#{roll_number} #{result}"
end

c.finally do
"done"
end
end
7 changes: 3 additions & 4 deletions lib/transport.rb
@@ -1,4 +1,3 @@
require 'base64'
require 'digest'
require 'msgpack'
require 'securerandom'
Expand Down Expand Up @@ -148,7 +147,7 @@ def complete?
def handle(string)
valid_commands = ["HELLO", "GET", "PUT"]
command = unserialize(string)

if not (command.kind_of?(Array) and valid_commands.include? command[0])
# The command is invalid.
return serialize("INVALID COMMAND")
Expand Down Expand Up @@ -214,13 +213,13 @@ def raw_send_message(string)
# This can be overridden by the specific transport if the protocol used is
# such that this mode of serialization is disadvantageous.
def serialize(object)
Base64::encode64(object.to_msgpack)
Marshal.dump(object)
end

# Unserialize an object which has been serialized using the `serialize`
# method.
def unserialize(string)
MessagePack.unpack(Base64::decode64(string))
Marshal.load(string)
end

# Return all variables relevant to the job status.
Expand Down

0 comments on commit bd250ab

Please sign in to comment.