Class: EvalUploader
- Inherits:
-
Object
- Object
- EvalUploader
- Defined in:
- lib/captured/uploaders/eval_uploader.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #gen_remote_name(file) ⇒ Object
-
#initialize(config = {}) ⇒ EvalUploader
constructor
A new instance of EvalUploader.
- #upload(file) ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ EvalUploader
Returns a new instance of EvalUploader.
4 5 6 |
# File 'lib/captured/uploaders/eval_uploader.rb', line 4 def initialize(config = {}) @config = config end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/captured/uploaders/eval_uploader.rb', line 2 def url @url end |
Instance Method Details
#gen_remote_name(file) ⇒ Object
8 9 10 |
# File 'lib/captured/uploaders/eval_uploader.rb', line 8 def gen_remote_name(file) Digest::MD5.hexdigest(file+Time.now.to_i.to_s) + File.extname(file) end |
#upload(file) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/captured/uploaders/eval_uploader.rb', line 12 def upload(file) remote_path = nil remote_name = gen_remote_name(file) unless eval @config['upload']['command'] raise "Upload failed: Bad Eval in config file" end # if the eval defines remote_path we will copy that to the clipboard # otherwise we compute it ouselves @url = remote_path || "#{@config['upload']['url']}#{remote_name}" @url end |