Skip to content

Instantly share code, notes, and snippets.

@zaphod42
Created August 2, 2012 16:45
Show Gist options
  • Select an option

  • Save zaphod42/3238593 to your computer and use it in GitHub Desktop.

Select an option

Save zaphod42/3238593 to your computer and use it in GitHub Desktop.
An example, flexible Gemfile for puppet
source :rubygems
facter_location = ENV['PUPPET_FACTER']
def type_of(location)
case location
when /github/
:git
else
:path
end
end
def url_of(location)
if location =~ /(.*)#?/
$1
end
end
def branch_of(location)
if location =~ /.*#(.*)/
$1
else
"master"
end
end
def source_location_of(location)
type = type_of(location)
case type
when :git
{ :git => url_of(location), :branch => branch_of(location) }
when :path
{ :path => location }
else
raise "Unknown location type: #{type}"
end
end
gem "rspec", "~> 2.11.0"
gem "mocha", "0.10.5"
gem "rack", "1.1.0"
gem "rake"
gem "ramcrest", source_location_of("https://github.com/hamcrest/ramcrest.git")
gem "facter", "2.0.0", source_location_of(facter_location)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment