Sha256: da9b4063416612e6975bb4f370411516fc13649340eef97d029bb7dc0e8de46e

Contents?: true

Size: 694 Bytes

Versions: 2

Compression:

Stored size: 694 Bytes

Contents

require "travis" unless defined?(::Travis)
require "multi_notifier/middleware"

module MultiNotifier
  module Middlewares
    class Travis < Middleware
      attr_accessor :access_token, :repo, :travis_pro

      validates_presence_of :access_token, :repo

      def notify
        host = travis_pro? ? ::Travis::Client::PRO_URI : ::Travis::Client::ORG_URI
        client = travis_client(host, access_token)
        r = client.repo(repo)
        r.last_build.restart
      end

      def travis_pro?
        !!travis_pro
      end

      private

      def travis_client(host, access_token)
        ::Travis::Client.new "uri" => host, "access_token" => access_token
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
multi_notifier-0.4.0 lib/multi_notifier/middlewares/travis.rb
multi_notifier-0.3.0 lib/multi_notifier/middlewares/travis.rb