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
Overview
Handles resolving binaries and checking versions
If there is an environment variable XXX_BIN when resolbing xxx, then a symlink to binary will be created in a temporary directory which will be added to PATH
Defined Under Namespace
Classes: BadBinVersion, Bin, BinNotFound, ComparableCondition, Error, 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
31 32 33 34 35 |
# File 'lib/image_optim/bin_resolver.rb', line 31 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.
30 31 32 |
# File 'lib/image_optim/bin_resolver.rb', line 30 def dir @dir end |
Instance Method Details
#env_path ⇒ Object
57 58 59 |
# File 'lib/image_optim/bin_resolver.rb', line 57 def env_path [dir, ENV['PATH'], VENDOR_PATH].compact.join(':') end |
#resolve!(name) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/image_optim/bin_resolver.rb', line 37 def resolve!(name) name = name.to_sym resolving(name) do bin = Bin.new(name, version(name)) if resolve?(name) if bin && @image_optim.verbose $stderr << "Resolved #{bin}\n" end @bins[name] = bin end if @bins[name] check!(@bins[name]) else fail BinNotFound, "`#{name}` not found" end end |