Class: AppConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/AppConfig.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAppConfig

Returns a new instance of AppConfig.



16
17
18
19
# File 'lib/AppConfig.rb', line 16

def initialize
  @@version = "0.0.0"
  @@name = "unnamed"
end

Class Method Details

.dataDirsObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/AppConfig.rb', line 37

def AppConfig.dataDirs
  siteLibDir = ::Config::CONFIG['sitelibdir']
  siteBaseDir, rubyVersionDir = siteLibDir.scan(/(.*\/)(.*)/)[0]
  dirs = []
  # This is for the development version. We assume that we run the app
  # from the lib directory.
  dirs << "../data/"
  # This hopefully works for all setups. Otherwise we have to add more
  # alternative pathes.
  dirs << siteBaseDir + "gems/" + rubyVersionDir + '/gems/' \
      + @@name + '-' + @@version + '/data/'
  dirs << '/usr/share/'
  dirs << '/usr/local/share/'
end

.dataFile(fileName) ⇒ Object



60
61
62
63
64
65
# File 'lib/AppConfig.rb', line 60

def AppConfig.dataFile(fileName)
  dirs = dataDirs
  dirs.each { |d| return d + fileName if File.exist?(d + fileName) }

  nil
end

.dataFiles(fileName) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/AppConfig.rb', line 52

def AppConfig.dataFiles(fileName)
  files = []
  dirs = dataDirs
  dirs.each { |d| files << d + fileName if File.exist?(d + fileName) }

  files
end

.nameObject



33
34
35
# File 'lib/AppConfig.rb', line 33

def AppConfig.name
  @@name
end

.name=(name) ⇒ Object



29
30
31
# File 'lib/AppConfig.rb', line 29

def AppConfig.name=(name)
  @@name = name
end

.versionObject



25
26
27
# File 'lib/AppConfig.rb', line 25

def AppConfig.version
  @@version
end

.version=(version) ⇒ Object



21
22
23
# File 'lib/AppConfig.rb', line 21

def AppConfig.version=(version)
  @@version = version
end