lib/lolcommits/plugins/lolsrv.rb in lolcommits-0.5.7 vs lib/lolcommits/plugins/lolsrv.rb in lolcommits-0.5.8.pre1
- old
+ new
@@ -5,11 +5,11 @@
module Lolcommits
class Lolsrv < Plugin
def initialize(runner)
super
- self.options << 'server'
+ options << 'server'
end
def run_postcapture
return unless valid_configuration?
fork { sync }
@@ -19,33 +19,30 @@
!configuration['enabled'].nil? && configuration['server']
end
def sync
existing = existing_lols
- unless existing.nil?
- Dir[self.runner.config.loldir + '/*.{jpg,gif}'].each do |item|
- sha = File.basename(item, '.*')
- unless existing.include?(sha) || sha == 'tmp_snapshot'
- upload(item, sha)
- end
- end
+ return unless existing.nil?
+ Dir[runner.config.loldir + '/*.{jpg,gif}'].each do |item|
+ sha = File.basename(item, '.*')
+ upload(item, sha) unless existing.include?(sha) || sha == 'tmp_snapshot'
end
end
def existing_lols
lols = JSON.parse(
- RestClient.get(configuration['server'] + '/lols'))
+ RestClient.get(configuration['server'] + '/lols'))
lols.map { |lol| lol['sha'] }
rescue => e
log_error(e, "ERROR: existing lols could not be retrieved #{e.class} - #{e.message}")
return nil
end
def upload(file, sha)
RestClient.post(configuration['server'] + '/uplol',
:lol => File.new(file),
- :url => self.runner.git_info.url + sha,
- :repo => self.runner.git_info.repo,
+ :url => runner.git_info.url + sha,
+ :repo => runner.git_info.repo,
:date => File.ctime(file),
:sha => sha)
rescue => e
log_error(e, "ERROR: Upload of lol #{sha} FAILED #{e.class} - #{e.message}")
end