74 lines
2.0 KiB
Diff
74 lines
2.0 KiB
Diff
From e088c6824209d98eccb0f1e6c7e21f26b4a1178d Mon Sep 17 00:00:00 2001
|
|
From: Eric Hodel <drbrain@segment7.net>
|
|
Date: Mon, 6 Jan 2014 14:20:18 -0800
|
|
Subject: [PATCH] Add BasicSpecification#source_paths
|
|
|
|
This allows documentation and analysis tools to retrieve paths of source
|
|
files in gems. This is needed as the introduction of shared gem
|
|
directories means the extension source directory is no longer included
|
|
in require_paths (which was meant for $LOAD_PATH, not source code).
|
|
---
|
|
lib/rubygems/basic_specification.rb | 18 ++++++++++++++++++
|
|
test/rubygems/test_gem_specification.rb | 16 ++++++++++++++++
|
|
2 files changed, 34 insertions(+)
|
|
|
|
diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb
|
|
index a52377f..470a6eb 100644
|
|
--- a/lib/rubygems/basic_specification.rb
|
|
+++ b/lib/rubygems/basic_specification.rb
|
|
@@ -207,6 +207,24 @@ def require_paths
|
|
end
|
|
|
|
##
|
|
+ # Returns the paths to the source files for use with analysis and
|
|
+ # documentation tools. These paths are relative to full_gem_path.
|
|
+
|
|
+ def source_paths
|
|
+ paths = raw_require_paths.dup
|
|
+
|
|
+ if @extensions then
|
|
+ ext_dirs = @extensions.map do |extension|
|
|
+ extension.split(File::SEPARATOR, 2).first
|
|
+ end.uniq
|
|
+
|
|
+ paths.concat ext_dirs
|
|
+ end
|
|
+
|
|
+ paths.uniq
|
|
+ end
|
|
+
|
|
+ ##
|
|
# Return a Gem::Specification from this gem
|
|
|
|
def to_spec
|
|
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
|
|
index 46db0c4..b72a5d1 100644
|
|
--- a/test/rubygems/test_gem_specification.rb
|
|
+++ b/test/rubygems/test_gem_specification.rb
|
|
@@ -1809,6 +1809,22 @@ def test_source
|
|
assert_kind_of Gem::Source::Installed, @a1.source
|
|
end
|
|
|
|
+ def test_source_paths
|
|
+ ext_spec
|
|
+
|
|
+ @ext.require_paths = %w[lib ext foo]
|
|
+ @ext.extensions << 'bar/baz'
|
|
+
|
|
+ expected = %w[
|
|
+ lib
|
|
+ ext
|
|
+ foo
|
|
+ bar
|
|
+ ]
|
|
+
|
|
+ assert_equal expected, @ext.source_paths
|
|
+ end
|
|
+
|
|
def test_full_require_paths
|
|
ext_spec
|
|
|
|
--
|
|
1.8.5.1
|
|
|