Skip to content

Instantly share code, notes, and snippets.

@DAddYE
Created January 20, 2012 22:58
Show Gist options
  • Save DAddYE/1650084 to your computer and use it in GitHub Desktop.
Save DAddYE/1650084 to your computer and use it in GitHub Desktop.
Fix malformed ruby gemspec
#!/usr/bin/env ruby
#
# Usage: curl -sL https://raw.github.com/gist/1650084/invalid.rb | ruby
#
require 'open3'
stdin, stdout, stderr = Open3.popen3('gem check')
invalid = stderr.read
errors = invalid.scan(/\[(.+)\]:/).flatten
abort 'No errors in your gems specs' if errors.empty?
errors.each do |spec|
cmd = "gem install %s" % File.basename(spec, '.gemspec').gsub(/-[0-9\.]+[a-z]?$/) { |m| " -v #{m.sub(/^-/,'')}" }
puts cmd
system "#{cmd} 2> /dev/null"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment