Module: TerminalCommands
- Defined in:
- lib/bullet_train/terminal_commands.rb
Class Method Summary collapse
- .can_open? ⇒ Boolean
- .linux ⇒ Object
- .linux? ⇒ Boolean
- .macosx ⇒ Object
- .macosx? ⇒ Boolean
- .open_file_or_link(file_or_link, options = {}) ⇒ Object
- .os ⇒ Object
Class Method Details
.can_open? ⇒ 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 |
.linux ⇒ Object
32 33 34 |
# File 'lib/bullet_train/terminal_commands.rb', line 32 def self.linux "linux" end |
.linux? ⇒ Boolean
19 20 21 |
# File 'lib/bullet_train/terminal_commands.rb', line 19 def self.linux? os == linux end |
.macosx ⇒ Object
28 29 30 |
# File 'lib/bullet_train/terminal_commands.rb', line 28 def self.macosx "darwin" end |
.macosx? ⇒ Boolean
15 16 17 |
# File 'lib/bullet_train/terminal_commands.rb', line 15 def self.macosx? os == macosx end |
.open_file_or_link(file_or_link, options = {}) ⇒ Object
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, = {}) command = if macosx? "open" elsif linux? "xdg-open" end `#{command} #{file_or_link}` end |
.os ⇒ Object
11 12 13 |
# File 'lib/bullet_train/terminal_commands.rb', line 11 def self.os Gem::Platform.local.os end |