Skip to content

Instantly share code, notes, and snippets.

@kostia
Created February 3, 2014 15:47
Show Gist options
  • Save kostia/8786316 to your computer and use it in GitHub Desktop.
Save kostia/8786316 to your computer and use it in GitHub Desktop.
Fast and easy check and test new gems from the CLI.
#!/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