Sha256: d39b59537b0450c36864c04c172dba2bb3669498294ddbf53cc4a3f2329120ce

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

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

module Lolcommits
  class DotCom < Plugin
    BASE_URL = 'http://lolcommits-dot-com.herokuapp.com'.freeze

    def initialize(runner)
      super
      options.concat(%w(api_key api_secret repo_id))
    end

    def run_postcapture
      return unless valid_configuration?

      t = Time.now.to_i.to_s
      HTTMultiParty.post(
        "#{BASE_URL}/git_commits.json",
        body: {
          git_commit: {
            sha: runner.sha,
            repo_external_id: configuration['repo_id'],
            image: File.open(runner.main_image),
            raw: File.open(runner.snapshot_loc)
          },

          key: configuration['api_key'],
          t: t,
          token: Digest::SHA1.hexdigest(configuration['api_secret'] + t)
        }
      )
    rescue => e
      log_error(e, "ERROR: HTTMultiParty POST FAILED #{e.class} - #{e.message}")
    end

    def configured?
      !configuration['enabled'].nil? &&
        configuration['api_key'] &&
        configuration['api_secret'] &&
        configuration['repo_id']
    end

    def self.name
      'dot_com'
    end

    def self.runner_order
      :postcapture
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lolcommits-0.9.2 lib/lolcommits/plugins/dot_com.rb
lolcommits-0.9.2.pre1 lib/lolcommits/plugins/dot_com.rb
lolcommits-0.9.1 lib/lolcommits/plugins/dot_com.rb
lolcommits-0.9.1.pre1 lib/lolcommits/plugins/dot_com.rb
lolcommits-0.9.0 lib/lolcommits/plugins/dot_com.rb