Last active
August 29, 2015 14:01
-
-
Save makefunstuff/6cd5b280b4290d948ecb to your computer and use it in GitHub Desktop.
naive example of using celluloid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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