Skip to content

Instantly share code, notes, and snippets.

@nanliu
Created December 9, 2013 01:50
Show Gist options
  • Save nanliu/7866322 to your computer and use it in GitHub Desktop.
Save nanliu/7866322 to your computer and use it in GitHub Desktop.
# simplify github module convention
def github(name, options = nil)
options ||= {}
options[:user] ||= 'puppetlabs'
options[:version] ||= :master
options[:protocol] ||= 'git'
options[:prefix] ||= case options[:user]
when 'puppetlabs'
'puppetlabs'
when 'VMop', 'vmware'
'vmware'
else
'puppet'
end
options[:repo] ||= case options[:protocol]
when 'git'
"#{options[:protocol]}@github.com:#{options[:user]}/#{options[:prefix]}-#{name}.git"
when 'https'
"#{options[:protocol]}://github.com/#{options[:user]}/#{options[:prefix]}-#{name}.git"
else
raise Error, "Invalid github repo protocol."
end
if options[:version] == :master
# puts name, options[:repo]
mod name, :git => options[:repo]
else
# puts name, options[:repo], options[:version]
mod name, :git => options[:repo] , :ref => options[:version]
end
end
# Puppet Labs modules
github 'stdlib', :version => '3.2.0'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment