Class: ImageOptim::BinResolver
- Inherits:
-
Object
- Object
- ImageOptim::BinResolver
- Defined in:
- lib/image_optim/bin_resolver.rb
Defined Under Namespace
Classes: Bin
Constant Summary collapse
- VENDOR_PATH =
File.('../../../vendor', __FILE__)
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Instance Method Summary collapse
- #env_path ⇒ Object
-
#initialize(image_optim) ⇒ BinResolver
constructor
A new instance of BinResolver.
- #resolve!(name) ⇒ Object
Constructor Details
#initialize(image_optim) ⇒ BinResolver
Returns a new instance of BinResolver.
21 22 23 24 25 |
# File 'lib/image_optim/bin_resolver.rb', line 21 def initialize(image_optim) @image_optim = image_optim @bins = {} @lock = Mutex.new end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
20 21 22 |
# File 'lib/image_optim/bin_resolver.rb', line 20 def dir @dir end |
Instance Method Details
#env_path ⇒ Object
46 47 48 |
# File 'lib/image_optim/bin_resolver.rb', line 46 def env_path [dir, ENV['PATH'], VENDOR_PATH].compact.join(':') end |
#resolve!(name) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/image_optim/bin_resolver.rb', line 27 def resolve!(name) name = name.to_sym resolving(name) do if bin = resolve?(name) && Bin.new(name, version(name)) $stderr << "Resolved #{bin}\n" if @image_optim.verbose? end @bins[name] = bin end if @bins[name] check!(@bins[name]) else raise BinNotFoundError, "`#{name}` not found" end end |