Sha256: e577a12fc25dc4a27c034ffde69b8d238fd54bb005cefec6cd208b4b1bf33e19

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

#!/usr/bin/env ruby
# coding: utf-8

module Cuesmash
  #
  # Provides an interface for starting the appium server
  #
  # @author [jarod]
  #
  class AppiumServer
    # Public: the output directory for the tests
    attr_accessor :output

    # Public: the output format for the tests
    attr_accessor :format

    #
    # Create a new instance of AppiumServer
    #
    def initialize
    end

    #
    # Run the appium server
    #
    def start_server
      started

      command = 'appium --log-level debug'

      @stdin, @stdout, @stderr, @wait_thr = Open3.popen3(command)
      Logger.info "Appium running with pid: #{@wait_thr.pid}"

      if Logger.debug?
        [@stdout, @stderr].each do |stream|
          Thread.new do
            until (line = stream.gets).nil?
              Logger.debug line
            end
          end
        end
      end
    end

    #
    # Stop the appium server
    #
    def stop_server
      Process.kill('INT', @wait_thr.pid)
      @stdin.close
      @stdout.close
      @stderr.close

      completed
    end

    private

    #
    # Output a nice message for starting
    #
    def started
      Logger.info 'Starting Appium Server'
    end

    #
    # Output a nice message for completing
    #
    def completed
      Logger.info 'Stopping Appium server 👌'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cuesmash-0.3.0 lib/cuesmash/appium_server.rb
cuesmash-0.2.0.0 lib/cuesmash/appium_server.rb
cuesmash-0.1.9.9 lib/cuesmash/appium_server.rb
cuesmash-0.1.9.8 lib/cuesmash/appium_server.rb