Sha256: fd4dd7e91f5103f4e0da97f697d18c58e0d9775a06a74acf0bb89c39c1b21110

Contents?: true

Size: 932 Bytes

Versions: 4

Compression:

Stored size: 932 Bytes

Contents

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

    def initialize
      @robot = Robot.new
    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 if [:enabled, :disabled].include? 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

4 entries across 4 versions & 1 rubygems

Version Path
slappy-0.6.0 lib/slappy/configuration.rb
slappy-0.5.2 lib/slappy/configuration.rb
slappy-0.5.1 lib/slappy/configuration.rb
slappy-0.5.0 lib/slappy/configuration.rb