Module: Gem
- Defined in:
- lib/reverse_require/extensions/rubygems.rb
Class Method Summary collapse
-
.find_files_for(gem, path) ⇒ Object
Find all files that end with the specified path, from within RubyGems that depend on the specified gem.
-
.find_resources(path) ⇒ Object
Find resources that end with the specified path from all RubyGems.
-
.find_resources_for(gem, path) ⇒ Object
Find resources that end with the specified path, from within RubyGems that depend on the specified gem.
Class Method Details
.find_files_for(gem, path) ⇒ Object
Find all files that end with the specified path, from within RubyGems that depend on the specified gem.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/reverse_require/extensions/rubygems.rb', line 8 def self.find_files_for(gem,path) if (spec = Gem.loaded_specs[gem]) version = spec.version else version = nil end deps = Gem.source_index.find_name(gem,version) deps.inject([]) do |paths,dep| paths + dep.dependent_gems.map { |deps| Gem.searcher.matching_files deps.first, path }.flatten end end |
.find_resources(path) ⇒ Object
Find resources that end with the specified path from all RubyGems.
Gem.find_resources 'static/template.erb'
# => [...]
30 31 32 33 34 |
# File 'lib/reverse_require/extensions/rubygems.rb', line 30 def self.find_resources(path) find_files(File.join('..',path)).map do |gem_path| File.(gem_path) end end |
.find_resources_for(gem, path) ⇒ Object
Find resources that end with the specified path, from within RubyGems that depend on the specified gem.
Gem.find_resources_for 'statix', 'static/xsl/page.xsl'
# => [...]
43 44 45 46 47 |
# File 'lib/reverse_require/extensions/rubygems.rb', line 43 def self.find_resources_for(gem,path) find_files_for(gem,File.join('..',path)).map do |gem_path| File.(gem_path) end end |