Created
November 12, 2013 10:08
-
-
Save moritzheiber/7428455 to your computer and use it in GitHub Desktop.
Install a ruby gem from git with chef
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # I had to do this once because a ruby gem's newer version wasn't officially released yet | |
| # Thought it might come in handy once again | |
| # Note: You will need to install all the required dependencies to compile/package your gem beforehand, i.e. build-essential/make and friends | |
| include_recipe 'git' | |
| git_repo_url = 'https://some.github.com/repository' | |
| gem_name = 'name_of_my_gem' | |
| tmp_gem_dir = "/tmp/#{gem_name}" | |
| options = '--no-rdoc --no-ri' # usually you don't need those on a chef enabled machine | |
| git tmp_gem_dir do | |
| repository git_repo_url | |
| notifies :run, "execute[build_gem]" | |
| end | |
| execute 'build_gem' do | |
| command "gem build #{gem_name}.gemspec" | |
| cwd tmp_gem_dir | |
| action :nothing | |
| notifies :create, "ruby_block[install_gem]" | |
| end | |
| ruby_block "install_gem" do | |
| block do | |
| gem_path = Dir["#{tmp_gem_dir}/#{gem_name}-?.?.?.gem"].first | |
| system("gem install #{gem_path} #{options}") | |
| end | |
| action :nothing | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment