Class: JsDuck::Options::Config
- Inherits:
-
Object
- Object
- JsDuck::Options::Config
- Defined in:
- lib/jsduck/options/config.rb
Overview
Handles reading JSON config file, specified by –config option.
Class Method Summary collapse
-
.read(filename) ⇒ Object
Reads JSON configuration from file and returns an array of config options that can be feeded into optparser.
Class Method Details
.read(filename) ⇒ Object
Reads JSON configuration from file and returns an array of config options that can be feeded into optparser.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jsduck/options/config.rb', line 11 def self.read(filename) config = [] json = Util::Json.read(filename) json.each_pair do |key, value| if key == "--" # filenames config += Array(value).map(&:to_s) elsif value == true # simple switch config += [key.to_s] else # An option with value or with multiple values. # In the latter case, add the option multiple times. Array(value).each do |v| config += [key.to_s, v.to_s] end end end config end |