Module: Configuration

Included in:
Hibot
Defined in:
lib/hibot/helpers/configuration.rb

Instance Method Summary collapse

Instance Method Details

#config_file_exists?(path) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/hibot/helpers/configuration.rb', line 13

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

#configure(opts) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/hibot/helpers/configuration.rb', line 4

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

#configure_hibot_giphy(opts) ⇒ Object



27
28
29
30
31
# File 'lib/hibot/helpers/configuration.rb', line 27

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

#configure_hibot_spotify(opts) ⇒ Object



21
22
23
24
25
# File 'lib/hibot/helpers/configuration.rb', line 21

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

#read_config_file(path) ⇒ Object



17
18
19
# File 'lib/hibot/helpers/configuration.rb', line 17

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