class HatenaFotolife::Configuration

Constants

OAUTH_KEYS

Public Class Methods

create(config_file) click to toggle source

Create a new configuration. @param [String] config_file configuration file path @return [HatenaFotolife::Configuration]

# File lib/hatena_fotolife/configuration.rb, line 12
def self.create(config_file)
  loaded_config = YAML.load(ERB.new(File.read(config_file)).result)
  config = new(loaded_config)
  config.check_valid_or_raise
end

Public Instance Methods

check_valid_or_raise() click to toggle source
# File lib/hatena_fotolife/configuration.rb, line 18
def check_valid_or_raise
  unless (lacking_keys = self.send(:lacking_keys)).empty?
    raise ConfigurationError, "Following keys are not setup. #{lacking_keys.map(&:to_s)}"
  end
  self
end

Private Instance Methods

lacking_keys() click to toggle source
# File lib/hatena_fotolife/configuration.rb, line 27
def lacking_keys
  config_keys   = to_h.keys
  OAUTH_KEYS.select { |key| !config_keys.include?(key) }
end