class Puppetfiler::Metadata

Attributes

dependencies[R]
path[R]

Public Class Methods

new(target) click to toggle source
# File lib/puppetfiler/metadata.rb, line 9
def initialize(target)
    @dependencies = {}

    parse target
end

Public Instance Methods

eql?(other) click to toggle source
# File lib/puppetfiler/metadata.rb, line 19
def eql?(other)
    @dependencies.eql?(other.dependencies)
end
fixture(modifiers = {}) click to toggle source
# File lib/puppetfiler/metadata.rb, line 15
def fixture(modifiers = {})
    Puppetfiler::Fixture.fixture(@dependencies, {}, modifiers)
end
updates() click to toggle source
# File lib/puppetfiler/metadata.rb, line 23
def updates
    require 'concurrent'

    updates = {}

    deps = @dependencies.map do |name, dep|
        Concurrent::Future.execute do
            latest = dep.latest

            if not dep.range.cover?(latest)
                updates[name] = {
                    :range  => dep.range,
                    :newest => latest,
                }
            end
        end
    end

    deps.each { |f| f.wait_or_cancel(300) }

    return updates
end

Private Instance Methods

parse(target) click to toggle source
# File lib/puppetfiler/metadata.rb, line 47
def parse(target)
    begin
        json = JSON.load(target)
    rescue JSON::ParserError => error
        STDERR.puts 'Passed metadata is invalid:'
        STDERR.puts error
        return nil
    end

    if not json.has_key?('dependencies') or json['dependencies'].eql?([])
        warn 'No dependencies found'
        return nil
    end

    json['dependencies'].each do |hash|
        @dependencies[hash['name']] = Puppetfiler::Mod.new(hash)
    end
end