Created
February 3, 2014 15:47
-
-
Save kostia/8786316 to your computer and use it in GitHub Desktop.
Fast and easy check and test new gems from the CLI.
This file contains 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
#!/usr/bin/env ruby | |
require 'tmpdir' | |
unless gem_name = ARGV.first | |
puts 'Usage: check-gem GEM_NAME' | |
exit 1 | |
end | |
Dir.mktmpdir("check-gem-#{gem_name}") do |tmpdir| | |
open("#{tmpdir}/Gemfile", 'w') do |f| | |
f.puts %{ | |
source 'https://rubygems.org' | |
gem 'pry' | |
gem '#{gem_name}' | |
} | |
end | |
open("#{tmpdir}/test.rb", 'w') do |f| | |
f.puts %{ | |
require 'pry' | |
require '#{gem_name}' | |
binding.pry | |
} | |
end | |
Dir.chdir(tmpdir) do | |
output = `bundle` | |
unless $?.success? | |
puts output | |
exit 1 | |
end | |
exec 'bundle exec ruby test.rb' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment