Skip to content

Instantly share code, notes, and snippets.

@makefunstuff
Last active August 29, 2015 14:01
Show Gist options
  • Save makefunstuff/6cd5b280b4290d948ecb to your computer and use it in GitHub Desktop.
Save makefunstuff/6cd5b280b4290d948ecb to your computer and use it in GitHub Desktop.
naive example of using celluloid
require 'celluloid'
require 'open-uri'
require 'digest/sha1'
URL_LIST = %w{http://yandex.ru http://bing.com}
class UrlChecksumGen
include Celluloid
attr_reader :digest
def initialize(dest)
@dest = dest
end
def gen_digest
data = open(@dest).read
@digest = Digest::SHA1.hexdigest data
end
def output(future)
puts future.value
end
end
URL_LIST.each do |url|
sha = UrlChecksumGen.new(url)
future = sha.future :gen_digest
sha.output future
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment