Class: Testbeds::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/testbeds/index.rb,
lib/testbeds/index/testbed.rb

Defined Under Namespace

Classes: Testbed

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeIndex

Returns a new instance of Index.



13
14
15
16
17
18
19
# File 'lib/testbeds/index.rb', line 13

def initialize
  @store_in = "testbeds"
  @beds = []
  raise "no Bedfile found" unless file = find_index_file
  src = File.read file
  eval src, binding, file
end

Instance Attribute Details

#bedsObject (readonly)

Returns the value of attribute beds.



3
4
5
# File 'lib/testbeds/index.rb', line 3

def beds
  @beds
end

Instance Method Details

#find_index_file(base_path = Pathname.new('.')) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/testbeds/index.rb', line 5

def find_index_file base_path = Pathname.new('.')
  path = File.expand_path(base_path.join('Bedfile'))
  return path if File.file?(path)
  # if we hit root, there is no Bedfile
  return nil if path =~ /:\\Bedfile/ or path =~ /^\/Bedfile/
  find_index_file base_path.join('..')
end

#store_in(dest) ⇒ Object



27
28
29
# File 'lib/testbeds/index.rb', line 27

def store_in dest
  @store_in = dest
end

#testbeds(&block) ⇒ Object Also known as: testbed



21
22
23
# File 'lib/testbeds/index.rb', line 21

def testbeds &block
  @beds.concat Testbeds::Index::Testbed.new(@store_in, &block).flatten
end