Sha256: 47ed8bf74c014504cf06feda04ca677a756287d0565fa6448f504bae01551ecf

Contents?: true

Size: 986 Bytes

Versions: 1

Compression:

Stored size: 986 Bytes

Contents

# -*- coding: utf-8 -*-
# vim:ft=ruby:enc=utf-8

require 'rbconfig'

module ToPass
  # Wrapper for the search directories. Primary purpose is to keep the dirty
  # part in one place instead of scattered throughout the project.
  #
  # Used by ToPass::AlgorithmReader and ToPass::ConverterReader
  class Directories
    class << self
      # get a directory or a list of directories
      def [](key)
        case key
        when :user, :data, :base, :source_data
          all[key]
        when :standard
          [ all[:user], all[:data], all[:source_data] ]
        end
      end

      private

      # list of all direcotries used by this project
      def all
        {
          :user => "~/.#{APP_NAME}",
          :data => "#{RbConfig::CONFIG['data-dir']}/#{APP_NAME}",
          :base => File.expand_path("#{File.dirname(__FILE__)}/../.."),
          :source_data => File.expand_path("#{File.dirname(__FILE__)}/../../data/#{APP_NAME}"),
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
to_pass-0.6.0 lib/to_pass/directories.rb