Class: YUI::Compressor::Ext::Config
- Inherits:
-
Object
- Object
- YUI::Compressor::Ext::Config
- Defined in:
- lib/yui/compressor/ext/config.rb
Constant Summary collapse
- DEFAULT =
'config.yml'
Class Method Summary collapse
Instance Method Summary collapse
- #files(type) ⇒ Array<String>
-
#initialize(config) ⇒ Config
constructor
A new instance of Config.
- #options(type) ⇒ Hash
- #output(type) ⇒ String
Constructor Details
#initialize(config) ⇒ Config
Returns a new instance of Config.
36 37 38 |
# File 'lib/yui/compressor/ext/config.rb', line 36 def initialize(config) @config = config end |
Class Method Details
.load_file(path) ⇒ Ext::Config
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/yui/compressor/ext/config.rb', line 11 def load_file(path) path ||= DEFAULT unless File.exist? path raise ArgumentError, "Not found configuration file to `#{File.(path)}`." end config = YAML.load_file(path) unless validate(config) raise 'Invalid configuration file.' end new(config) end |
Instance Method Details
#files(type) ⇒ Array<String>
49 50 51 52 53 54 55 |
# File 'lib/yui/compressor/ext/config.rb', line 49 def files(type) base = clean_path(config_for(type, 'base_dir')) files = config_for(type, 'files') files.map do |file| File.join(*[base, clean_path(file)].compact) end end |
#options(type) ⇒ Hash
59 60 61 62 |
# File 'lib/yui/compressor/ext/config.rb', line 59 def (type) base = @config['options'] || {} base.merge(config_for(type, 'options') || {}) end |
#output(type) ⇒ String
42 43 44 45 |
# File 'lib/yui/compressor/ext/config.rb', line 42 def output(type) File.join(*[clean_path(@config['output_dir']), clean_path(config_for(type, 'output'))].compact) end |