Class: Revamp::Filter::PuppetVerToRpmReq

Inherits:
Object
  • Object
show all
Defined in:
lib/revamp/filter/puppetver2rpmreq.rb

Overview

A filter that process Puppet dependency into RPM requirements lines More info: docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#dependencies-in-metadatajson Even more info: robots.thoughtbot.com/rubys-pessimistic-operator

Constant Summary collapse

PUPPETMODULE =
'puppetmodule'
TWIDDLE_WAKKA =
'~>'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePuppetVerToRpmReq

Returns a new instance of PuppetVerToRpmReq.



13
14
15
# File 'lib/revamp/filter/puppetver2rpmreq.rb', line 13

def initialize
  @slugger = Revamp::Mapper::PuppetNameSlugger.new
end

Instance Attribute Details

#slugObject

Returns the value of attribute slug.



11
12
13
# File 'lib/revamp/filter/puppetver2rpmreq.rb', line 11

def slug
  @slug
end

#sluggerObject

Returns the value of attribute slugger.



11
12
13
# File 'lib/revamp/filter/puppetver2rpmreq.rb', line 11

def slugger
  @slugger
end

Instance Method Details

#filter(puppetver) ⇒ Object

Filters a Puppet version

Parameters:

  • Revamp::Model::PuppetDependency (puppetver)

    a puppet dependency object

Returns:

  • String[] a array of puppet compatibile version specs



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/revamp/filter/puppetver2rpmreq.rb', line 20

def filter(puppetver)
  @slug = slugger.map(puppetver.name)
  reqs = []
  requirements = puppetver.version.requirements
  if singular?(requirements)
    reqs += filter_single(requirements.first)
  else
    reqs += filter_many(requirements)
  end
  reqs
end