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'
Instance Attribute Summary collapse
- #config ⇒ Array, Hash readonly
- #path ⇒ Pathname readonly
Class Method Summary collapse
Instance Method Summary collapse
- #files(type) ⇒ Array<String>
-
#initialize(config, path) ⇒ Config
constructor
A new instance of Config.
- #options(type) ⇒ Hash
- #output(type) ⇒ String
Constructor Details
#initialize(config, path) ⇒ Config
Returns a new instance of Config.
45 46 47 48 |
# File 'lib/yui/compressor/ext/config.rb', line 45 def initialize(config, path) @config = config @path = Pathname.new(path) end |
Instance Attribute Details
#config ⇒ Array, Hash (readonly)
38 39 40 |
# File 'lib/yui/compressor/ext/config.rb', line 38 def config @config end |
#path ⇒ Pathname (readonly)
41 42 43 |
# File 'lib/yui/compressor/ext/config.rb', line 41 def path @path end |
Class Method Details
.load_file(path) ⇒ Ext::Config
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/yui/compressor/ext/config.rb', line 13 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, File.(path)) end |
Instance Method Details
#files(type) ⇒ Array<String>
58 59 60 61 62 63 |
# File 'lib/yui/compressor/ext/config.rb', line 58 def files(type) dir = config_for(type, 'files_dir') || config_for(type, 'base_dir') config_for(type, 'files').map do |file| build_path(dir, file) end end |
#options(type) ⇒ Hash
67 68 69 70 |
# File 'lib/yui/compressor/ext/config.rb', line 67 def (type) opts = @config['options'] || {} opts.merge(config_for(type, 'options') || {}) end |
#output(type) ⇒ String
52 53 54 |
# File 'lib/yui/compressor/ext/config.rb', line 52 def output(type) build_path(@config['output_dir'], config_for(type, 'output')) end |