Class: ImageOptim::BinResolver
- Inherits:
-
Object
- Object
- ImageOptim::BinResolver
- Defined in:
- lib/image_optim/bin_resolver.rb,
lib/image_optim/bin_resolver/simple_version.rb,
lib/image_optim/bin_resolver/comparable_condition.rb
Defined Under Namespace
Classes: Bin, ComparableCondition, SimpleVersion
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.
24 25 26 27 28 |
# File 'lib/image_optim/bin_resolver.rb', line 24 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.
23 24 25 |
# File 'lib/image_optim/bin_resolver.rb', line 23 def dir @dir end |
Instance Method Details
#env_path ⇒ Object
49 50 51 |
# File 'lib/image_optim/bin_resolver.rb', line 49 def env_path [dir, ENV['PATH'], VENDOR_PATH].compact.join(':') end |
#resolve!(name) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/image_optim/bin_resolver.rb', line 30 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 |