Class: Heyterminal::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/heyterminal/parser.rb

Instance Method Summary collapse

Instance Method Details

#add_expression(expression) ⇒ Object



40
41
42
# File 'lib/heyterminal/parser.rb', line 40

def add_expression(expression)
  Heyterminal::Runner.add_expression(expression)
end

#capture(*args) ⇒ Object



27
28
29
30
# File 'lib/heyterminal/parser.rb', line 27

def capture(*args)
  line = Terrapin::CommandLine.new(*args)
  line.run
end

#chdir(to, &block) ⇒ Object



32
33
34
# File 'lib/heyterminal/parser.rb', line 32

def chdir(to, &block)
  Dir.chdir(to, &block)
end

#editor(editor) ⇒ Object



4
5
6
# File 'lib/heyterminal/parser.rb', line 4

def editor(editor)
  Heyterminal::Runner.set_editor(editor)
end

#hey(command) ⇒ Object



23
24
25
# File 'lib/heyterminal/parser.rb', line 23

def hey(command)
  Heyterminal::Runner.run(command)
end

#Hey(command, &block) ⇒ Object



8
9
10
11
# File 'lib/heyterminal/parser.rb', line 8

def Hey(command, &block)
  expression_factory = Cucumber:: CucumberExpressions::ExpressionFactory.new(Cucumber::CucumberExpressions::ParameterTypeRegistry.new)
  add_expression [expression_factory.create_expression(command), block]
end

#home_file_path(*args) ⇒ Object



36
37
38
# File 'lib/heyterminal/parser.rb', line 36

def home_file_path(*args)
  File.join(Dir.home, *args)
end

#run(*args) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/heyterminal/parser.rb', line 13

def run(*args)
  line = Terrapin::CommandLine.new(*args)
  puts Rainbow("[" + line.command + "]").magenta.to_s
  spinner = TTY::Spinner.new
  spinner.auto_spin
  output = line.run
  spinner.stop('Done!')
  puts output
end