~db-keen/rush/asterales-prep

« back to all changes in this revision

Viewing changes to lib/rubyunix/commands/builtins.rb

  • Committer: Daniel Brumbaugh Keeney
  • Date: 2008-03-10 02:53:16 UTC
  • Revision ID: devi.webmaster@gmail.com-20080310025316-3220q6hdsfybeyvk
added ruby-lex hack for the time being
added irb parser ( which uses the ruby-lex hack )
In Rakefile, moved sync_dirs out of the rake task into a top-level method
updated test folder to reflect vocab change syntax => parser
added name instance attribute to Rubyunix::Session
added parsers to rubyunix.rb, so they can be changed only in defaults.rb (soon to be replaced with asterales)
added send_directive for parser-independent commands
updated history.rb to new style guidelines
added syntax class attribute to parsers
updated session.rb
updated numerous ui files for style guidelines
fixed bug for Wxw.ttyout.puts( nonstring )

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
module Rubyunix
24
24
module Commands
25
 
 
26
 
  class BuiltinsClass
27
 
    instance_methods.each do |m|
28
 
      undef_method m unless /^__/.match m or m.to_sym == :'respond_to?'
29
 
    end
30
 
  end
31
 
  Builtins = BuiltinsClass.new
 
25
module Builtins
32
26
 
33
27
  def Builtins.exit(*a)
34
28
    Rubyunix.quit ? 0 : 1
63
57
      when 0
64
58
        Rubyunix.ui.ttyout.puts Rubyunix.parser.inspect
65
59
      when 1
66
 
        Rubyunix.parser = eval('Rubyunix::Parsers::' << args[0])
 
60
        new_parser = args[0]
 
61
        begin
 
62
          if new_parser['/'] or new_parser.downcase == new_parser
 
63
            require "rubyunix/parsers/#{new_parser}"
 
64
            Rubyunix.parser = eval(
 
65
              new_parser.split('/').inject('Rubyunix::Parsers::') do |part, total|
 
66
                part.gsub! %r/_\w/ do |old| old[1].upcase; end
 
67
                part.sub!  %r/^\w/ do |old| old.upcase;    end
 
68
                total << '::'
 
69
                total << part
 
70
                nil
 
71
              end
 
72
            )
 
73
          else
 
74
            Rubyunix.parser = eval('Rubyunix::Parsers::' << args[0])
 
75
          end
 
76
        rescue LoadError, NameError => err
 
77
          Rubyunix.ui.ttyerr.puts "unable to change parser (#{err.to_s})"
 
78
        end
67
79
      else
68
80
        raise ArgumentError if args.length > 1
69
81
    end
129
141
 
130
142
end
131
143
end
 
144
end