Sha256: 45d0e33066ccaacbfa8031d182b47d228f4f62b3ef9db2052e7359b9f625d3bc

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module Slappy
  class Configuration
    attr_accessor :robot, :token, :scripts_dir_path, :lib_dir_path, :logger, :stop_with_error

    def initialize
      @robot = Robot.new
    end

    def stop_with_error
      @stop_with_error = true if @stop_with_error.nil?
      @stop_with_error
    end

    def logger
      unless @logger
        @logger = Logger.new(STDOUT)
        @logger.level = Logger::INFO
      end
      @logger
    end

    def token
      @token ||= ENV['SLACK_TOKEN']
    end

    def config_file_path
      './slappy_config.rb'
    end

    def lib_dir_path
      @lib_dir_path ||= './lib'
    end

    def scripts_dir_path
      @scripts_dir_path ||= './slappy-scripts'
    end

    def dsl
      @dsl ||= :enabled
    end

    def dsl=(symbol)
      fail ArgumentError unless [:enabled, :disabled].include? symbol
      @dsl = symbol
    end

    def send_params
      {
        username: robot.username,
        icon_emoji: robot.icon_emoji,
        channel: robot.channel,
        icon_url: robot.icon_url,
        as_user: robot.as_user
      }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slappy-0.6.3 lib/slappy/configuration.rb
slappy-0.6.2 lib/slappy/configuration.rb