Class: Termup::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/termup/base.rb

Direct Known Subclasses

Iterm, Terminal

Instance Method Summary collapse

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

#startObject



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 = "    var app = Application(\#{@process.pid});\n    var se = Application('System Events');\n    app.activate();\n    \#{@lines.join(\";\\n\")}\n  JS\n  ExecJS.exec script\n\nrescue ExecJS::RuntimeError => e\n  script.split(\"\\n\").each.with_index do |line, i|\n    index = (i+1).to_s.rjust(3)\n    puts \"\#{index}: \#{line}\"\n  end\n  puts e.message\nend\n".gsub(/^\s+/, '')