Sha256: a4f3cd3dc772d65e856314e27111fc9db475a3d16bbaca71a96eb558695f520c

Contents?: true

Size: 1.09 KB

Versions: 15

Compression:

Stored size: 1.09 KB

Contents

module Xcov
  class SlackPoster

    def run(report)
      return if Xcov.config[:skip_slack]
      return if Xcov.config[:slack_url].nil?

      require 'slack-notifier'
      notifier = Slack::Notifier.new(Xcov.config[:slack_url])
      notifier.username = 'xcov'

      if Xcov.config[:slack_channel].to_s.length > 0
        notifier.channel = Xcov.config[:slack_channel]
        notifier.channel = ('#' + notifier.channel) unless ['#', '@'].include?(notifier.channel[0])
      end

      attachments = []

      report.targets.each do |target|
        attachments << {
          text: "#{target.name}: #{target.displayable_coverage}",
          color: target.coverage_color,
          short: true
        }
      end

      result = notifier.ping "Your *xcov* coverage report",
                             icon_url: 'https://s3-eu-west-1.amazonaws.com/fastlane.tools/fastlane.png',
                             attachments: attachments

      if result.code.to_i == 200
        UI.message 'Successfully sent Slack notification'.green
      else
        UI.message result.to_s.red
      end
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
xcov-1.0.1 lib/xcov/slack_poster.rb
xcov-1.0.0 lib/xcov/slack_poster.rb
xcov-0.12.5 lib/xcov/slack_poster.rb
xcov-0.12.4 lib/xcov/slack_poster.rb
xcov-0.12.3 lib/xcov/slack_poster.rb
xcov-0.12.2 lib/xcov/slack_poster.rb
xcov-0.12.1 lib/xcov/slack_poster.rb
xcov-0.12 lib/xcov/slack_poster.rb
xcov-0.11.3 lib/xcov/slack_poster.rb
xcov-0.11.2 lib/xcov/slack_poster.rb
xcov-0.11.1 lib/xcov/slack_poster.rb
xcov-0.11 lib/xcov/slack_poster.rb
xcov-0.10 lib/xcov/slack_poster.rb
xcov-0.9 lib/xcov/slack_poster.rb
xcov-0.8 lib/xcov/slack_poster.rb