exit(1)
end
-specpatt = RbConfig::CONFIG["rubylibdir"].sub(RbConfig::CONFIG["ruby_version"], ".*/specifications/.*\.gemspec$")
+require 'rubygems'
+gem_dir = Gem.respond_to?(:default_dirs) ? Gem.default_dirs[:system][:gem_dir] : Gem.path.first
+specpatt = "#{gem_dir}/specifications/.*\.gemspec$"
gems = []
ruby_versioned = false
abi_provide = false
+# as ruby_version may be empty, take version from basename of archdir
+ruby_version = RbConfig::CONFIG["ruby_version"].empty? ? File.basename(RbConfig::CONFIG["archdir"]) : RbConfig::CONFIG["ruby_version"]
for path in $stdin.readlines
# way fugly, but we make the assumption that if the package has
abi_provide = true
ruby_versioned = true
elsif path.match(specpatt)
- ruby_versioned = true
gems.push(path.chomp)
# this is quite ugly and lame, but the assumption made is that if any files
# found in any of these directories specific to this ruby version, the
elsif path.match(RbConfig::CONFIG["archdir"])
ruby_versioned = true
elsif path.match(RbConfig::CONFIG["sitelibdir"])
- ruby_versioned = true
+ ruby_versioned = !RbConfig::CONFIG["ruby_version"].empty?
elsif path.match(RbConfig::CONFIG["sitearchdir"])
ruby_versioned = true
elsif path.match(RbConfig::CONFIG["vendorlibdir"])
- ruby_versioned = true
+ ruby_versioned = !RbConfig::CONFIG["ruby_version"].empty?
elsif path.match(RbConfig::CONFIG["vendorarchdir"])
ruby_versioned = true
end
if requires or abi_provide
abidep = "ruby(abi)"
if ruby_versioned
- abidep += " = %s" % RbConfig::CONFIG["ruby_version"]
+ abidep += " = %s" % ruby_version
end
print abidep + "\n"
end
pessimistic = "rubygem(%s) < %s\n" % [name, Gem::Version.create(version[3..-1]).bump]
version = version.gsub(/\~>/, '=>')
end
- version = version.gsub(/^/, ' ')
+ if version[0..1] == "!="
+ version = version.gsub(/\!=/, '>')
+ end
+ version = version.sub(/^/, ' ')
end
version = "rubygem(%s)%s\n%s" % [name, version, pessimistic]
end