class Natives::Catalog

Constants

CATALOG_PATH_IN_GEM
WORKING_DIR_CATALOG_DIRNAME

Attributes

name[R]
package_provider[R]
platform[R]
platform_version[R]

Public Class Methods

new(catalog_name, platform, platform_version, package_provider, opts={}) click to toggle source
# File lib/natives/catalog.rb, line 14
def initialize(catalog_name,
               platform, platform_version,
               package_provider,
               opts={})

  @name = catalog_name.to_s
  @platform = platform.to_s
  @platform_version = platform_version.to_s
  @package_provider = package_provider.to_s

  @loader = opts.fetch(:loader, Loader.new)
  @working_dir = opts.fetch(:working_dir, Dir.pwd)

  reload
end

Public Instance Methods

native_packages_for(*entry_names) click to toggle source
# File lib/natives/catalog.rb, line 38
def native_packages_for(*entry_names)
  packages = Array(entry_names).flatten.map do |entry_name|
    Selector.new(self.to_hash.fetch(entry_name, {})).
      values_for(@package_provider, @platform, @platform_version)
  end
  packages.flatten.compact
end
reload() click to toggle source
# File lib/natives/catalog.rb, line 30
def reload
  @catalogs = @loader.load_from_paths(catalog_paths)
end
to_hash() click to toggle source
# File lib/natives/catalog.rb, line 34
def to_hash
  @catalogs.fetch(self.name, {})
end

Protected Instance Methods

catalog_paths() click to toggle source
# File lib/natives/catalog.rb, line 48
def catalog_paths
  [
    CATALOG_PATH_IN_GEM,
    File.absolute_path(File.join(@working_dir, WORKING_DIR_CATALOG_DIRNAME))
  ]
end