module PoiseLanguages::Static::Mixin::ClassMethods

Attributes

static_machines[RW]
static_name[RW]
static_retries[RW]
static_strip_components[RW]
static_url[RW]
static_versions[RW]

Public Instance Methods

default_inversion_options(node, resource) click to toggle source

Set some default inversion provider options. Package name can't get a default value here because that would complicate the handling of {system_package_candidates}.

@api private

Calls superclass method
# File lib/poise_languages/static/mixin.rb, line 78
def default_inversion_options(node, resource)
  super.merge({
    # Path to install the package. Defaults to /opt/name-version.
    path: nil,
    # Number of times to retry failed downloads.
    retries: static_retries,
    # Full version number for use in interpolation.
    static_version: static_version(node, resource),
    # Value to pass to tar --strip-components.
    strip_components: static_strip_components,
    # URL template to download from.
    url: static_url,
  })
end
included(klass) click to toggle source
Calls superclass method
# File lib/poise_languages/static/mixin.rb, line 129
def included(klass)
  super
  klass.extend ClassMethods
end
provides_auto?(node, resource) click to toggle source
# File lib/poise_languages/static/mixin.rb, line 67
def provides_auto?(node, resource)
  # Check that the version starts with our project name and the machine
  # we are on is supported.
  resource.version.to_s =~ /^#{static_name}(-|$)/ && static_machines.include?(static_machine_label_wrapper(node, resource))
end
static_machine_label(node, _resource=nil) click to toggle source
# File lib/poise_languages/static/mixin.rb, line 114
def static_machine_label(node, _resource=nil)
  "#{node['kernel']['name'].downcase}-#{node['kernel']['machine']}"
end
static_machine_label_wrapper(node, resource) click to toggle source

Wrapper for {#static_machine_label} because I need to add an argument. This preserves backwards compat.

@api private

# File lib/poise_languages/static/mixin.rb, line 122
def static_machine_label_wrapper(node, resource)
  args = [node]
  arity = method(:static_machine_label).arity
  args << resource if arity > 1 || arity < 0
  static_machine_label(*args)
end
static_options(name: nil, versions: [], machines: %w{linux-i686 linux-x86_64}, url: nil, strip_components: 1, retries: 5) click to toggle source
# File lib/poise_languages/static/mixin.rb, line 93
def static_options(name: nil, versions: [], machines: %w{linux-i686 linux-x86_64}, url: nil, strip_components: 1, retries: 5)
  raise PoiseLanguages::Error.new("Static archive URL is required, on #{self}") unless url
  self.static_name = name || provides.to_s
  self.static_versions = versions
  self.static_machines = Set.new(machines)
  self.static_url = url
  self.static_strip_components = strip_components
  self.static_retries = retries
end
static_version(node, resource) click to toggle source
# File lib/poise_languages/static/mixin.rb, line 103
def static_version(node, resource)
  raw_version = resource.version.to_s.gsub(/^#{static_name}(-|$)/, '')
  if static_versions.include?(raw_version)
    raw_version
  else
    # Prefix match or just use the given version number if not found.
    # This allow mild future proofing in some cases.
    static_versions.find {|v| v.start_with?(raw_version) } || raw_version
  end
end