Module: Chitin::Builtins

Extended by:
Builtins
Includes:
Aliases, ExecutableBinaries, Prompts
Included in:
Builtins
Defined in:
lib/chitin/commands/builtins.rb

Defined Under Namespace

Modules: Aliases, ExecutableBinaries, Prompts

Constant Summary

Constants included from ExecutableBinaries

ExecutableBinaries::COMMANDS, ExecutableBinaries::PRIORITY_METHODS

Instance Method Summary collapse

Methods included from ExecutableBinaries

#lookup, #method_missing, #path_for_exec, #raw_exec

Methods included from Aliases

#all, #c, #cd, #exeunt, #gem, #la, #ll, #p, #pwd, #short_pwd, #to_num, #x

Methods included from Prompts

#last_elapsed, #last_elapsed_formatted, #minimalist_prompt, #prompt, #time_elapsed_working_multiline_prompt

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Chitin::Builtins::ExecutableBinaries

Instance Method Details

#`(*args) ⇒ Object

ruby’s backtick doesn’t chomp off the newline, which makes it more or less useless for piping into other commands



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/chitin/commands/builtins.rb', line 51

def `(*args)
  res = eval args.join

  if Runnable === res
    composed = res | L {|str| str }
    res = composed[:raw_run].chomp
    composed[:wait]
  end

  res.to_s
end

#bind(key, &action) ⇒ Object

interface to Coolline



14
15
16
17
# File 'lib/chitin/commands/builtins.rb', line 14

def bind(key, &action)
  cool = defined?(SESSION) ? SESSION : Coolline
  cool.bind(key, &action)
end

#completion_proc(&block) ⇒ Object



19
20
21
# File 'lib/chitin/commands/builtins.rb', line 19

def completion_proc(&block)
  @completion_proc = block
end

#post_process(label = :default, &block) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/chitin/commands/builtins.rb', line 41

def post_process(label=:default, &block)
  if label == :default
    post_processing[label] << block
  else
    post_processing[label] = block
  end
end

#post_processingObject



35
36
37
38
39
# File 'lib/chitin/commands/builtins.rb', line 35

def post_processing
  @post_processing ||= {:default => []}
  @post_processing.default = Proc.new {|*args| args.size > 1 ? args : args.first }
  @post_processing
end

#pre_process(label = :default, &block) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/chitin/commands/builtins.rb', line 27

def pre_process(label=:default, &block)
  if label == :default
    pre_processing[label] << block
  else
    pre_processing[label] = block
  end
end

#pre_processingObject



23
24
25
# File 'lib/chitin/commands/builtins.rb', line 23

def pre_processing
  @pre_processing ||= {:default => []}
end