Class: GameDigHelper
- Inherits:
-
Object
- Object
- GameDigHelper
- Defined in:
- lib/game_dig/game_dig_helper.rb
Class Method Summary collapse
-
.cli_installed? ⇒ Boolean
Check if gamedig cli is installed globally.
-
.node_service_running? ⇒ Boolean
—————————————————————————————————-.
-
.stop_node_service ⇒ Object
—————————————————————————————————-.
-
.which(cmd) ⇒ Object
—————————————————————————————————-.
Class Method Details
.cli_installed? ⇒ Boolean
Check if gamedig cli is installed globally
29 30 31 |
# File 'lib/game_dig/game_dig_helper.rb', line 29 def self.cli_installed?() !!(which 'gamedig') end |
.node_service_running? ⇒ Boolean
8 9 10 |
# File 'lib/game_dig/game_dig_helper.rb', line 8 def self.node_service_running? port_open? '127.0.0.1', 24445 end |
.stop_node_service ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/game_dig/game_dig_helper.rb', line 14 def self.stop_node_service begin uri = URI("http://127.0.0.1:24445/exit") res = Net::HTTP.get_response(uri) rescue Errno::ECONNREFUSED => e # will be refused, as /exit closes the server and makes no more response end end |
.which(cmd) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/game_dig/game_dig_helper.rb', line 35 def self.which(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each do |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable?(exe) && !File.directory?(exe) end end nil end |