Class: Licensed::Configuration
- Inherits:
-
Object
- Object
- Licensed::Configuration
- Defined in:
- lib/licensed/configuration.rb
Defined Under Namespace
Classes: LoadError
Constant Summary collapse
- DEFAULT_CONFIG_FILES =
[ ".licensed.yml".freeze, ".licensed.yaml".freeze, ".licensed.json".freeze ].freeze
Instance Attribute Summary collapse
-
#apps ⇒ Object
readonly
An array of the applications in this licensed configuration.
Class Method Summary collapse
-
.load_from(path) ⇒ Object
Loads and returns a Licensed::Configuration object from the given path.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(options = {}) ⇒ Configuration
Returns a new instance of Configuration.
276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/licensed/configuration.rb', line 276 def initialize( = {}) @options = apps = .delete("apps") || [] apps << .merge() if apps.empty? # apply a root setting to all app configurations so that it's available # when expanding app source paths apps.each { |app| app["root"] ||= ["root"] if ["root"] } apps = apps.flat_map { |app| self.class.(app) } @apps = apps.map { |app| AppConfiguration.new(app, ) } end |
Instance Attribute Details
#apps ⇒ Object (readonly)
An array of the applications in this licensed configuration.
264 265 266 |
# File 'lib/licensed/configuration.rb', line 264 def apps @apps end |
Class Method Details
.load_from(path) ⇒ Object
Loads and returns a Licensed::Configuration object from the given path. The path can be relative or absolute, and can point at a file or directory. If the path given is a directory, the directory will be searched for a ‘config.yml` file.
270 271 272 273 274 |
# File 'lib/licensed/configuration.rb', line 270 def self.load_from(path) config_path = Pathname.pwd.join(path) config_path = find_config(config_path) if config_path.directory? Configuration.new(parse_config(config_path)) end |
Instance Method Details
#[](key) ⇒ Object
289 290 291 |
# File 'lib/licensed/configuration.rb', line 289 def [](key) @options&.fetch(key, nil) end |