Class: ImageOptim::BinResolver
- Inherits:
-
Object
- Object
- ImageOptim::BinResolver
- Defined in:
- lib/image_optim/bin_resolver.rb
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 ⇒ BinResolver
constructor
A new instance of BinResolver.
- #resolve!(bin) ⇒ Object
Constructor Details
#initialize ⇒ BinResolver
Returns a new instance of BinResolver.
8 9 10 11 |
# File 'lib/image_optim/bin_resolver.rb', line 8 def initialize @bins = {} @lock = Mutex.new end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
7 8 9 |
# File 'lib/image_optim/bin_resolver.rb', line 7 def dir @dir end |
Instance Method Details
#env_path ⇒ Object
25 26 27 |
# File 'lib/image_optim/bin_resolver.rb', line 25 def env_path [dir, ENV['PATH'], VENDOR_PATH].compact.join(':') end |
#resolve!(bin) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/image_optim/bin_resolver.rb', line 13 def resolve!(bin) bin = bin.to_sym unless @bins.include?(bin) @lock.synchronize do @bins[bin] = resolve?(bin) unless @bins.include?(bin) end end @bins[bin] or raise BinNotFoundError, "`#{bin}` not found" end |