Sha256: f520bd29436fc434dddb5b8be36251e238502b28bb83a59161d0bf5b05a3b02b

Contents?: true

Size: 754 Bytes

Versions: 2

Compression:

Stored size: 754 Bytes

Contents

require 'yaml'

module Configuration
  def configure(opts)
    unless config_file_exists?(opts[:path])
      STDERR.puts Rainbow("Config file .hibotrc not found. Please ensure that it exists in your home directory or override the default location with the option corresponding.").red
      exit 1
    end

    config = read_config_file(opts[:path])
  end

  def config_file_exists?(path)
    File.exists?(path)
  end

  def read_config_file(path)
    config = YAML.load_file(path)
  end

  def configure_hibot_spotify(opts)
    opts.each {|opt, value|
      API::Spotify.class_variable_set("@@#{opt}", value)
    }
  end

  def configure_hibot_giphy(opts)
    opts.each {|opt, value|
      API::Giphy.class_variable_set("@@#{opt}", value)
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hibot-0.0.4 lib/hibot/helpers/configuration.rb
hibot-0.0.2 lib/hibot/helpers/configuration.rb