Module: Ren

Extended by:
Parser
Defined in:
lib/rust/parsers/ren.rb

Overview

run_as_ruby is not allowed in Ren

Class Method Summary collapse

Methods included from Parser

run, run_standard

Class Method Details

.check_for_pipes(line) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rust/parsers/ren.rb', line 33

def check_for_pipes(line)
  cmd_parts = (line.match('|') ? line.split('|') : [line] )   # check for pipelining
  # because between the pipes,
  # it's nothing but commands
  
  clean_whitespace!(cmd_parts)
  
  styles = cmd_parts.map do |cmd_part|
    parts = cmd_part.split(' ')
    cmd = parts[0]
    if builtin_commands.include? cmd.strip.to_sym
      :builtin
    else
      :cmd
    end
  end
  [cmd_parts, styles]
end

.clean_whitespace!(parts) ⇒ Object



52
53
54
# File 'lib/rust/parsers/ren.rb', line 52

def clean_whitespace!(parts)
  parts.map! {|p| p.strip }
end

.execute(line) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rust/parsers/ren.rb', line 13

def execute(line)
  (eval(line); return) if line.strip.slice(0).chr =~ /!/
  
  package = check_for_pipes(line)
  p package
  print run_standard(package[0], package[1])
  
  # Gotta catch 'em all
#    rescue NameError => e
#      err "Internal Command Unknown"
rescue ArgumentError => e
  err "Improper use of command syntax"
rescue SyntaxError => e
  err "Incorrect Ruby Grammar"
rescue Errno::ENOENT => e
  err "Command not found"
rescue => e
  raise e
end