Class: Squash::Uploader
- Inherits:
-
Object
- Object
- Squash::Uploader
- Defined in:
- lib/squash/uploader.rb
Overview
Class that handles communicating with the Squash API.
By default, transmission is done with ‘Net::HTTP`. If this is unpalatable to you, reimplement #http_post.
Constant Summary collapse
- DEFAULT_CONFIGURATION =
Default configuration options. See #initialize.
{ :open_timeout => 15, :read_timeout => 15, :skip_verification => false, :success => [Net::HTTPSuccess] }
Instance Attribute Summary collapse
-
#host ⇒ String
The host name and scheme of the Squash server (e.g., “squash.mycompany.com”).
-
#options ⇒ Hash<Symbol, Object>
Additional options for uploading.
Instance Method Summary collapse
-
#initialize(host, options = {}) ⇒ Uploader
constructor
Creates a new Squash uploader that will communicate with a given host.
-
#transmit(path, data) ⇒ Object
Transmits information to Squash.
Constructor Details
#initialize(host, options = {}) ⇒ Uploader
Creates a new Squash uploader that will communicate with a given host.
58 59 60 61 |
# File 'lib/squash/uploader.rb', line 58 def initialize(host, ={}) @host = host @options = DEFAULT_CONFIGURATION.merge() end |
Instance Attribute Details
#host ⇒ String
Returns The host name and scheme of the Squash server (e.g., “squash.mycompany.com”).
39 40 41 |
# File 'lib/squash/uploader.rb', line 39 def host @host end |
#options ⇒ Hash<Symbol, Object>
Returns Additional options for uploading.
41 42 43 |
# File 'lib/squash/uploader.rb', line 41 def @options end |
Instance Method Details
#transmit(path, data) ⇒ Object
Transmits information to Squash.
68 69 70 71 72 |
# File 'lib/squash/uploader.rb', line 68 def transmit(path, data) http_post (host + path), {'Content-Type' => 'application/json'}, [data.to_json] end |