Class: Upcloudify

Inherits:
Object
  • Object
show all
Defined in:
lib/upcloudify.rb,
lib/notifiers/slack.rb,
lib/upcloudify/version.rb

Defined Under Namespace

Modules: Notifiers Classes: S3

Constant Summary collapse

VERSION =
"0.3.3"

Instance Method Summary collapse

Constructor Details

#initialize(uploader: nil, notifier: nil) ⇒ Upcloudify

Returns a new instance of Upcloudify.



13
14
15
16
17
18
# File 'lib/upcloudify.rb', line 13

def initialize(uploader: nil, notifier: nil)
  raise ArgumentError "uploader cannot be nil" unless uploader
  raise ArgumentError "notifier cannot be nil" unless notifier
  @uploader = uploader
  @notifier = notifier
end

Instance Method Details

#upload_and_notify(filename: nil, attachment: nil, message: "%s") ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/upcloudify.rb', line 20

def upload_and_notify(filename: nil, attachment: nil, message: "%s")
  raise ArgumentError "filename cannot be nil" unless filename
  raise ArgumentError "attachment cannot be nil" unless attachment

  expiration = (Date.today + 7).to_time
  file = @uploader.upload(filename, attachment)
  @notifier.notify(text: message % file.url(expiration))
end