Class: SimplePuppetForge
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- SimplePuppetForge
- Defined in:
- lib/simple_puppet_forge.rb
Defined Under Namespace
Classes: Module
Instance Method Summary collapse
-
#list_modules(user, mod) ⇒ Object
List modules matching user and module.
-
#modules_dependencies(modules) ⇒ Object
From a list of modules get a list of modules (names) they depend on.
Instance Method Details
#list_modules(user, mod) ⇒ Object
List modules matching user and module
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/simple_puppet_forge.rb', line 50 def list_modules(user, mod) require 'simple_puppet_forge/module' dir = File.join(settings.module_dir, user, mod) begin Dir.entries(dir).select do |e| e.match(/^#{Regexp.escape user}-#{Regexp.escape mod}-.*.tar\.gz$/) end.sort.reverse.collect do |f| path = File.join(dir, f) begin Module.new(path, settings.module_dir) rescue RuntimeError => e logger.error e. nil end end.compact rescue Errno::ENOENT return [] end end |
#modules_dependencies(modules) ⇒ Object
From a list of modules get a list of modules (names) they depend on
45 46 47 |
# File 'lib/simple_puppet_forge.rb', line 45 def modules_dependencies(modules) modules.collect { |m| m.dependencies.collect { |d| d.first } }.flatten.uniq end |