module RemoTransmission

Constants

DEFAULT_OPTIONS
VERSION

Public Class Methods

default_options(file = nil) click to toggle source

Returns the default options hash, optionnaly pulled from the given configuration file.

Arguments:

file: path to JSON configuration file
# File lib/remotransmission.rb, line 21
def self.default_options(file = nil)
  defaults = DEFAULT_OPTIONS

  if file and file = File.expand_path(file) and File.exists?(file)
    config = JSON.parse(File.read(file))

    # symbolize keys
    config = config.inject({}) do |options, (key, value)|
      options[key.to_sym] = value
      options
    end

    defaults = defaults.merge(config)
  end

  defaults
end