module BrowseEverything

Object structuring the credentials retrieved for the Google API's

Manages request parameters for the request to the Google Drive API

Constants

VERSION

Attributes

config[W]

Public Class Methods

config() click to toggle source
# File lib/browse_everything.rb, line 75
def config
  if @config.nil?
    config_path = Rails.root.join 'config', 'browse_everything_providers.yml'
    configure config_path.to_s
  end
  @config
end
configure(value) click to toggle source
# File lib/browse_everything.rb, line 50
def configure(value)
  return if value.nil?
  if value.is_a?(Hash)
    @config = ActiveSupport::HashWithIndifferentAccess.new value
  elsif value.is_a?(String)
    begin
      config_file_content = File.read(value)
      config_file_template = ERB.new(config_file_content)
      config_values = YAML.safe_load(config_file_template.result, [Symbol])
      @config = ActiveSupport::HashWithIndifferentAccess.new config_values
      @config.deep_symbolize_keys
    rescue Errno::ENOENT
      Rails.logger.warn 'Missing browse_everything_providers.yml configuration file'
      @config = ActiveSupport::HashWithIndifferentAccess.new({})
    end
  else
    raise InitializationError, "Unrecognized configuration: #{value.inspect}"
  end

  if @config.include? 'drop_box' # rubocop:disable Style/GuardClause
    warn '[DEPRECATION] `drop_box` is deprecated.  Please use `dropbox` instead.'
    @config['dropbox'] = @config.delete('drop_box')
  end
end