Class: Termup::Base
- Inherits:
-
Object
- Object
- Termup::Base
- Defined in:
- lib/termup/base.rb
Instance Method Summary collapse
-
#initialize(project, process) ⇒ Base
constructor
A new instance of Base.
- #start ⇒ Object
Constructor Details
#initialize(project, process) ⇒ Base
Returns a new instance of Base.
3 4 5 6 7 8 9 |
# File 'lib/termup/base.rb', line 3 def initialize(project, process) @config = YAML.load_file(Termup::Dir.join("#{project}.yml")) @options = @config['options'] || {} @tabs = @config['tabs'] || {} @process = process @lines = [] end |
Instance Method Details
#start ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/termup/base.rb', line 11 def start script = <<-JS.gsub(/^\s+/, '') var app = Application(#{@process.pid}); var se = Application('System Events'); app.activate(); #{@lines.join(";\n")} JS ExecJS.exec script rescue ExecJS::RuntimeError => e script.split("\n").each.with_index do |line, i| index = (i+1).to_s.rjust(3) puts "#{index}: #{line}" end puts e. end |