Class: MOSAIK::Configuration
- Inherits:
-
Object
- Object
- MOSAIK::Configuration
- Defined in:
- lib/mosaik/configuration.rb
Overview
Configuration parser (mosaik.yml)
Instance Attribute Summary collapse
-
#collapsed ⇒ Object
readonly
Returns the value of attribute collapsed.
-
#excludes ⇒ Object
readonly
Returns the value of attribute excludes.
-
#includes ⇒ Object
readonly
Returns the value of attribute includes.
-
#load_paths ⇒ Object
readonly
Returns the value of attribute load_paths.
-
#overrides ⇒ Object
readonly
Returns the value of attribute overrides.
Class Method Summary collapse
Instance Method Summary collapse
- #files ⇒ Object
-
#initialize(directory:, load_paths: [], includes: [], excludes: [], overrides: {}, collapsed: []) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(directory:, load_paths: [], includes: [], excludes: [], overrides: {}, collapsed: []) ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 16 17 |
# File 'lib/mosaik/configuration.rb', line 10 def initialize(directory:, load_paths: [], includes: [], excludes: [], overrides: {}, collapsed: []) @directory = directory @load_paths = load_paths @includes = includes @excludes = excludes @overrides = overrides @collapsed = collapsed end |
Instance Attribute Details
#collapsed ⇒ Object (readonly)
Returns the value of attribute collapsed.
8 9 10 |
# File 'lib/mosaik/configuration.rb', line 8 def collapsed @collapsed end |
#excludes ⇒ Object (readonly)
Returns the value of attribute excludes.
8 9 10 |
# File 'lib/mosaik/configuration.rb', line 8 def excludes @excludes end |
#includes ⇒ Object (readonly)
Returns the value of attribute includes.
8 9 10 |
# File 'lib/mosaik/configuration.rb', line 8 def includes @includes end |
#load_paths ⇒ Object (readonly)
Returns the value of attribute load_paths.
8 9 10 |
# File 'lib/mosaik/configuration.rb', line 8 def load_paths @load_paths end |
#overrides ⇒ Object (readonly)
Returns the value of attribute overrides.
8 9 10 |
# File 'lib/mosaik/configuration.rb', line 8 def overrides @overrides end |
Class Method Details
.from(file) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mosaik/configuration.rb', line 28 def self.from(file) raise ConfigurationError, "Configuration file not found: #{file}" unless File.exist?(file) configuration = YAML.load_file(file) new( directory: File.dirname(file), load_paths: Array(configuration["load_paths"]), includes: Array(configuration["include"]), excludes: Array(configuration["exclude"]), overrides: configuration["overrides"] || {}, collapsed: Array(configuration["collapsed"]), ) end |
Instance Method Details
#files ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/mosaik/configuration.rb', line 19 def files @files ||= begin included_files = Dir[*load_paths.flat_map { |p| includes.map { |i| File.join(directory, p, i) } }] excluded_files = Dir[*load_paths.flat_map { |p| excludes.map { |e| File.join(directory, p, e) } }] included_files - excluded_files end end |