class Lolcommits::DotCom

Constants

BASE_URL

Public Class Methods

name() click to toggle source
# File lib/lolcommits/plugins/dot_com.rb, line 41
def self.name
  'dot_com'
end
new(runner) click to toggle source
Calls superclass method Lolcommits::Plugin::new
# File lib/lolcommits/plugins/dot_com.rb, line 7
def initialize(runner)
  super
  options.concat(%w(api_key api_secret repo_id))
end
runner_order() click to toggle source
# File lib/lolcommits/plugins/dot_com.rb, line 45
def self.runner_order
  :postcapture
end

Public Instance Methods

configured?() click to toggle source
# File lib/lolcommits/plugins/dot_com.rb, line 34
def configured?
  !configuration['enabled'].nil? &&
    configuration['api_key'] &&
    configuration['api_secret'] &&
    configuration['repo_id']
end
run_postcapture() click to toggle source
# File lib/lolcommits/plugins/dot_com.rb, line 12
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