Class: Ra10ke::Deprecation::Validation
- Inherits:
-
Object
- Object
- Ra10ke::Deprecation::Validation
- Includes:
- PuppetfileParser
- Defined in:
- lib/ra10ke/deprecation.rb
Instance Attribute Summary collapse
-
#puppetfile ⇒ Object
readonly
Returns the value of attribute puppetfile.
Instance Method Summary collapse
-
#bad_mods? ⇒ Boolean
-
true if there are any bad mods.
-
-
#deprecated_modules ⇒ Array[Hash]
Array of module information and git status.
-
#initialize(file) ⇒ Validation
constructor
A new instance of Validation.
-
#sorted_mods ⇒ Hash
-
sorts the mods based on good/bad.
-
Methods included from PuppetfileParser
#forge_modules, #git_modules, #modules, #parse_module_args, #process_args
Constructor Details
#initialize(file) ⇒ Validation
Returns a new instance of Validation.
34 35 36 37 38 |
# File 'lib/ra10ke/deprecation.rb', line 34 def initialize(file) file ||= './Puppetfile' @puppetfile = File.(file) abort("Puppetfile does not exist at #{puppetfile}") unless File.readable?(puppetfile) end |
Instance Attribute Details
#puppetfile ⇒ Object (readonly)
Returns the value of attribute puppetfile.
32 33 34 |
# File 'lib/ra10ke/deprecation.rb', line 32 def puppetfile @puppetfile end |
Instance Method Details
#bad_mods? ⇒ Boolean
Returns - true if there are any bad mods.
63 64 65 |
# File 'lib/ra10ke/deprecation.rb', line 63 def bad_mods? deprecated_modules.any? end |
#deprecated_modules ⇒ Array[Hash]
Returns array of module information and git status.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ra10ke/deprecation.rb', line 41 def deprecated_modules @deprecated_modules ||= begin deprecated = forge_modules(puppetfile).map do |mod| # For Ruby 2.4 support begin # rubocop:disable Style/RedundantBegin module_name = "#{mod[:namespace] || mod[:name]}-#{mod[:name]}" forge_data = PuppetForge::Module.find(module_name) next forge_data if forge_data.deprecated_at nil rescue Faraday::ResourceNotFound nil end end deprecated.compact.map do |mod| { name: mod.slug, deprecated_at: Time.parse(mod.deprecated_at) } end end end |
#sorted_mods ⇒ Hash
Returns - sorts the mods based on good/bad.
68 69 70 |
# File 'lib/ra10ke/deprecation.rb', line 68 def sorted_mods deprecated_modules.sort_by { |a| a[:name] } end |