Skip to content

Instantly share code, notes, and snippets.

@mjc
Created July 30, 2013 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjc/6114889 to your computer and use it in GitHub Desktop.
Save mjc/6114889 to your computer and use it in GitHub Desktop.
trying to add fake extension to activemerchant to allow conditionally requiring nokogiri based on ruby version at gem install time
index 652e40c..233d9df 100644
--- a/activemerchant.gemspec
+++ b/activemerchant.gemspec
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
s.homepage = 'http://activemerchant.org/'
s.rubyforge_project = 'activemerchant'
- s.files = Dir['CHANGELOG', 'README.md', 'MIT-LICENSE', 'CONTRIBUTORS', 'gem-public_cert.pem', 'lib/**/*', 'vendor/**/*']
- s.require_path = 'lib'
+ s.files = Dir['CHANGELOG', 'README.md', 'MIT-LICENSE', 'CONTRIBUTORS', 'gem-public_cert.pem', 'lib/**/*', 'vendor/**/*', 'ext/nokogiri_conf.rb']
+ s.require_paths = ['lib', 'ext']
s.has_rdoc = true if Gem::VERSION < '1.7.0'
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.add_dependency('builder', '>= 2.0.0')
s.add_dependency('json', '>= 1.5.1')
s.add_dependency('active_utils', '>= 1.0.2')
- s.add_dependency('nokogiri', "< 1.6.0")
+ s.extensions = ['ext/nokogiri_conf.rb']
s.add_development_dependency('rake')
s.add_development_dependency('mocha', '~> 0.13.0')
require 'rubygems'
require 'rubygems/command.rb'
require 'rubygems/dependency_installer.rb'
begin
Gem::Command.build_args = ARGV
rescue NoMethodError
end
inst = Gem::DependencyInstaller.new
begin
if RUBY_VERSION < "1.9"
inst.install "nokogiri", "< 0.6.0"
else
inst.install "nokogiri", "~> 0.6.0"
end
rescue
exit(1)
end
f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w") # create dummy rakefile to indicate success
f.write("task :default\n")
f.close
$ gem build activemerchant.gemspec && gem install ./activemerchant-1.35.1.gem
WARNING: licenses is empty
Successfully built RubyGem
Name: activemerchant
Version: 1.35.1
File: activemerchant-1.35.1.gem
Building native extensions. This could take a while...
ERROR: Error installing ./activemerchant-1.35.1.gem:
ERROR: Failed to build gem native extension.
No builder for extension 'ext/nokogiri_conf.rb'
Gem files will remain installed in $MY_GEMS_DIR/activemerchant-1.35.1 for inspection.
Results logged to $MY_GEMS_DIR/activemerchant-1.35.1/ext/gem_make.out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment