lib/github-status/out.rb in concourse-github-status-0.1.1 vs lib/github-status/out.rb in concourse-github-status-0.2.0

- old
+ new

@@ -2,13 +2,18 @@ require 'concourse-fuselage' require 'contracts' require 'git' require 'octokit' +require_relative 'core' +require_relative 'support/params' module GitHubStatus class Out < Fuselage::Out + include Core + include Support::Params + Contract None => Sawyer::Resource def update! github.create_status repo, sha, state, options rescue Octokit::Error => error STDERR.puts error.message @@ -19,52 +24,10 @@ def version { 'context@sha' => "#{context}@#{sha}" } end Contract None => String - def repo - @repo ||= source.fetch 'repo' - rescue KeyError - STDERR.puts 'Source is missing repo' - abort - end - - Contract None => String - def access_token - @access_token ||= source.fetch 'access_token' - rescue KeyError - STDERR.puts 'Source is missing access_token' - abort - end - - Contract None => String - def state - @state ||= params.fetch 'state' - rescue KeyError - STDERR.puts 'Params is missing state' - abort - end - - Contract None => String - def path - @path ||= params.fetch 'path' - rescue KeyError - STDERR.puts 'Params is missing path' - abort - end - - Contract None => String - def context - @context ||= params.fetch 'context', 'concourse' - end - - Contract None => String - def description - @description ||= params.fetch 'description', '' - end - - Contract None => String def target_url @target_url ||= "#{atc_external_url}/builds/#{build_id}" end Contract None => HashOf[Symbol, String] @@ -84,10 +47,10 @@ abort end Contract None => String def sha - @repo ||= git.revparse 'HEAD' + @sha ||= git.revparse 'HEAD' end Contract None => Octokit::Client def github @github ||= Octokit::Client.new access_token: access_token