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
-
#around_command {|env| ... } ⇒ Object
Wraps the execution of commands on this source’s packages, letting the source enhance the surrounding process (e.g. Bundler isolation) and contribute environment variables to the command.
- #each ⇒ 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
42 43 44 45 46 |
# File 'lib/cobra_commander/source.rb', line 42 def self.load(path, config = nil, **selector) select(**selector).map do |source| source.new(path, config&.dig(source.key)) end end |
Instance Method Details
#around_command {|env| ... } ⇒ Object
Wraps the execution of commands on this source’s packages, letting the source enhance the surrounding process (e.g. Bundler isolation) and contribute environment variables to the command. The base implementation yields an empty env; plugins override it (see CobraCommander::Ruby::Bundle).
32 33 34 |
# File 'lib/cobra_commander/source.rb', line 32 def around_command yield({}) end |
#each ⇒ Object
36 37 38 39 40 |
# File 'lib/cobra_commander/source.rb', line 36 def each(&) packages.each(&) 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 |