Class: Chimps::Workflows::Upload::Notifier
- Defined in:
- lib/chimps/workflows/upload/notifier.rb
Overview
Encapsulates the process of notifying Infochimps of new data that’s already been uploaded.
Instance Attribute Summary collapse
-
#bundler ⇒ Object
The bundler responsible for the upload.
-
#response ⇒ Object
The response from Infochimps to the request to create a package.
-
#token ⇒ Object
The upload token used for the upload.
Instance Method Summary collapse
-
#data ⇒ Hash
Information about the uplaoded data to pass to Infochimps when notifying.
-
#initialize(token, bundler) ⇒ Notifier
constructor
A new instance of Notifier.
-
#path ⇒ String
The path on Infochimps to submit package creation requests to.
-
#post ⇒ Chimps::Response
Make a request to notify Infochimps of the new data.
Constructor Details
#initialize(token, bundler) ⇒ Notifier
Returns a new instance of Notifier.
19 20 21 22 |
# File 'lib/chimps/workflows/upload/notifier.rb', line 19 def initialize token, bundler self.token = token self.bundler = bundler end |
Instance Attribute Details
#bundler ⇒ Object
The bundler responsible for the upload.
17 18 19 |
# File 'lib/chimps/workflows/upload/notifier.rb', line 17 def bundler @bundler end |
#response ⇒ Object
The response from Infochimps to the request to create a package.
11 12 13 |
# File 'lib/chimps/workflows/upload/notifier.rb', line 11 def response @response end |
#token ⇒ Object
The upload token used for the upload.
14 15 16 |
# File 'lib/chimps/workflows/upload/notifier.rb', line 14 def token @token end |
Instance Method Details
#data ⇒ Hash
Information about the uplaoded data to pass to Infochimps when notifying.
36 37 38 |
# File 'lib/chimps/workflows/upload/notifier.rb', line 36 def data { :package => {:fmt => token['fmt'], :pkg_size => bundler.size, :pkg_fmt => bundler.pkg_fmt, :summary => bundler.summary, :token_timestamp => token['timestamp'] } } end |
#path ⇒ String
The path on Infochimps to submit package creation requests to.
28 29 30 |
# File 'lib/chimps/workflows/upload/notifier.rb', line 28 def path "/datasets/#{bundler.dataset}/packages.json" end |
#post ⇒ Chimps::Response
Make a request to notify Infochimps of the new data.
43 44 45 46 47 48 49 50 |
# File 'lib/chimps/workflows/upload/notifier.rb', line 43 def post @response = Request.new(path, :signed => true, :data => data).post if response.error? response.print raise UploadError.new("Unable to notify Infochimps of newly uploaded data.") end response end |