Sha256: 1f20a379296447b4803b9997b91eca22cacd40d1129df0536c32f71297d7cca5

Contents?: true

Size: 855 Bytes

Versions: 2

Compression:

Stored size: 855 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
      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
    end

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

    def self.name
      'uploldz'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lolcommits-0.5.4 lib/lolcommits/plugins/uploldz.rb
lolcommits-0.5.3 lib/lolcommits/plugins/uploldz.rb