Class: Rutabaga::Util

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

Class Method Summary collapse

Class Method Details

.find_feature(description) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rutabaga/util.rb', line 18

def find_feature(description)
  tried = []

  if description =~ /.*\.(feature|rutabaga)\Z/
    return description if File.exists?(description)
    tried << description

    candidate = File.join(extract_directory, description)
    return candidate if File.exists?(candidate)
    tried << candidate
  else
    feature_files = extract_features
    feature_files.each do |feature_file|
      return feature_file if File.exists?(feature_file)
    end
    tried += feature_files
  end

  raise "Feature file not found. Tried: #{tried.join(', ')}"
end

.require_if_exists(filename) ⇒ Object



39
40
41
42
43
44
# File 'lib/rutabaga/util.rb', line 39

def require_if_exists(filename)
  require filename
rescue LoadError => e
  # Don't hide LoadErrors raised in the spec helper.
  raise unless e.message.include?(filename)
end