Class: Ra10ke::Duplicates::Verification

Inherits:
Object
  • Object
show all
Includes:
PuppetfileParser
Defined in:
lib/ra10ke/duplicates.rb

Defined Under Namespace

Classes: Module

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PuppetfileParser

#forge_modules, #git_modules, #modules, #parse_module_args, #process_args

Constructor Details

#initialize(file) ⇒ Verification

Returns a new instance of Verification.



65
66
67
68
69
# File 'lib/ra10ke/duplicates.rb', line 65

def initialize(file)
  file ||= './Puppetfile'
  @puppetfile = File.expand_path(file)
  abort("Puppetfile does not exist at #{puppetfile}") unless File.readable?(puppetfile)
end

Instance Attribute Details

#puppetfileObject (readonly)

Returns the value of attribute puppetfile.



63
64
65
# File 'lib/ra10ke/duplicates.rb', line 63

def puppetfile
  @puppetfile
end

Instance Method Details

#duplicatesObject



71
72
73
74
75
76
77
# File 'lib/ra10ke/duplicates.rb', line 71

def duplicates
  to_ret = {}
  modules(puppetfile).each do |mod|
    (to_ret[mod[:name]] ||= []) << Module.new(mod[:namespace], mod[:name], mod[:args])
  end
  to_ret.select { |_k, v| v.count > 1 }
end