Class: FakeGem::FakeGemSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_gem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ FakeGemSpec

Returns a new instance of FakeGemSpec.



21
22
23
24
25
# File 'lib/fake_gem.rb', line 21

def initialize file
  should_exist file
  @dir, @libs = File.expand_path(File.dirname(file)), []
  instance_eval File.read(file), __FILE__, __LINE__
end

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



20
21
22
# File 'lib/fake_gem.rb', line 20

def dir
  @dir
end

#libs(*args) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fake_gem.rb', line 27

def libs *args
  if args.empty?
    @libs
  else
    args = args.first if args.first.is_a? Array
    args = args.collect do |d| 
      d = d.to_s
      d = (d =~ /^\//) ? d : "#{dir}/#{d}"
      should_exist d
      d            
    end
    @libs.push *args
  end
end

Instance Method Details

#inspectObject Also known as: to_s



43
44
45
46
# File 'lib/fake_gem.rb', line 43

def inspect
  relative_libs = @libs.collect{|l| l.sub("#{@dir}/", '')}
  "fake gem #{@dir} (#{relative_libs.join(', ')})"        
end