class Minjector::Config

Public Class Methods

exists?() click to toggle source
# File lib/minjector/config.rb, line 26
def exists?
  File.exist?(file)
end
file() click to toggle source
# File lib/minjector/config.rb, line 8
def file
  File.expand_path(File.join("~", ".minjector", "config"))
end
read() click to toggle source
# File lib/minjector/config.rb, line 12
def read
  config = {}

  File.open(file, "r") do |f|
    config = YAML.load(f)
  end

  config[:buckets].each do |bucket|
    bucket[:path] = File.expand_path(bucket[:path])
  end

  config
end
write(config) click to toggle source
# File lib/minjector/config.rb, line 30
def write(config)
  unless exists?
    FileUtils.mkdir_p(File.dirname(file))
  end

  File.open(file, "w") do |f|
    return YAML.dump(config, f)
  end
end

Private Class Methods

example() click to toggle source
# File lib/minjector/config.rb, line 42
def example
  {
    :token => "YOUR_API_TOKEN",
    :buckets => [
      {
        :name => "Movies",
        :path => File.expand_path("~/Movies")
      }
    ]
  }
end