Sha256: 8a8b542c1328193c66b19cd85a82a43bff4587f5f6646d3b1eb7e3ddc1410f65

Contents?: true

Size: 1.3 KB

Versions: 9

Compression:

Stored size: 1.3 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 :build
      
      def initialize(build, config)
        @build = build
        @config = config
      end
      
      def deliver!
        raise NoMethodError, "you need to implement this method in your notifier"
      end
      
      def short_message
        "Build #{build.short_commit_identifier} #{build.successful? ? "was successful" : "failed"}"
      end
      
      def full_message
        <<-EOM
"Build #{build.commit_identifier} #{build.successful? ? "was successful" : "failed"}"

Commit Message: #{build.commit_message}
Commit Date: #{build.commited_at}
Commit Author: #{build.commit_author.name}

Link: #{build_url}

Build Output:

#{stripped_build_output}
EOM
      end
      
      def build_url
        raise if Integrity.config[:base_uri].nil?
        Integrity.config[:base_uri] / build.project.permalink / "builds" / build.commit_identifier
      end

      private

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

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
bantic-integrity-0.1.4.1 lib/integrity/notifier/base.rb
bantic-integrity-0.1.4.2 lib/integrity/notifier/base.rb
bantic-integrity-0.1.4.3 lib/integrity/notifier/base.rb
bantic-integrity-0.1.4.4 lib/integrity/notifier/base.rb
bantic-integrity-0.1.4 lib/integrity/notifier/base.rb
foca-integrity-0.1.2 lib/integrity/notifier/base.rb
foca-integrity-0.1.3 lib/integrity/notifier/base.rb
foca-integrity-0.1.4 lib/integrity/notifier/base.rb
giraffesoft-integrity-0.1.4 lib/integrity/notifier/base.rb