class ChupaText::ConfigurationLoader
Attributes
decomposer[R]
mime_types[R]
Public Class Methods
new(configuration)
click to toggle source
# File lib/chupa-text/configuration-loader.rb, line 23 def initialize(configuration) @configuration = configuration @decomposer = DecomposerLoader.new(@configuration.decomposer) @mime_types = MIMETypesLoader.new(@configuration.mime_type_registry) @load_paths = [] data_dir = Pathname(__dir__) + ".." + ".." + "data" @load_paths << data_dir.expand_path end
Public Instance Methods
load(path)
click to toggle source
# File lib/chupa-text/configuration-loader.rb, line 32 def load(path) path = resolve_path(path) File.open(path) do |file| instance_eval(file.read, path.to_path, 1) end end
Private Instance Methods
resolve_path(path)
click to toggle source
# File lib/chupa-text/configuration-loader.rb, line 40 def resolve_path(path) path = Pathname(path) unless path.is_a?(Pathname) return path if path.exist? return path if path.absolute? @load_paths.each do |load_path| resolved_path = path.expand_path(load_path) return resolved_path if resolved_path.exist? end path end