Class: CobraCommander::Source
- Inherits:
-
Object
- Object
- CobraCommander::Source
- Extended by:
- Registry
- Includes:
- Enumerable
- Defined in:
- lib/cobra_commander/source.rb
Constant Summary collapse
- Error =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(path, config) ⇒ Source
constructor
A new instance of Source.
- #to_ary ⇒ Object
Methods included from Registry
Constructor Details
#initialize(path, config) ⇒ Source
Returns a new instance of Source.
15 16 17 18 19 |
# File 'lib/cobra_commander/source.rb', line 15 def initialize(path, config) @path = Pathname.new(path) @config = config || {} super() end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/cobra_commander/source.rb', line 13 def config @config end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
13 14 15 |
# File 'lib/cobra_commander/source.rb', line 13 def path @path end |
Class Method Details
.load(path, config = nil, **selector) ⇒ Object
31 32 33 34 35 |
# File 'lib/cobra_commander/source.rb', line 31 def self.load(path, config = nil, **selector) select(**selector).map do |source| source.new(path, config&.dig(source.key)) end end |
Instance Method Details
#each(&block) ⇒ Object
25 26 27 28 29 |
# File 'lib/cobra_commander/source.rb', line 25 def each(&block) packages.each(&block) rescue Errno::ENOENT => e raise Error, e. end |
#to_ary ⇒ Object
21 22 23 |
# File 'lib/cobra_commander/source.rb', line 21 def to_ary to_a end |