Class: Guard::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/frank/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Runner

Returns a new instance of Runner.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/guard/frank/runner.rb', line 4

def initialize(options)
  if options[:project].nil?
    Dir.chdir("..")
    project = Dir.glob("*.xcodeproj").first
    if project
      options[:project] = project.gsub(".xcodeproj","")
    else
      UI.info "You must specify project name at your Guardfile."
    end
  end
  self.bundle_path = bundle(options)
end

Instance Attribute Details

#bundle_pathObject

Returns the value of attribute bundle_path.



3
4
5
# File 'lib/guard/frank/runner.rb', line 3

def bundle_path
  @bundle_path
end

Instance Method Details

#bundle(options) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/guard/frank/runner.rb', line 39

def bundle(options)
  pwd = Dir::pwd
  if File.exists?"Frank"
    Dir.chdir("Frank")
  end
  project = options[:project]
  target = options[:target] || "frankified"
  config = options[:config] || "Debug"
  device = "iphonesimulator"
  bundle_path = "#{pwd}/DerivedData/#{project}/Build/Products/#{config}-#{device}/#{target}.app"
end

#command(features) ⇒ Object



32
33
34
35
36
37
# File 'lib/guard/frank/runner.rb', line 32

def command(features)
  if features.kind_of? Array
    features = features.join(' ')
  end
  "APP_BUNDLE_PATH='#{self.bundle_path}' cucumber #{features} --require features"
end

#run(features) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/guard/frank/runner.rb', line 17

def run(features)
  unless File.exists? self.bundle_path
    UI.info "Could not run Frank. \n'#{self.bundle_path}' not found."
    return false
  end
  if features.eql?("features")
    start_message = "Run all features"
  else
    features = features.join(' ') if features.kind_of? Array
    start_message = "Run #{features}"
  end
  UI.info start_message
  system(command(features))
end