Sha256: cc2dce59f7eb2c88afecb6e1aa20999c3f85f750a08c5f27dd92f11eff715051

Contents?: true

Size: 1.51 KB

Versions: 9

Compression:

Stored size: 1.51 KB

Contents

module Integrity
  class Notifier
    class Base
      def self.notify_of_build(build, config)
        Timeout.timeout(8) { new(build, config).deliver! }
      end

      def self.to_haml
        raise NoMethodError, "you need to implement this method in your notifier"
      end

      attr_reader :commit

      def initialize(commit, config)
        @commit = commit
        @config = config
      end

      def build
        warn "Notifier::Base#build is deprecated, use Notifier::Base#commit instead"
        commit
      end

      def deliver!
        raise NoMethodError, "you need to implement this method in your notifier"
      end

      def short_message
        commit.human_readable_status
      end

      def full_message
        <<-EOM
"Build #{commit.identifier} #{commit.successful? ? "was successful" : "failed"}"

Commit Message: #{commit.message}
Commit Date: #{commit.committed_at}
Commit Author: #{commit.author.name}

Link: #{commit_url}

Build Output:

#{stripped_commit_output}
EOM
      end

      def commit_url
        raise if Integrity.config[:base_uri].nil?
        Integrity.config[:base_uri] / commit.project.permalink / "commits" / commit.identifier
      end

      private

        def stripped_commit_output
          commit.output.gsub("\e[0m", "").gsub(/\e\[3[1-7]m/, "")
        end

        def stripped_build_output
          warn "Notifier::Base#stripped_build_output is deprecated, use Notifier::base#stripped_commit_output instead"
          stripped_commit_output
        end
    end
  end
end

Version data entries

9 entries across 9 versions & 4 rubygems

Version Path
foca-integrity-0.1.9.0 lib/integrity/notifier/base.rb
foca-integrity-0.1.9.1 lib/integrity/notifier/base.rb
oliyoung-integrity-0.1.9.0 lib/integrity/notifier/base.rb
sr-integrity-0.1.8.1 lib/integrity/notifier/base.rb
sr-integrity-0.1.9.1 lib/integrity/notifier/base.rb
sr-integrity-0.1.9.2 lib/integrity/notifier/base.rb
integrity-0.1.9.1 lib/integrity/notifier/base.rb
integrity-0.1.9.0 lib/integrity/notifier/base.rb
integrity-0.1.9 lib/integrity/notifier/base.rb