Class: Sinicum::Imaging::Config
- Inherits:
-
Object
- Object
- Sinicum::Imaging::Config
- Includes:
- Logger
- Defined in:
- lib/sinicum/imaging/config.rb
Overview
Represents the configuraiton of the imaging module and its renderers
Constant Summary collapse
- IMAGING_CONFIG_FILE =
"config/imaging.yml"
- VERSION =
The version number of the imaging directory format. Stored in the file ‘VERSION`.
"1.0"
- DEFAULT_ROOT_DIR =
Default Root directory
File.join("tmp", "imaging")
- @@dir_setup =
If the directory sturcture is already set up
false
Instance Attribute Summary collapse
-
#root_dir ⇒ Object
readonly
The root directory under which all files are stored.
Class Method Summary collapse
-
.configure(configfile) ⇒ Object
Initialize and setup the configuration.
-
.instance ⇒ Object
Obtain an instance of the imaging configuration.
- .read_configuration ⇒ Object
Instance Method Summary collapse
-
#converter(renderer) ⇒ Sinicum::Imaging::Converter
Returns the converter class for a given renderer.
-
#file_dir ⇒ String
The directory to store all rendered files in.
-
#tmp_dir ⇒ String
The directory to store temporary files in.
-
#version_file ⇒ String
Path of the file that stores the version of the directory format.
Methods included from Logger
Instance Attribute Details
#root_dir ⇒ Object (readonly)
The root directory under which all files are stored
21 22 23 |
# File 'lib/sinicum/imaging/config.rb', line 21 def root_dir @root_dir end |
Class Method Details
.configure(configfile) ⇒ Object
Initialize and setup the configuration
‘Rails.root/config/imaging.yml` will be used.
48 49 50 51 52 53 |
# File 'lib/sinicum/imaging/config.rb', line 48 def self.configure(configfile) config = Config.send(:new, configfile) @@__instance__ = config @@config = true config end |
.instance ⇒ Object
Obtain an instance of the imaging configuration.
56 57 58 59 60 |
# File 'lib/sinicum/imaging/config.rb', line 56 def self.instance @@__instance__ ||= false fail "Class is not yet configured" unless @@__instance__ @@__instance__ end |
.read_configuration ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/sinicum/imaging/config.rb', line 74 def self.read_configuration config_file = File.join(Rails.root, IMAGING_CONFIG_FILE) if Rails.env.production? @@conf ||= configure(config_file) else configure(config_file) end end |
Instance Method Details
#converter(renderer) ⇒ Sinicum::Imaging::Converter
Returns the converter class for a given renderer
66 67 68 69 70 71 72 |
# File 'lib/sinicum/imaging/config.rb', line 66 def converter(renderer) result = nil renderer_config = read_config[renderer.to_s] result = render_type(renderer_config) if renderer_config result ||= DefaultConverter.new(nil) result end |
#file_dir ⇒ String
The directory to store all rendered files in
26 27 28 |
# File 'lib/sinicum/imaging/config.rb', line 26 def file_dir File.join(@root_dir, "files") end |
#tmp_dir ⇒ String
The directory to store temporary files in
33 34 35 |
# File 'lib/sinicum/imaging/config.rb', line 33 def tmp_dir File.join(@root_dir, "tmp") end |
#version_file ⇒ String
Path of the file that stores the version of the directory format.
40 41 42 |
# File 'lib/sinicum/imaging/config.rb', line 40 def version_file File.join(@root_dir, "VERSION") end |