Class: Licensed::Configuration

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

Returns a new instance of Configuration.



246
247
248
249
250
251
252
253
254
255
256
# File 'lib/licensed/configuration.rb', line 246

def initialize(options = {})
  apps = options.delete("apps") || []
  apps << default_options.merge(options) 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"] ||= options["root"] if options["root"] }

  apps = apps.flat_map { |app| self.class.expand_app_source_path(app) }
  @apps = apps.map { |app| AppConfiguration.new(app, options) }
end

Instance Attribute Details

#appsObject (readonly)

An array of the applications in this licensed configuration.



234
235
236
# File 'lib/licensed/configuration.rb', line 234

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.



240
241
242
243
244
# File 'lib/licensed/configuration.rb', line 240

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