<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -69,6 +69,12 @@ receive do |f|
     f.receive_loop
   end
 
+  f.when([:bool, Erl.boolean]) do |bool|
+    debug(:bool, bool, !bool)
+    f.send!([:bool, !bool])
+    f.receive_loop
+  end
+
   f.when([:number, Fixnum]) do |num|
     debug(:number, num, num*2)
     f.send!([:number, num*2])</diff>
      <filename>examples/simple/rerl.rb</filename>
    </modified>
    <modified>
      <diff>@@ -25,6 +25,7 @@ process(Port, i_am_alive) -&gt;
 
   send(Port, test),
   send(Port, {atom, symbol}),
+  send(Port, {bool, true}),
   send(Port, {number, 1}),
   send(Port, {string, &lt;&lt;&quot;reverse&quot;&gt;&gt;}),
   send(Port, {array, [1,2,3]}),</diff>
      <filename>examples/simple/rerl.sh</filename>
    </modified>
    <modified>
      <diff>@@ -21,6 +21,7 @@ require 'erlectricity/encoder'
 require 'erlectricity/port'
 require 'erlectricity/matcher'
 require 'erlectricity/condition'
+require 'erlectricity/conditions/boolean'
 require 'erlectricity/conditions/hash'
 require 'erlectricity/conditions/static'
 require 'erlectricity/conditions/type'</diff>
      <filename>lib/erlectricity.rb</filename>
    </modified>
    <modified>
      <diff>@@ -54,6 +54,10 @@ module Erlectricity
     def hash
       HashCondition.new()
     end
+
+    def boolean
+      BooleanCondition.new()
+    end
   end
 
   extend Conditions</diff>
      <filename>lib/erlectricity/condition.rb</filename>
    </modified>
    <modified>
      <diff>@@ -24,6 +24,7 @@ module Erlectricity
         when Array then write_tuple(obj)
         when String then write_binary(obj)
         when Time then write_any_raw(obj.to_i.divmod(1000000) + [obj.usec])
+        when TrueClass, FalseClass then write_boolean(obj)
         else
           fail(obj)
       end
@@ -45,6 +46,10 @@ module Erlectricity
       out.write(string)
     end
 
+    def write_boolean(bool)
+      write_symbol(bool.to_s.to_sym)
+    end
+
     def write_symbol(sym)
       fail(sym) unless sym.is_a?(Symbol)
       data = sym.to_s</diff>
      <filename>lib/erlectricity/encoder.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,119 +3,112 @@ require File.dirname(__FILE__) + '/test_helper.rb'
 context &quot;When unpacking from a binary stream&quot; do
   setup do
   end
-  
+
   specify &quot;an erlang atom should decode to a ruby symbol&quot; do
     get(&quot;haha&quot;).should == :haha
   end
-  
+
   specify &quot;an erlang number encoded as a small_int (&lt; 255) should decode to a fixnum&quot; do
     get(&quot;0&quot;).should == 0
     get(&quot;255&quot;).should == 255
   end
-  
+
   specify &quot;an erlang number encoded as a int (signed 27-bit number) should decode to a fixnum&quot; do
     get(&quot;256&quot;).should == 256
     get(&quot;#{(1 &lt;&lt; 27) -1}&quot;).should == (1 &lt;&lt; 27) -1
     get(&quot;-1&quot;).should == -1
     get(&quot;#{-(1 &lt;&lt; 27)}&quot;).should == -(1 &lt;&lt; 27)
   end
-  
-  
+
   specify &quot;an erlang number encoded as a small bignum (1 byte length) should decode to fixnum if it can&quot; do
     get(&quot;#{(1 &lt;&lt; 27)}&quot;).should == (1 &lt;&lt; 27)
     get(&quot;#{-(1 &lt;&lt; 27) - 1}&quot;).should == -(1 &lt;&lt; 27) - 1
     get(&quot;#{(1 &lt;&lt; word_length) - 1}&quot;).should == (1 &lt;&lt; word_length) - 1
     get(&quot;#{-(1 &lt;&lt; word_length)}&quot;).should == -(1 &lt;&lt; word_length)
   end
-  
+
   specify &quot;an erlang number encoded as a small bignum (1 byte length) should decode to bignum if it can't be a fixnum&quot; do
     get(&quot;#{(1 &lt;&lt; word_length)}&quot;).should == (1 &lt;&lt; word_length)
     get(&quot;#{-(1 &lt;&lt; word_length) - 1}&quot;).should == -(1 &lt;&lt; word_length) - 1
     get(&quot;#{(1 &lt;&lt; (255 * 8)) - 1}&quot;).should == (1 &lt;&lt; (255 * 8)) - 1
     get(&quot;#{-((1 &lt;&lt; (255 * 8)) - 1)}&quot;).should == -((1 &lt;&lt; (255 * 8)) - 1)
   end
-  
-  
+
   specify &quot;an erlang number encoded as a big bignum (4 byte length) should decode to bignum&quot; do
     get(&quot;#{(1 &lt;&lt; (255 * 8)) }&quot;).should == (1 &lt;&lt; (255 * 8))
     get(&quot;#{-(1 &lt;&lt; (255 * 8))}&quot;).should == -(1 &lt;&lt; (255 * 8))
     get(&quot;#{(1 &lt;&lt; (512 * 8)) }&quot;).should == (1 &lt;&lt; (512 * 8))
     get(&quot;#{-(1 &lt;&lt; (512 * 8))}&quot;).should == -(1 &lt;&lt; (512 * 8))
   end
-  
+
   specify &quot;an erlang float should decode to a Float&quot; do
     get(&quot;#{1.0}&quot;).should == 1.0
     get(&quot;#{-1.0}&quot;).should == -1.0
     get(&quot;#{123.456}&quot;).should == 123.456
     get(&quot;#{123.456789012345}&quot;).should == 123.456789012345
   end
-  
-  
+
   specify &quot;an erlang reference should decode to a Reference object&quot; do
     ref = get(&quot;make_ref()&quot;)
     ref.should.be.instance_of Erlectricity::NewReference
     ref.node.should.be.instance_of Symbol
   end
-  
+
   specify &quot;an erlang pid should decode to a Pid object&quot; do
     pid = get(&quot;spawn(fun() -&gt; 3 end)&quot;)
     pid.should.be.instance_of Erlectricity::Pid
     pid.node.should.be.instance_of Symbol
   end
-  
-  
+
   specify &quot;an erlang tuple encoded as a small tuple (1-byte length) should decode to an array&quot; do
     ref = get(&quot;{3}&quot;)
     ref.length.should == 1
     ref.first.should == 3
-  
+
     ref = get(&quot;{3, a, make_ref()}&quot;)
     ref.length.should == 3
     ref[0].should == 3
     ref[1].should == :a
     ref[2].class.should == Erlectricity::NewReference
-  
+
     tuple_meat = (['3'] * 255).join(', ')
     ref = get(&quot;{#{tuple_meat}}&quot;)
     ref.length.should == 255
     ref.each{|r| r.should == 3}
   end
-  
-  
+
   specify &quot;an erlang tuple encoded as a large tuple (4-byte length) should decode to an array&quot; do
     tuple_meat = (['3'] * 256).join(', ')
     ref = get(&quot;{#{tuple_meat}}&quot;)
     ref.length.should == 256
     ref.each{|r| r.should == 3}
-    
+
     tuple_meat = (['3'] * 512).join(', ')
     ref = get(&quot;{#{tuple_meat}}&quot;)
     ref.length.should == 512
     ref.each{|r| r.should == 3}
   end
-  
-  
+
   specify &quot;an empty erlang list encoded as a nil should decode to an array&quot; do
     get(&quot;[]&quot;).should == []
   end
-  
+
   specify &quot;an erlang list encoded as a string should decode to an array of bytes (less than ideal, but consistent)&quot; do
     get(&quot;\&quot;asdasd\&quot;&quot;).should == &quot;asdasd&quot;.split('').map{|c| c[0]}
     get(&quot;\&quot;#{'a' * 65534}\&quot;&quot;).should == ['a'[0]] * 65534
   end
-  
+
   specify &quot;an erlang list encoded as a list should decode to a array&quot; do
     get(&quot;[3,4,256]&quot;).should == [3,4,256]
     get(&quot;\&quot;#{'a' * 65535 }\&quot;&quot;).should == [97] * 65535
     get(&quot;[3,4, foo, {3,4,5,bar}, 256]&quot;).should == [3,4, :foo, [3,4,5,:bar], 256]
   end
-  
-  
+
   specify &quot;an erlang binary should decode to a string&quot; do
     get(&quot;&lt;&lt; 3,4,255 &gt;&gt;&quot;).should == &quot;\003\004\377&quot;
     get(&quot;&lt;&lt; \&quot;whatup\&quot; &gt;&gt;&quot;).should == &quot;whatup&quot;
   end
-  
+
   specify &quot;erlang atomic booleans should decode to ruby booleans&quot; do
     get(&quot;true&quot;).should == true
     get(&quot;false&quot;).should == false
@@ -126,10 +119,10 @@ context &quot;When unpacking from a binary stream&quot; do
     get(%Q-[{options,{struct,[{test,&lt;&lt;&quot;I'm chargin' mah lazer&quot;&gt;&gt;}]}},{passage,&lt;&lt;&quot;Why doesn't this work?&quot;&gt;&gt;}]-).should ==
     [[:options, [:struct, [[:test, &quot;I'm chargin' mah lazer&quot;]]]], [:passage, &quot;Why doesn't this work?&quot;]]
   end
-  
+
   def get(str)
     x = &quot;term_to_binary(#{str.gsub(/&quot;/, '\\\&quot;')})&quot;
     bin = run_erl(x)
     Erlectricity::Decoder.read_any_from(bin)
   end
-end
+end
\ No newline at end of file</diff>
      <filename>test/decode_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,19 +5,26 @@ context &quot;When packing to a binary stream&quot; do
     @out = StringIO.new('', 'w')
     @encoder = Erlectricity::Encoder.new(@out)
   end
+
   specify &quot;A symbol should be encoded to an erlang atom&quot; do
     get{@encoder.write_symbol :haha}.should == get_erl(&quot;haha&quot;)
     write_any(:haha).should == get_erl_with_magic(&quot;haha&quot;)
   end
-  
+
+  specify &quot;A boolean should be encoded to an erlang atom&quot; do
+    get{@encoder.write_boolean true}.should == get_erl(&quot;true&quot;)
+    get{@encoder.write_boolean false}.should == get_erl(&quot;false&quot;)
+    write_any(true).should == get_erl_with_magic(&quot;true&quot;)
+    write_any(false).should == get_erl_with_magic(&quot;false&quot;)
+  end
+
   specify &quot;A number should be encoded as an erlang number would be&quot; do
-    
     #SMALL_INTS
     get{@encoder.write_fixnum 0}.should == get_erl(&quot;0&quot;)
     get{@encoder.write_fixnum 255}.should == get_erl(&quot;255&quot;)
     write_any(0).should == get_erl_with_magic(&quot;0&quot;)
     write_any(255).should == get_erl_with_magic(&quot;255&quot;)
-    
+
     #INTS
     get{@encoder.write_fixnum 256}.should == get_erl(&quot;256&quot;)
     get{@encoder.write_fixnum((1 &lt;&lt; 27) - 1)}.should == get_erl(&quot;#{(1 &lt;&lt; 27) - 1}&quot;)
@@ -27,105 +34,105 @@ context &quot;When packing to a binary stream&quot; do
     write_any((1 &lt;&lt; 27) - 1).should == get_erl_with_magic(&quot;#{(1 &lt;&lt; 27) - 1}&quot;)
     write_any(-1).should == get_erl_with_magic(&quot;-1&quot;)
     write_any(-(1 &lt;&lt; 27)).should == get_erl_with_magic(&quot;#{-(1 &lt;&lt; 27)}&quot;)
-    
+
     # #SMALL_BIGNUMS
     # get{@encoder.write_fixnum((1 &lt;&lt; word_length))}.should == get_erl(&quot;#{(1 &lt;&lt; word_length)}&quot;)
     # get{@encoder.write_fixnum(-(1 &lt;&lt; word_length) - 1)}.should == get_erl(&quot;#{-(1 &lt;&lt; word_length) - 1}&quot;)
     # get{@encoder.write_fixnum((1 &lt;&lt; (255 * 8)) - 1)}.should == get_erl(&quot;#{(1 &lt;&lt; (255 * 8)) - 1}&quot;)
     # get{@encoder.write_fixnum(-((1 &lt;&lt; (255 * 8)) - 1))}.should == get_erl(&quot;#{-((1 &lt;&lt; (255 * 8)) - 1)}&quot;)
-    # 
+    #
     # write_any((1 &lt;&lt; word_length)).should == get_erl_with_magic(&quot;#{(1 &lt;&lt; word_length)}&quot;)
     # write_any(-(1 &lt;&lt; word_length) - 1).should == get_erl_with_magic(&quot;#{-(1 &lt;&lt; word_length) - 1}&quot;)
     # write_any((1 &lt;&lt; (255 * 8)) - 1).should == get_erl_with_magic(&quot;#{(1 &lt;&lt; (255 * 8)) - 1}&quot;)
     # write_any(-((1 &lt;&lt; (255 * 8)) - 1)).should == get_erl_with_magic(&quot;#{-((1 &lt;&lt; (255 * 8)) - 1)}&quot;)
-    # 
+    #
     # #LARG_BIGNUMS
     # get{@encoder.write_fixnum((1 &lt;&lt; (255 * 8)))}.should == get_erl(&quot;#{(1 &lt;&lt; (255 * 8))}&quot;)
     # get{@encoder.write_fixnum(-(1 &lt;&lt; (255 * 8))}.should == get_erl(&quot;#{-(1 &lt;&lt; (255 * 8)}&quot;)
     # get{@encoder.write_fixnum((1 &lt;&lt; (512 * 8))}.should == get_erl(&quot;#{(1 &lt;&lt; (512 * 8))}&quot;)
     # get{@encoder.write_fixnum(-((1 &lt;&lt; (512 * 8)) - 1))}.should == get_erl(&quot;#{-((1 &lt;&lt; (512 * 8)) - 1)}&quot;)
-    # 
+    #
     # write_any((1 &lt;&lt; (255 * 8))).should == get_erl_with_magic(&quot;#{(1 &lt;&lt; (255 * 8))}&quot;)
     # write_any(-(1 &lt;&lt; (255 * 8)).should == get_erl_with_magic(&quot;#{-(1 &lt;&lt; (255 * 8)}&quot;)
     # write_any((1 &lt;&lt; (512 * 8))).should == get_erl_with_magic(&quot;#{(1 &lt;&lt; (512 * 8))}&quot;)
     # write_any(-((1 &lt;&lt; (512 * 8)) - 1)).should == get_erl_with_magic(&quot;#{-((1 &lt;&lt; (512 * 8)) - 1)}&quot;)
   end
-  
+
   # specify &quot;A float (that is within the truncated precision of ruby compared to erlang) should encode as erlang does&quot; do
   #   get{@encoder.write_float 1.0}.should == get_erl(&quot;1.0&quot;)
   #   get{@encoder.write_float -1.0}.should == get_erl(&quot;-1.0&quot;)
   #   get{@encoder.write_float 123.456}.should == get_erl(&quot;123.456&quot;)
   #   get{@encoder.write_float 123.456789012345}.should == get_erl(&quot;123.456789012345&quot;)
   # end
-  
+
   specify &quot;An Erlectiricity::NewReference should encode back to its original form&quot; do
     ref_bin = run_erl(&quot;term_to_binary(make_ref())&quot;)
     ruby_ref = Erlectricity::Decoder.read_any_from(ref_bin)
-    
+
     get{@encoder.write_new_reference(ruby_ref)}.should == ref_bin[1..-1]
     write_any(ruby_ref).should == ref_bin
   end
-  
+
   specify &quot;An Erlectiricity::Pid should encode back to its original form&quot; do
     pid_bin = run_erl(&quot;term_to_binary(spawn(fun() -&gt; 3 end))&quot;)
     ruby_pid = Erlectricity::Decoder.read_any_from(pid_bin)
-    
+
     get{@encoder.write_pid(ruby_pid)}.should == pid_bin[1..-1]
     write_any(ruby_pid).should == pid_bin
   end
-  
+
   specify &quot;An array written with write_tuple should encode as erlang would a tuple&quot; do
     get{@encoder.write_tuple [1,2,3]}.should == get_erl(&quot;{1,2,3}&quot;)
     get{@encoder.write_tuple [3] * 255}.should == get_erl(&quot;{#{([3] * 255).join(',')}}&quot;)
     get{@encoder.write_tuple [3] * 256}.should == get_erl(&quot;{#{([3] * 256).join(',')}}&quot;)
     get{@encoder.write_tuple [3] * 512}.should == get_erl(&quot;{#{([3] * 512).join(',')}}&quot;)
   end
-  
+
   specify &quot;An array should by default be written as a tuple&quot; do
     write_any([1,2,3]).should == get_erl_with_magic(&quot;{1,2,3}&quot;)
     write_any([3] * 255).should == get_erl_with_magic(&quot;{#{([3] * 255).join(',')}}&quot;)
     write_any([3] * 256).should == get_erl_with_magic(&quot;{#{([3] * 256).join(',')}}&quot;)
     write_any([3] * 512).should == get_erl_with_magic(&quot;{#{([3] * 512).join(',')}}&quot;)
   end
-  
+
   specify &quot;An Erlectricity::List should by default be written as a list&quot; do
     write_any(Erl::List.new([1,2,300])).should == get_erl_with_magic(&quot;[1,2,300]&quot;)
     write_any(Erl::List.new([300] * 255)).should == get_erl_with_magic(&quot;[#{([300] * 255).join(',')}]&quot;)
     write_any(Erl::List.new([300] * 256)).should == get_erl_with_magic(&quot;[#{([300] * 256).join(',')}]&quot;)
     write_any(Erl::List.new([300] * 512)).should == get_erl_with_magic(&quot;[#{([300] * 512).join(',')}]&quot;)
   end
-  
+
   specify &quot;An array written with write_list should encode as erlang would a list&quot; do
     get{@encoder.write_list [1,2,300]}.should == get_erl(&quot;[1,2,300]&quot;)
     get{@encoder.write_list [300] * 255}.should == get_erl(&quot;[#{([300] * 255).join(',')}]&quot;)
     get{@encoder.write_list [300] * 256}.should == get_erl(&quot;[#{([300] * 256).join(',')}]&quot;)
     get{@encoder.write_list [300] * 512}.should == get_erl(&quot;[#{([300] * 512).join(',')}]&quot;)
   end
-  
+
   specify &quot;a string should be encoded as a erlang binary would be&quot; do
     get{@encoder.write_binary &quot;hey who&quot;}.should == get_erl(&quot;&lt;&lt; \&quot;hey who\&quot; &gt;&gt;&quot;)
     get{@encoder.write_binary &quot;&quot;}.should == get_erl(&quot;&lt;&lt; \&quot;\&quot; &gt;&gt;&quot;)
-    
+
     write_any(&quot;hey who&quot;).should == get_erl_with_magic(&quot;&lt;&lt; \&quot;hey who\&quot; &gt;&gt;&quot;)
     write_any(&quot;&quot;).should == get_erl_with_magic(&quot;&lt;&lt; \&quot;\&quot; &gt;&gt;&quot;)
   end
-  
+
   def get
     @encoder.out = StringIO.new('', 'w')
     yield
     @encoder.out.string
   end
-  
+
   def write_any(term)
     @encoder.out = StringIO.new('', 'w')
     @encoder.write_any term
     @encoder.out.string
   end
-  
+
   def get_erl(str)
     get_erl_with_magic(str)[1..-1] #[1..-1] to chop off the magic number
   end
-  
+
   def get_erl_with_magic(str)
     run_erl(&quot;term_to_binary(#{str.gsub(/&quot;/, '\\\&quot;')})&quot;)
   end</diff>
      <filename>test/encode_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8c85ba2728484706e82f35e33d47ac5db0f20063</id>
    </parent>
  </parents>
  <author>
    <name>Tom Preston-Werner</name>
    <email>tom@mojombo.com</email>
  </author>
  <url>http://github.com/mojombo/erlectricity/commit/5e82730ec45dc5de9e153469cfaad50e06718e3c</url>
  <id>5e82730ec45dc5de9e153469cfaad50e06718e3c</id>
  <committed-date>2009-04-27T22:41:33-07:00</committed-date>
  <authored-date>2009-04-27T22:41:33-07:00</authored-date>
  <message>support boolean encoding and matching</message>
  <tree>bf2af10a2ce5f444b78e851fdb219ccc14a9b5e3</tree>
  <committer>
    <name>Tom Preston-Werner</name>
    <email>tom@mojombo.com</email>
  </committer>
</commit>
