module TurksatkabloCli::OnlineOperations::Helpers

Public Instance Methods

add_line() click to toggle source
# File lib/turksatkablo_cli/online_operations/helpers.rb, line 29
def add_line
  puts "\n"
end
agent() click to toggle source
# File lib/turksatkablo_cli/online_operations/helpers.rb, line 22
 def agent
  unless $agent
    $agent = TurksatkabloCli::OnlineOperations::Agent.new
  end
  $agent
end
check_is_installed?(command, err_msg) click to toggle source
# File lib/turksatkablo_cli/online_operations/helpers.rb, line 41
def check_is_installed?(command, err_msg)
  if which(command)
    true
  else
    abort(err_msg)
  end
end
check_ruby_version(ruby_version = RUBY_VERSION) click to toggle source
# File lib/turksatkablo_cli/online_operations/helpers.rb, line 33
def check_ruby_version(ruby_version = RUBY_VERSION)
  if ruby_version < '2.2.0'
    abort "turksatkablo_cli requires Ruby 2.2.0 or higher"
  else
    ruby_version
  end
end
internet_connection?(host = "8.8.8.8") click to toggle source
# File lib/turksatkablo_cli/online_operations/helpers.rb, line 8
def internet_connection?(host = "8.8.8.8")
  begin
    Net::Ping::External.new(host).ping?
  rescue
    nil
  end
end
require_all(_dir) click to toggle source
# File lib/turksatkablo_cli/online_operations/helpers.rb, line 16
 def require_all(_dir)
  Dir[File.join(_dir, "**/*.rb")].each do |file|
    require file
  end
end
which(command) click to toggle source
# File lib/turksatkablo_cli/online_operations/helpers.rb, line 49
def which(command)
  exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
  ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
    exts.each { |ext|
      exe = File.join(path, "#{command}#{ext}")
      return exe if File.executable?(exe) && !File.directory?(exe)
    }
  end
  return nil
end