Sha256: d09defa602ebd559856ce2b58fc173e36dc0084f9032d7314f5dd42176dd5006

Contents?: true

Size: 805 Bytes

Versions: 9

Compression:

Stored size: 805 Bytes

Contents

module NativesRecipeHelper
  def use_homebrew?
    ::File.exist? '/usr/local/bin/brew'
  end

  def use_apt?
    !which('apt-get').nil?
  end

  def natives_install_list
    node["natives"]["install_list"]
  end

  def current_package_provider
    package_provider = Chef::Platform.find_provider_for_node({
      platform: node[:platform], platform_version: node[:platform_version]},
      ::Chef::Resource::Package.new(""))
    package_provider.to_s.split('::').last.downcase
  end

  def which(cmd)
    paths = (ENV['PATH'].split(::File::PATH_SEPARATOR) + %w(/bin /usr/bin /sbin /usr/sbin))

    paths.each do |path|
      possible = File.join(path, cmd)
      return possible if File.executable?(possible)
    end

    nil
  end
end

class Chef
  class Recipe
    include NativesRecipeHelper
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
natives-0.4.1 chef/cookbooks/natives/libraries/natives_recipe_helper.rb
natives-0.4.0 chef/cookbooks/natives/libraries/natives_recipe_helper.rb
natives-0.3.0 chef/cookbooks/natives/libraries/natives_recipe_helper.rb
natives-0.2.2 chef/cookbooks/natives/libraries/natives_recipe_helper.rb
natives-0.2.1 chef/cookbooks/natives/libraries/natives_recipe_helper.rb
natives-0.2.0 chef-solo/cookbooks/natives/libraries/natives_recipe_helper.rb
natives-0.1.3 chef-solo/cookbooks/natives/libraries/natives_recipe_helper.rb
natives-0.1.2 chef-solo/cookbooks/natives/libraries/natives_recipe_helper.rb
natives-0.1.1 chef-solo/cookbooks/natives/libraries/natives_recipe_helper.rb