Module: FakeGem
- Defined in:
- lib/fake_gem.rb
Defined Under Namespace
Classes: FakeGemSpec
Class Attribute Summary collapse
-
.gems ⇒ Object
list of found false-gems.
Class Method Summary collapse
-
.activate(path) ⇒ Object
searches for that path in all libs inside of registered fake_gems and updates $LOAD_PATH if found.
- .clear ⇒ Object
-
.paths(*paths) ⇒ Object
Use it to set location for your fake_gems.
- .paths=(paths) ⇒ Object
Class Attribute Details
.gems ⇒ Object
list of found false-gems
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/fake_gem.rb', line 106 def gems unless @gems @gems = [] paths.each do |location| Dir.glob("#{location}/*/fake_gem.rb").each do |gem_spec_file| @gems << FakeGemSpec.new(gem_spec_file) unless gem_spec_file =~ /\/fake_gem\/fake_gem\.rb/ end end end @gems end |
Class Method Details
.activate(path) ⇒ Object
searches for that path in all libs inside of registered fake_gems and updates $LOAD_PATH if found.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/fake_gem.rb', line 81 def activate path found = nil catch :found do gems.each do |gem_spec| gem_spec.libs.each do |lib_path| if File.exist? "#{lib_path}/#{path}" found = gem_spec throw :found end end end end if found gems.delete found found.libs.each do |lib_path| $LOAD_PATH << lib_path unless $LOAD_PATH.include? lib_path end true else false end end |
.clear ⇒ Object
119 120 121 |
# File 'lib/fake_gem.rb', line 119 def clear @paths, @gems = nil end |
.paths(*paths) ⇒ Object
Use it to set location for your fake_gems
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/fake_gem.rb', line 59 def paths *paths paths = paths.first if paths.first.is_a? Array if paths.empty? unless @paths if env_paths = ENV['FALSE_GEM_PATH'] self.paths = env_paths.split(':') else self.paths = [] end end @paths else self.paths = paths end end |
.paths=(paths) ⇒ Object
75 76 77 |
# File 'lib/fake_gem.rb', line 75 def paths= paths @paths = paths.collect{|l| File. l} end |