Class: Frank::MacLauncher

Inherits:
Object
  • Object
show all
Defined in:
lib/frank-cucumber/mac_launcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(app_path) ⇒ MacLauncher

Returns a new instance of MacLauncher.



6
7
8
# File 'lib/frank-cucumber/mac_launcher.rb', line 6

def initialize(app_path)
    @app_path = app_path
end

Instance Method Details

#launchObject



10
11
12
# File 'lib/frank-cucumber/mac_launcher.rb', line 10

def launch
    `open "#{@app_path}"`
end

#quit_if_runningObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/frank-cucumber/mac_launcher.rb', line 14

def quit_if_running
    pid = `ps -ax | grep "#{@app_path}" | grep -v grep`

    if pid != ""
        pid = pid.strip.split[0]
        `kill #{pid}`
    end

    Timeout::timeout(60) {
        while pid != ""
            pid = `ps -ax | grep "#{@app_path}" | grep -v grep`
        end
    }

end

#relaunchObject



30
31
32
33
# File 'lib/frank-cucumber/mac_launcher.rb', line 30

def relaunch
    self.quit_if_running
    self.launch
end