Module: Finder::Find::Gem
- Includes:
- Base
- Defined in:
- lib/finder/gem.rb
Overview
RubyGems finder methods.
Instance Method Summary collapse
-
#data_path(match, options = {}) ⇒ Array<String>
Search gem data paths.
-
#load_path(match, options = {}) ⇒ Array<String>
Search gem load paths.
-
#path(match, options = {}) ⇒ Array<String>
Search gems.
- #specifications(options) ⇒ Object private
Methods included from Base
#append_extensions, #feature, included, #valid_load_options
Instance Method Details
#data_path(match, options = {}) ⇒ Array<String>
Search gem data paths.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/finder/gem.rb', line 95 def data_path(match, ={}) specs = specifications() matches = [] specs.each do |spec| list = [] glob = File.join(spec.full_gem_path, 'data', match) list = Dir[glob] #.map{ |f| f.untaint } list = list.map{ |d| d.chomp('/') } matches.concat(list) # activate the library if activate flag spec.activate if [:activate] && !list.empty? end matches end |
#load_path(match, options = {}) ⇒ Array<String>
Search gem load paths.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/finder/gem.rb', line 59 def load_path(match, ={}) = () specs = specifications() matches = [] specs.each do |spec| list = [] spec.require_paths.each do |path| glob = File.join(spec.full_gem_path, path, match) list = Dir[glob] #.map{ |f| f.untaint } list = list.map{ |d| d.chomp('/') } # return relative paths unless absolute flag if [:relative] #not options[:absolute] # the extra '' in File.join adds a '/' to the end of the path list = list.map{ |f| f.sub(File.join(spec.full_gem_path, path, ''), '') } end matches.concat(list) end # activate the library if activate flag spec.activate if [:activate] && !list.empty? end matches end |
#path(match, options = {}) ⇒ Array<String>
Search gems.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/finder/gem.rb', line 23 def path(match, ={}) specs = specifications() matches = [] specs.each do |spec| list = [] glob = File.join(spec.full_gem_path, match) list = Dir[glob] #.map{ |f| f.untaint } list = list.map{ |d| d.chomp('/') } matches.concat(list) # activate the library if activate flag spec.activate if [:activate] && !list.empty? end matches end |
#specifications(options) ⇒ Object (private)
114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/finder/gem.rb', line 114 def specifications() name = [:from] || [:gem] if name criteria = [[:version]].compact begin specs = [::Gem::Specification.find_by_name(name.to_s, *criteria)] rescue ::Gem::LoadError specs = [] end else specs = ::Gem::Specification.current_specs end return specs end |