Class: Cloutree::Client
Instance Attribute Summary collapse
-
#app_key ⇒ Object
Returns the value of attribute app_key.
-
#app_secret ⇒ Object
Returns the value of attribute app_secret.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#app_key ⇒ Object
Returns the value of attribute app_key.
15 16 17 |
# File 'lib/cloutree.rb', line 15 def app_key @app_key end |
#app_secret ⇒ Object
Returns the value of attribute app_secret.
15 16 17 |
# File 'lib/cloutree.rb', line 15 def app_secret @app_secret end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
16 17 18 |
# File 'lib/cloutree.rb', line 16 def result @result end |
Class Method Details
.configure(hash) ⇒ Object
18 19 20 21 22 |
# File 'lib/cloutree.rb', line 18 def self.configure(hash) raise Cloutree::Error, "Specify :app_key" unless instance.app_key = hash[:app_key] raise Cloutree::Error, "Specify :app_secret" unless instance.app_secret = hash[:app_secret] instance end |
Instance Method Details
#upload(file) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cloutree.rb', line 40 def upload(file) filename = File.basename(file) time = Time.now.to_i string_to_sha = [app_key, time, filename, app_secret].join(":") checksum = Digest::SHA1.hexdigest(string_to_sha) c = Curl::Easy.new("https://cloutr.ee/upload") c.ssl_verify_peer = false c.headers["KEY"] = "#{app_key}" c.headers["CHECKSUM"] = "#{checksum}" c.headers["FILENAME"] = "#{filename}" c.headers["TIMESTAMP"] = "#{time}" c.http_post(File.read(file)) @result = JSON.parse(c.body_str) @result["success"] end |