Sha256: 5ff372f028900222fdef11b405c09df741dbe3bad83233c5cc9f523fe674e623
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 KB
Contents
# -*- encoding : utf-8 -*- require 'rest_client' require 'pp' require 'json' module Lolcommits class Lolsrv < Plugin def initialize(runner) super options << 'server' end def run_postcapture return unless valid_configuration? fork { sync } end def configured? !configuration['enabled'].nil? && configuration['server'] end def sync existing = existing_lols 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')) 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 => runner.vcs_info.url + sha, :repo => runner.vcs_info.repo, :date => File.ctime(file), :sha => sha) rescue => e log_error(e, "ERROR: Upload of lol #{sha} FAILED #{e.class} - #{e.message}") end def self.name 'lolsrv' end def self.runner_order :postcapture end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lolcommits-0.8.1 | lib/lolcommits/plugins/lolsrv.rb |
lolcommits-0.8.0 | lib/lolcommits/plugins/lolsrv.rb |