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.
-
.activate_gem(name) ⇒ 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
163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/fake_gem.rb', line 163 def gems unless @gems @gems = [] paths.each do |location| Dir.glob("#{location}/*/fake_gem").each do |gem_spec_file| @gems << FakeGemSpec.new(gem_spec_file) 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.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/fake_gem.rb', line 122 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 |
.activate_gem(name) ⇒ Object
searches for that path in all libs inside of registered fake_gems and updates $LOAD_PATH if found.
148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/fake_gem.rb', line 148 def activate_gem name found = gems.find{|gem_spec| gem_spec.name && (gem_spec.name == name)} 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
176 177 178 |
# File 'lib/fake_gem.rb', line 176 def clear @paths, @gems = nil end |
.paths(*paths) ⇒ Object
Use it to set location for your fake_gems
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/fake_gem.rb', line 100 def paths *paths paths = paths.first if paths.first.is_a? Array if paths.empty? unless @paths if env_paths = ENV['FAKE_GEM_PATHS'] self.paths = env_paths.split(':') else self.paths = [] end end @paths else self.paths = paths end end |
.paths=(paths) ⇒ Object
116 117 118 |
# File 'lib/fake_gem.rb', line 116 def paths= paths @paths = paths.collect{|l| File. l} end |