Module: TerminalCommands

Defined in:
lib/bullet_train/terminal_commands.rb

Class Method Summary collapse

Class Method Details

.can_open?Boolean

Returns:

  • (Boolean)


23
24
25
26
# File 'lib/bullet_train/terminal_commands.rb', line 23

def self.can_open?
  (TerminalCommands.macosx? && `which open`.present?) ||
    (TerminalCommands.linux? && `which xdg-open`.present?)
end

.linuxObject



32
33
34
# File 'lib/bullet_train/terminal_commands.rb', line 32

def self.linux
  "linux"
end

.linux?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/bullet_train/terminal_commands.rb', line 19

def self.linux?
  os == linux
end

.macosxObject



28
29
30
# File 'lib/bullet_train/terminal_commands.rb', line 28

def self.macosx
  "darwin"
end

.macosx?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/bullet_train/terminal_commands.rb', line 15

def self.macosx?
  os == macosx
end


2
3
4
5
6
7
8
9
# File 'lib/bullet_train/terminal_commands.rb', line 2

def self.open_file_or_link(file_or_link, options = {})
  command = if macosx?
    "open"
  elsif linux?
    "xdg-open"
  end
  `#{command} #{file_or_link}`
end

.osObject



11
12
13
# File 'lib/bullet_train/terminal_commands.rb', line 11

def self.os
  Gem::Platform.local.os
end