Permalink
Browse files

Basic puppet-module tool support

  • Loading branch information...
1 parent d7bbb0b commit 756b4b76c8c1781cb2588cf0e835e48d2eeb56aa @rodjek committed Nov 23, 2011
Showing with 46 additions and 0 deletions.
  1. +1 −0 lib/curtain.rb
  2. +4 −0 lib/curtain/dsl.rb
  3. +41 −0 lib/curtain/source/forge.rb
View
@@ -1,5 +1,6 @@
require 'fileutils'
require 'curtain/source/git'
+require 'curtain/source/forge'
require 'curtain/dsl'
module Curtain
View
@@ -18,6 +18,10 @@ def git(uri, options = {})
source Source::Git.new(options.merge({'uri' => uri}))
end
+ def forge(package, options = {})
+ source Source::Forge.new(options.merge({'package' => package}))
+ end
+
private
def source(obj)
@@ -0,0 +1,41 @@
+module Curtain
+ module Source
+ class Forge
+ def initialize(options)
+ @package = options['package']
+ @name = options['name'] || options['package']
+ @version = options['version']
+ end
+
+ def install
+ install_module
+ end
+
+ private
+
+ def path
+ "modules/#{@name}"
+ end
+
+ def module_tool(command)
+ out = %x{puppet-module #{command}}
+ out
+ end
+
+ def install_module
+ FileUtils.mkdir_p(File.dirname(path))
+ Dir.chdir(File.dirname(path)) do
+ if @version.nil?
+ module_tool "install #{@name} --force"
+ else
+ module_tool "install #{@name} --force --version #{@version}"
+ end
+
+ unless @name == @package
+ FileUtils.mv(@package, @name)
+ end
+ end
+ end
+ end
+ end
+end

0 comments on commit 756b4b7

Please sign in to comment.