Class: Zucchini::Detector

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/zucchini/detector.rb

Direct Known Subclasses

Approver, Runner

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#featuresObject (readonly)

Returns the value of attribute features.



2
3
4
# File 'lib/zucchini/detector.rb', line 2

def features
  @features
end

Instance Method Details

#detect_features(path) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/zucchini/detector.rb', line 23

def detect_features(path)
  features = []
  if File.exists?("#{path}/feature.zucchini")
    features << Zucchini::Feature.new(path)
  else
    raise detection_error(path) if Dir["#{path}/*"].empty?

    Dir.glob("#{path}/*").each do |dir|
        unless dir.match /support/
        if File.exists?("#{dir}/feature.zucchini")
          features << Zucchini::Feature.new(dir)
        else
          raise detection_error(dir)
        end
      end
    end
  end
  features
end

#detection_error(path) ⇒ Object



43
44
45
# File 'lib/zucchini/detector.rb', line 43

def detection_error(path)
  "#{path} is not a feature directory"
end

#executeObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/zucchini/detector.rb', line 6

def execute
  raise "Directory #{path} does not exist" unless File.exists?(path)

  @path = File.expand_path(path)
  Zucchini::Config.base_path = File.exists?("#{path}/feature.zucchini") ? File.dirname(path) : path

  @device = Zucchini::Config.device(ENV['ZUCCHINI_DEVICE'])

  exit run_command
end

#run_commandObject



17
# File 'lib/zucchini/detector.rb', line 17

def run_command; end