Sha256: 8484e772960ff2966e0c5605bad435d2333851e29528cb89dbd58c97aaf99ca3
Contents?: true
Size: 667 Bytes
Versions: 5
Compression:
Stored size: 667 Bytes
Contents
require 'readonce/version' require 'httparty' class ReadOnce BASE_URI = 'https://readonce-production.herokuapp.com' def self.from_key(key) r = ReadOnce.new r.instance_variable_set(:@key, key) r end def self.from_data(data) response = HTTParty.post "#{BASE_URI}/create", body: data r = ReadOnce.new r.instance_variable_set(:@key, response.body) r end def read_url "#{BASE_URI}/#{key}" end def exists? response = HTTParty.get "#{BASE_URI}/status/#{key}" response.code == 200 ? true : false end def block_while_exists while exists? do sleep 1 end end private attr_accessor :key end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
readonce-1.0.5 | lib/readonce.rb |
readonce-1.0.4 | lib/readonce.rb |
readonce-1.0.3 | lib/readonce.rb |
readonce-1.0.2 | lib/readonce.rb |
readonce-1.0.1 | lib/readonce.rb |