Module: Yarsh::InstanceMethods

Included in:
Shell
Defined in:
lib/yarsh/instance_methods.rb

Constant Summary collapse

SEVERITIES =
%w[DEBUG INFO WARN ERROR FATAL UNKNOWN]

Instance Method Summary collapse

Instance Method Details

#__sh__(command) ⇒ Object

Executes a shell line from inside a multiline Ruby buffer. Shell lines are rewritten to sh(...) by Yarsh::Multiline.transform.

Raises:



13
14
15
16
17
18
# File 'lib/yarsh/instance_methods.rb', line 13

def __sh__(command)
  shell = Yarsh.current_shell
  raise Error, 'No active Yarsh shell' if shell.nil?

  shell.send(:__sh_exec, command)
end

#__yarsh__(exp, binding = nil) ⇒ Object

Raises:



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/yarsh/instance_methods.rb', line 20

def __yarsh__(exp, binding = nil)
  shell = Yarsh.current_shell
  raise Error, 'No active Yarsh shell' if shell.nil?

  current_bind = nil
  if binding
    current_bind = shell.bind
    shell.bind = binding
  end
  result = shell.send(:yarsh_eval, exp)
  shell.bind = current_bind if binding
  result
end

#configure(&block) ⇒ Object



38
39
40
# File 'lib/yarsh/instance_methods.rb', line 38

def configure(&block)
  block.call(Config.instance)
end

#sh_alias(new_name, command) ⇒ Object



7
8
9
# File 'lib/yarsh/instance_methods.rb', line 7

def sh_alias(new_name, command)
  Config.instance.add_alias(new_name, command)
end

#source(filename) ⇒ Object



34
35
36
# File 'lib/yarsh/instance_methods.rb', line 34

def source(filename)
  load(filename, Yarsh::InstanceMethods)
end