Sha256: b93c5c854c07acf70518028c5e74f3e05bdae95395a3574487fd5299446b6529

Contents?: true

Size: 1015 Bytes

Versions: 2

Compression:

Stored size: 1015 Bytes

Contents

# -*- encoding : utf-8 -*-
require 'rest_client'

module Lolcommits
  class Uploldz < Plugin
    attr_accessor :endpoint

    def initialize(runner)
      super
      self.options.concat(['endpoint', 'optional_key'])
    end

    def run_postcapture
      return unless valid_configuration?

      repo = self.runner.repo.to_s
      if repo.empty?
        puts 'Repo is empty, skipping upload'
      else
        debug 'Calling ' + configuration['endpoint'] + ' with repo ' + repo
        RestClient.post(configuration['endpoint'],
                        :file => File.new(self.runner.main_image),
                        :repo => repo,
                        :key => configuration['optional_key'])
      end
    rescue => e
      log_error(e, "ERROR: RestClient POST FAILED #{e.class} - #{e.message}")
    end

    def configured?
      !configuration['enabled'].nil? && configuration['endpoint']
    end

    def self.name
      'uploldz'
    end

    def self.runner_order
      :postcapture
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lolcommits-0.5.6 lib/lolcommits/plugins/uploldz.rb
lolcommits-0.5.5 lib/lolcommits/plugins/uploldz.rb