Class: Blacksmith::Executable
- Inherits:
-
Object
- Object
- Blacksmith::Executable
- Includes:
- Singleton
- Defined in:
- lib/blacksmith/executable.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.method_missing(name, *args, &block) ⇒ Object
6 7 8 |
# File 'lib/blacksmith/executable.rb', line 6 def method_missing(name, *args, &block) instance.send(name, *args, &block) end |
Instance Method Details
#check_dependency! ⇒ Object
29 30 31 |
# File 'lib/blacksmith/executable.rb', line 29 def check_dependency! raise Blacksmith::DependencyMissing, "#{executable} not installed" unless installed? end |
#executable ⇒ Object
12 13 14 |
# File 'lib/blacksmith/executable.rb', line 12 def executable raise NotImplementedError, "#{self.class} is expected to implement #executable" end |
#installed? ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/blacksmith/executable.rb', line 16 def installed? @installed unless @installed.nil? paths = ENV['PATH'].split(File::PATH_SEPARATOR) extensions = ENV['PATHEXT'] ? ENV['PATHEXT'].split(File::PATH_SEPARATOR) : [''] @installed = !!paths.find do |path| extensions.find do |ext| File.executable?(File.join(path, "#{executable}#{ext}")) end end end |