Module: JLDrill::Config

Defined in:
lib/jldrill/model/Config.rb

Overview

Configuration data for JLDrill. This is how JLDrill knows where to find it’s data.

Constant Summary collapse

PERSONAL_DATA_DIR =
File.expand_path(File.join("~",".jldrill"))
REPO_DATA_DIR =
File.join(Config::repositoryDir, "data","jldrill")
GEM_DATA_DIR =
nil
DEBIAN_DATA_DIR =
File.join("/","usr","share","jldrill")
DEBIAN_EDICT_DIR =
File.join("/","usr","share","edict")
DATA_DIR =
getDataDir
QUIZ_DIR =
"quiz"
SVG_ICON_FILE =
"jldrill-icon.svg"
PNG_ICON_FILE =
"jldrill-icon.png"
DICTIONARY_DIR =
"dict"
DICTIONARY_FILE =
"edict"
KANJI_FILE =
File.join("dict","rikaichan","kanji.dat")
RADICAL_FILE =
File.join("dict","rikaichan","radicals.dat")
KANA_FILE =
File.join("dict","Kana","kana.dat")
TANAKA_FILE =
File.join("Tanaka","examples.utf")
TATOEBA_SENTENCE_FILE =
File.join("Tatoeba", "sentences.csv")
File.join("Tatoeba", "links.csv")
TATOEBA_JAPANESE_FILE =
File.join("Tatoeba", "jpn_indices.csv")
DEINFLECTION_FILE =
File.join("dict","rikaichan","deinflect.dat")

Class Method Summary collapse

Class Method Details

.configSrcDirObject



9
10
11
# File 'lib/jldrill/model/Config.rb', line 9

def Config::configSrcDir
    File.expand_path(File.dirname(__FILE__))
end

.getDataDirObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/jldrill/model/Config.rb', line 21

def Config::getDataDir
    if !Gem::datadir("jldrill").nil?
        # Use the data directory in the Gem if it is available
        File.expand_path(Gem::datadir("jldrill"))
    else
        # Otherwise hope we are in a source repository and
        # can find the data dir in the usual spot
        File.join(repositoryDir, "data","jldrill")
    end
end

.repositoryDirObject

In a source repository, this gives the top level directory If the source has been installed by a package, then who knows where this is…



16
17
18
19
# File 'lib/jldrill/model/Config.rb', line 16

def Config::repositoryDir
    File.expand_path(File.join(Config::configSrcDir, 
                               File.join("..","..","..")))
end

.resolveDataFile(filename) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/jldrill/model/Config.rb', line 42

def Config::resolveDataFile(filename)
    retVal = nil
    loadPath = LoadPath.new
    loadPath.add(PERSONAL_DATA_DIR)
    loadPath.add(REPO_DATA_DIR)
    loadPath.add(GEM_DATA_DIR)
    loadPath.add(DEBIAN_DATA_DIR)
    loadPath.add(DEBIAN_EDICT_DIR)
    return loadPath.find(filename)
end