From 7bc107d9781eb28a1ec83ad04452ce0eea1ec812 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Fri, 18 Oct 2019 02:13:09 +1030 Subject: [PATCH] Provide enough empty shells that rake-compiler can (partly) work We're currently still not aiming to be able to produce a packaged gem -- but we can fake out the parts rake-compiler needs while it's just trying to set up its rake tasks. The goal is to allow a rake-compiler-using gem (such as Puma) to work in local use, and support `rake compile`, under Gel. Actual packaging for distribution is best left to Bundler & Rubygems. Fixes #77 --- lib/gel/compatibility/bundler/gem_tasks.rb | 0 lib/gel/compatibility/rubygems.rb | 12 ++++++++++++ lib/gel/compatibility/rubygems/package_task.rb | 7 +++++++ lib/gel/direct_gem.rb | 4 ++-- 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 lib/gel/compatibility/bundler/gem_tasks.rb create mode 100644 lib/gel/compatibility/rubygems/package_task.rb diff --git a/lib/gel/compatibility/bundler/gem_tasks.rb b/lib/gel/compatibility/bundler/gem_tasks.rb new file mode 100644 index 0000000..e69de29 diff --git a/lib/gel/compatibility/rubygems.rb b/lib/gel/compatibility/rubygems.rb index 83b6504..83f4457 100644 --- a/lib/gel/compatibility/rubygems.rb +++ b/lib/gel/compatibility/rubygems.rb @@ -32,6 +32,10 @@ class << self include Enumerable end + def self.load(filename) + new(Gel::DirectGem.new(File.dirname(filename), File.basename(filename, ".gemspec"))) + end + def self.find_by_name(name, *requirements) if g = Gel::Environment.find_gem(name, *requirements) new(g) @@ -76,6 +80,14 @@ def require_paths Pathname.new(path).relative_path_from(base).to_s end end + + def platform + nil + end + + def files + [] + end end class DependencyInstaller diff --git a/lib/gel/compatibility/rubygems/package_task.rb b/lib/gel/compatibility/rubygems/package_task.rb new file mode 100644 index 0000000..f52f6fb --- /dev/null +++ b/lib/gel/compatibility/rubygems/package_task.rb @@ -0,0 +1,7 @@ +class Gem::PackageTask + def initialize(*) + end + + def method_missing(*) + end +end diff --git a/lib/gel/direct_gem.rb b/lib/gel/direct_gem.rb index da4d9fc..814d0d7 100644 --- a/lib/gel/direct_gem.rb +++ b/lib/gel/direct_gem.rb @@ -20,10 +20,10 @@ def initialize(root, name, version = nil) info = { bindir: gemspec.bindir || "bin", executables: gemspec.executables, - require_paths: gemspec.require_paths || [gemspec.require_path].compact, + require_paths: gemspec.require_paths || [gemspec.require_path || "lib"].compact, dependencies: gemspec.runtime_dependencies, } - super(root, name, version || Gel::Support::GemVersion.new(gemspec.version).to_s, gemspec.extensions, info) + super(root, name, version || Gel::Support::GemVersion.new(gemspec.version).to_s, nil, info) end end