Class: Colore::C_

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

Overview

This is a simple mechanism to hold document configuration. A future version will replace this with SimpleConfig.

It is accessed by calling C_.setting, where the config settings are defined as attr_accessors in the class. For example:

storage_dir = C_.storage_directory

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#conversion_logObject

Path to the Heathen conversion log


27
28
29
# File 'lib/config.rb', line 27

def conversion_log
  @conversion_log
end

#error_logObject

Path to the Error log


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

def error_log
  @error_log
end

#legacy_purge_daysObject

Number of days to keep legacy files before purging


19
20
21
# File 'lib/config.rb', line 19

def legacy_purge_days
  @legacy_purge_days
end

#legacy_url_baseObject

File URL base for legacy convert API method


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

def legacy_url_base
  @legacy_url_base
end

#redis_namespaceObject

Redis namespace (used by sidekiq)


23
24
25
# File 'lib/config.rb', line 23

def redis_namespace
  @redis_namespace
end

#redis_urlObject

Redis connection URL (used by sidekiq)


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

def redis_url
  @redis_url
end

#storage_directoryObject

Base storage directory for all documents


15
16
17
# File 'lib/config.rb', line 15

def storage_directory
  @storage_directory
end

#wkhtmltopdf_pathObject

Path to the wkhtmltopdf binary


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

def wkhtmltopdf_path
  @wkhtmltopdf_path
end

Class Method Details

.configObject


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

def self.config
  @config ||= begin
    yaml = YAML.load File.read(config_file_path)
    c = new
    c.storage_directory = yaml['storage_directory']
    c.legacy_url_base = yaml['legacy_url_base']
    c.legacy_purge_days = yaml['legacy_purge_days'].to_i
    c.redis_url = yaml['redis_url']
    c.redis_namespace = yaml['redis_namespace']
    c.wkhtmltopdf_path = yaml['wkhtmltopdf_path']
    c.conversion_log = yaml['conversion_log']
    c.error_log = yaml['error_log']
    c
  end
end

.config_file_pathObject


31
32
33
34
# File 'lib/config.rb', line 31

def self.config_file_path  # BASE/config/app.yml

  Pathname.new(__FILE__).realpath.parent.parent + 'config' + 'app.yml'
end

.method_missing(*args) ⇒ Object


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

def self.method_missing *args
  if config.respond_to? args[0].to_sym
    config.send( *args )
  else
    super
  end
end

.resetObject

Reset config - used for testing


61
62
63
# File 'lib/config.rb', line 61

def self.reset
  @config = nil
end