Sha256: 6b016e4940c333c5fdc7ad24130af8e268ebe56b15942e312204f7e475eaa924

Contents?: true

Size: 1002 Bytes

Versions: 15

Compression:

Stored size: 1002 Bytes

Contents

require 'singleton'
require 'yaml'

module Taperole
  class Notifier
    include ::Singleton

    attr_accessor :observers

    def initialize
      @observers = []
    end

    class << self
      include Taperole::Helpers::Files

      def register_notifiers(options)
        if config["slack_webhook_url"]
          slack_notifier = Taperole::Notifiers::Slack.new(
            config["slack_webhook_url"],
            deploy_info(options)
          )
          instance.observers.push(slack_notifier)
        end
      end

      def config
        @config ||= YAML.load_file("#{tapefiles_dir}/tape_vars.yml")
      end

      def deploy_info(options)
        {
          app_name: config["app_name"],
          user: `whoami`.chomp,
          hosts: options[:limit] || 'default',
          repo: config["be_app_repo"] || ''
        }
      end

      def notify_observers(state)
        instance.observers.each do |observer|
          observer.update(state)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
taperole-2.1.1 lib/taperole/core/notifier.rb
taperole-2.1.0 lib/taperole/core/notifier.rb
taperole-2.0.7 lib/taperole/core/notifier.rb
taperole-2.0.6 lib/taperole/core/notifier.rb
taperole-2.0.5 lib/taperole/core/notifier.rb
taperole-2.0.4 lib/taperole/core/notifier.rb
taperole-2.0.3 lib/taperole/core/notifier.rb
taperole-2.0.2 lib/taperole/core/notifier.rb
taperole-2.0.1 lib/taperole/core/notifier.rb
taperole-2.0.0 lib/taperole/core/notifier.rb
taperole-1.8.2 lib/taperole/core/notifier.rb
taperole-1.8.1 lib/taperole/core/notifier.rb
taperole-1.8.0 lib/taperole/core/notifier.rb
taperole-1.7.1 lib/taperole/core/notifier.rb
taperole-1.7.0 lib/taperole/core/notifier.rb