Commits

seydar  committed 382d50b Draft

command suspension (maybe) and Array#to_hash

  • Participants
  • Parent commits ce1dc83

Comments (0)

Files changed (2)

 *   post_processing for shell commands
     -> make it asynchronous and use pipes
 *   ability to 'neuter' a command, so that it won't automatically be run
+    -> i think i just did this in a commit (6/11/13)
 
 QUIRKS:
 *   menu doesn't erase itself sometimes
 FAILURES:
 *   slashes in filenames
 *   `include Math; sin(5)` fails
+*   too many open pipes
+    -> don't close them in the first place
+*   unable to do "STDIN > ls > NULLOUT ^ NULLERR"
 
 Questions:
 *   Why do you have to do @line = '' in Coolline in order to not affect the

File lib/chitin/commands/executable.rb

 
       @path = path
       @args = process_args(args)
+      @suspended = false
     end
   
     # EVERYTHING will be sent to the command. ERRTHANG!!!!
     def method_missing(name, *arr, &blk)
-      setup name.to_s, *process_args(arr)
-      self
+      if @suspended
+        super(name, *arr, &blk)
+      else
+        setup name.to_s, *process_args(arr)
+        self
+      end
     end
 
     private
       end
     end
 
+    # Make it so you can treat it like a normal object.
+    # This stops method forwarding
+    def suspend
+      @suspended_methods = private_methods.dup
+      @suspended_methods.each {|m| public m }
+
+      @suspended = true
+    end
+
+    def unsuspend
+      @suspended_methods.each {|m| private m }
+      @suspended_methods = []
+      @suspended = false
+    end
+
     def inspect
       "#<Chitin::Executable #{super}>"
     end