[macruby-changes] [3610] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 24 16:24:52 PST 2010


Revision: 3610
          http://trac.macosforge.org/projects/ruby/changeset/3610
Author:   ernest.prabhakar at gmail.com
Date:     2010-02-24 16:24:52 -0800 (Wed, 24 Feb 2010)
Log Message:
-----------
Trimmed Dispatch::Source class method names

Modified Paths:
--------------
    MacRuby/trunk/lib/dispatch/source.rb
    MacRuby/trunk/spec/macruby/library/dispatch/source_spec.rb
    MacRuby/trunk/spec/macruby/tags/macruby/library/dispatch/enumerable_tags.txt

Added Paths:
-----------
    MacRuby/trunk/spec/macruby/tags/macruby/library/dispatch/source_tags.txt

Removed Paths:
-------------
    MacRuby/trunk/spec/macruby/tags/macruby/library/dispatch/queue_source_tags.txt

Modified: MacRuby/trunk/lib/dispatch/source.rb
===================================================================
--- MacRuby/trunk/lib/dispatch/source.rb	2010-02-25 00:24:30 UTC (rev 3609)
+++ MacRuby/trunk/lib/dispatch/source.rb	2010-02-25 00:24:52 UTC (rev 3610)
@@ -3,14 +3,14 @@
 module Dispatch
   class Source
     
-    @@proc_events = {
+    @@procs = {
        exit:PROC_EXIT,
        fork:PROC_FORK,
        exec:PROC_EXEC,
        signal:PROC_SIGNAL
        }
 
-    @@vnode_events = {
+    @@vnodes = {
       delete:VNODE_DELETE,
       write:VNODE_WRITE, 
       extend:VNODE_EXTEND, 
@@ -22,19 +22,19 @@
       
     class << self
       
-      def proc_event(e)
-        convert_event(e, @@proc_events)
+      def proc(e)
+        convert(e, @@procs)
       end
 
-      def vnode_event(e)
-        convert_event(e, @@vnode_events)
+      def vnode(e)
+        convert(e, @@vnodes)
       end
     
       def events2mask(events, hash)
-        mask = events.collect { |e| convert_event(e, hash) }.reduce(:|)
+        mask = events.collect { |e| convert(e, hash) }.reduce(:|)
       end
       
-      def convert_event(e, hash)
+      def convert(e, hash)
         return e.to_i if e.is_a? Numeric
         value = hash[e.to_sym]
         raise ArgumentError, "No event type #{e.inspect}" if value.nil?
@@ -42,47 +42,47 @@
       end
     
 
-      # Returns a Dispatch::Source::DATA_ADD
-      def on_add(queue = Dispatch::Queue.concurrent, &block)
+      # Returns Dispatch::Source of type DATA_ADD
+      def add(queue = Dispatch::Queue.concurrent, &block)
         Dispatch::Source.new(Dispatch::Source::DATA_ADD, 0, 0, queue, &block)
       end
 
-      # Returns a Dispatch::Source::DATA_OR
-      def on_or(queue = Dispatch::Queue.concurrent, &block)
+      # Returns Dispatch::Source of type DATA_OR
+      def or(queue = Dispatch::Queue.concurrent, &block)
         Dispatch::Source.new(Dispatch::Source::DATA_OR, 0, 0, queue, &block)
       end
 
       # Takes events: :delete, :write, :extend, :attrib, :link, :rename, :revoke
-      # Returns a Dispatch::Source::PROC
-      def on_process_event(pid, events, queue = Dispatch::Queue.concurrent, &block)
-        mask = events2mask(events, @@proc_events)
+      # Returns Dispatch::Source of type PROC
+      def process(pid, events, queue = Dispatch::Queue.concurrent, &block)
+        mask = events2mask(events, @@procs)
         Dispatch::Source.new(Dispatch::Source::PROC, pid, mask, queue, &block)
       end
 
-      # Returns a Dispatch::Source::SIGNAL
-      def on_signal(signal, queue = Dispatch::Queue.concurrent, &block)
+      # Returns Dispatch::Source of type SIGNAL
+      def signal(signal, queue = Dispatch::Queue.concurrent, &block)
         signal = Signal.list[signal.to_s] if signal.to_i == 0
         Dispatch::Source.new(Dispatch::Source::SIGNAL, signal, 0, queue, &block)
       end
 
-      # Returns a Dispatch::Source::READ
-      def on_read(file, queue = Dispatch::Queue.concurrent, &block)
+      # Returns Dispatch::Source of type READ
+      def read(file, queue = Dispatch::Queue.concurrent, &block)
         Dispatch::Source.new(Dispatch::Source::READ, file, 0, queue, &block)
       end
 
-      # Returns a Dispatch::Source::WRITE
-      def on_write(file, queue = Dispatch::Queue.concurrent, &block)
+      # Returns Dispatch::Source of type WRITE
+      def write(file, queue = Dispatch::Queue.concurrent, &block)
         Dispatch::Source.new(Dispatch::Source::WRITE, file, 0, queue, &block)
       end
 
       # Takes events: :exit, :fork, :exec, :signal
-      # Returns a Dispatch::Source::VNODE
-      def on_file_event(file, events, queue = Dispatch::Queue.concurrent, &block)
-        mask = events2mask(events, @@vnode_events)
+      # Returns Dispatch::Source of type VNODE
+      def file(file, events, queue = Dispatch::Queue.concurrent, &block)
+        mask = events2mask(events, @@vnodes)
         Dispatch::Source.new(Dispatch::Source::VNODE, file, mask, queue, &block)
       end
 
-      def on_interval(seconds, queue = Dispatch::Queue.concurrent, &block)
+      def interval(seconds, queue = Dispatch::Queue.concurrent, &block)
         Dispatch::Source.timer(0, seconds, 0, queue, &block)
       end
     end

Modified: MacRuby/trunk/spec/macruby/library/dispatch/source_spec.rb
===================================================================
--- MacRuby/trunk/spec/macruby/library/dispatch/source_spec.rb	2010-02-25 00:24:30 UTC (rev 3609)
+++ MacRuby/trunk/spec/macruby/library/dispatch/source_spec.rb	2010-02-25 00:24:52 UTC (rev 3610)
@@ -14,10 +14,10 @@
       @q.sync { }
     end
 
-    describe "on_add" do
+    describe "add" do
       it "fires with data on summed inputs" do
         @count = 0
-        @src = Dispatch::Source.on_add(@q) {|s| @count += s.data}
+        @src = Dispatch::Source.add(@q) {|s| @count += s.data}
         @src << 20
         @src << 22
         @q.sync {}
@@ -25,10 +25,10 @@
       end
     end    
 
-    describe "on_or" do
+    describe "or" do
       it "fires with data on ORed inputs" do
         @count = 0
-        @src = Dispatch::Source.on_or(@q) {|s| @count += s.data}
+        @src = Dispatch::Source.or(@q) {|s| @count += s.data}
         @src << 0b101_000
         @src << 0b000_010
         @q.sync {}
@@ -36,26 +36,26 @@
       end
     end    
 
-    describe "on_process_event" do
+    describe "process" do
       it "fires with data indicating which process event(s)" do
         @signal = Signal.list["USR1"]
         @event = nil
-        @src = Dispatch::Source.on_process_event($$, %w(exit fork exec signal), @q) do 
+        @src = Dispatch::Source.process($$, %w(exit fork exec signal), @q) do 
            |s| @event = s.data
         end
         Signal.trap(@signal, "IGNORE")
         Process.kill(@signal, $$)
         Signal.trap(@signal, "DEFAULT")
         @q.sync {}
-        (@event & Dispatch::Source.proc_event(:signal)).should > 0
+        (@event & Dispatch::Source.proc(:signal)).should > 0
       end
     end
 
-    describe "on_signal" do
+    describe "signal" do
       it "fires with data on how often the process was signaled" do
         @signal = Signal.list["USR1"]
         @count = 0
-        @src = Dispatch::Source.on_signal(@signal, @q) {|s| @count += s.data}
+        @src = Dispatch::Source.signal(@signal, @q) {|s| @count += s.data}
         Signal.trap(@signal, "IGNORE")
         Process.kill(@signal, $$)
         Process.kill(@signal, $$)
@@ -66,7 +66,7 @@
       end
     end    
 
-    describe "file" do
+    describe "vnode" do
       before :each do
         @msg = "#{$$}-#{Time.now}"
         @filename = "/var/tmp/gcd_spec_source-#{@msg}"
@@ -81,24 +81,24 @@
         File.delete(@filename)
       end
 
-      describe "on_read" do
+      describe "read" do
         it "fires with data on how many bytes can be read" do
           File.open(@filename, "w") {|f| f.print @msg}
           @file = File.open(@filename, "r")
           @result = ""
-          @src = Dispatch::Source.on_read(@file, @q) {|s| @result<<@file.read(s.data)}
+          @src = Dispatch::Source.read(@file, @q) {|s| @result<<@file.read(s.data)}
           while (@result.size < @msg.size) do; end
           @q.sync { }
           @result.should == @msg
         end
       end    
 
-      describe "on_write" do
+      describe "write" do
         it "fires with data on how many bytes can be written" do
           @file = File.open(@filename, "w")
           @pos = 0
           @message = @msg
-          @src = Dispatch::Source.on_read(@file, @q) do |s|
+          @src = Dispatch::Source.read(@file, @q) do |s|
             pos = s.data
             if not @message.nil? then
               next_msg = @message[0..pos-1]
@@ -112,12 +112,12 @@
         end
       end
       
-      describe "on_file_event" do
+      describe "file" do
         it "fires with data indicating which file event(s)" do
           @file = File.open(@filename, "w")
           @fired = false
           events = %w(delete write extend attrib link rename revoke)
-          @src = Dispatch::Source.on_file_event(@file, events, @q) do |s|
+          @src = Dispatch::Source.file(@file, events, @q) do |s|
               @flag = s.data
               @fired = true
           end
@@ -126,17 +126,17 @@
           @q.sync { }
           #while (@fired == false) do; end
           @fired.should == true
-          @flag.should == Dispatch::Source.vnode_event(:write)
+          @flag.should == Dispatch::Source.vnode(:write)
         end
       end          
     end
 
-    describe "on_interval" do
+    describe "interval" do
       it "fires with data on how often the timer has fired" do
         @count = -1
         repeats = 2
         @interval = 0.02
-        @src = Dispatch::Source.on_interval(@interval, @q) {|s| @count += s.data}
+        @src = Dispatch::Source.interval(@interval, @q) {|s| @count += s.data}
         sleep repeats*@interval
         @q.sync { }
         @count.should == repeats

Modified: MacRuby/trunk/spec/macruby/tags/macruby/library/dispatch/enumerable_tags.txt
===================================================================
--- MacRuby/trunk/spec/macruby/tags/macruby/library/dispatch/enumerable_tags.txt	2010-02-25 00:24:30 UTC (rev 3609)
+++ MacRuby/trunk/spec/macruby/tags/macruby/library/dispatch/enumerable_tags.txt	2010-02-25 00:24:52 UTC (rev 3610)
@@ -1,2 +0,0 @@
-critical:parallel Enumerable p_map should behave like map
-critical:parallel Enumerable p_find_all should behave like find_all

Deleted: MacRuby/trunk/spec/macruby/tags/macruby/library/dispatch/queue_source_tags.txt
===================================================================
--- MacRuby/trunk/spec/macruby/tags/macruby/library/dispatch/queue_source_tags.txt	2010-02-25 00:24:30 UTC (rev 3609)
+++ MacRuby/trunk/spec/macruby/tags/macruby/library/dispatch/queue_source_tags.txt	2010-02-25 00:24:52 UTC (rev 3610)
@@ -1,3 +0,0 @@
-fails:Dispatch::Queue source from on_process_event fires with data indicating which process event(s)
-fails:Dispatch::Queue source from on_signal fires with data on how often the process was signaled
-fails:Dispatch::Queue source from file on_file_event fires with data indicating which file event(s)

Added: MacRuby/trunk/spec/macruby/tags/macruby/library/dispatch/source_tags.txt
===================================================================
--- MacRuby/trunk/spec/macruby/tags/macruby/library/dispatch/source_tags.txt	                        (rev 0)
+++ MacRuby/trunk/spec/macruby/tags/macruby/library/dispatch/source_tags.txt	2010-02-25 00:24:52 UTC (rev 3610)
@@ -0,0 +1,3 @@
+fails:Dispatch::Source from process fires with data indicating which process event(s)
+fails:Dispatch::Source from signal fires with data on how often the process was signaled
+fails:Dispatch::Source from vnode file fires with data indicating which file event(s)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100224/3483d103/attachment-0001.html>


More information about the macruby-changes mailing list