Class: WonkoTheSane::WonkoWeb
- Inherits:
-
Object
- Object
- WonkoTheSane::WonkoWeb
- Includes:
- HTTParty
- Defined in:
- lib/wonko_the_sane/wonkoweb_uploader.rb
Defined Under Namespace
Classes: UploadError
Instance Method Summary collapse
- #file(uid) ⇒ Object
- #index ⇒ Object
-
#initialize(benchmark) ⇒ WonkoWeb
constructor
A new instance of WonkoWeb.
- #upload_file(data) ⇒ Object
- #upload_version(data) ⇒ Object
- #version(uid, version) ⇒ Object
Constructor Details
#initialize(benchmark) ⇒ WonkoWeb
Returns a new instance of WonkoWeb.
13 14 15 16 17 18 19 20 21 |
# File 'lib/wonko_the_sane/wonkoweb_uploader.rb', line 13 def initialize(benchmark) self.class.base_uri Settings[:wonkoweb][:host] self.class.headers 'X-Uploader-Name' => Settings[:wonkoweb][:name], 'X-Uploader-Token' => Settings[:wonkoweb][:token], 'X-WUR-Enabled' => 'true', 'Content-Type' => 'application/json' @benchmark = benchmark end |
Instance Method Details
#file(uid) ⇒ Object
27 28 29 |
# File 'lib/wonko_the_sane/wonkoweb_uploader.rb', line 27 def file(uid) self.class.get(path uid).with_indifferent_access end |
#index ⇒ Object
23 24 25 |
# File 'lib/wonko_the_sane/wonkoweb_uploader.rb', line 23 def index self.class.get(path 'index').with_indifferent_access end |
#upload_file(data) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/wonko_the_sane/wonkoweb_uploader.rb', line 35 def upload_file(data) return if data.nil? uid = data[:uid] theirs = @benchmark.benchmark('upload_file.theirs') { file uid rescue nil } data.delete :versions # only stubs here data[:name] ||= data[:uid] upload_hash path, path(uid), data, theirs, false end |
#upload_version(data) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/wonko_the_sane/wonkoweb_uploader.rb', line 46 def upload_version(data) return if data.nil? uid = data[:uid] version = data[:version] theirs = @benchmark.benchmark('upload_version.theirs') { version uid, version rescue nil } upload_hash path(uid), path(uid, version), data, theirs, true end |
#version(uid, version) ⇒ Object
31 32 33 |
# File 'lib/wonko_the_sane/wonkoweb_uploader.rb', line 31 def version(uid, version) self.class.get(path uid, version).with_indifferent_access end |