<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,9 +4,10 @@
 
 == rufus-lua - 1.1.0    not yet released
 
-- issue #2 : tables returned from Ruby functions were indexed at 0. (Scott)
-- issue #3 : passing false from Ruby to Lua twists it to true. (Scott)
-- issue #1 : Ruby function return array not OK. Fixed. (Thanks Scott Persinger)
+- todo      : state['a'] = [ 1, 2, 3 ] now possible
+- issue #2  : tables returned from Ruby functions were indexed at 0. (Scott)
+- issue #3  : passing false from Ruby to Lua twists it to true. (Scott)
+- issue #1  : Ruby function return array not OK. Fixed. (Thanks Scott Persinger)
 
 
 == rufus-lua - 1.0.0    released 2009/03/27</diff>
      <filename>CHANGELOG.txt</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@
 [o] fix coroutine &amp; co / memoization (make it better later)
 [o] fib.lua, use local, bench ! (2 times faster almost)
 
-[ ] add GC control methods (Alain)
+[o] add GC control methods (Alain)
 [X] Add method to disable GC
 [X] Add method to enable GC
 [ ] Look at parameters in Lua GC that can be tweaked
@@ -21,3 +21,8 @@
 [x] ruby callbacks (functions)
 [ ] ability to bind ruby functions (callbacks) inside of tables (modules)
 
+[ ] state['var'] = value
+[ ] state['var'] = hash
+
+[ ] state.load_and_eval(filepath)
+</diff>
      <filename>TODO.txt</filename>
    </modified>
    <modified>
      <diff>@@ -48,6 +48,7 @@ module Rufus::Lua
     # (Problably a good idea if you want Lua's GC to get rid of it later).
     #
     def free
+
       Lib.luaL_unref(@pointer, LUA_REGISTRYINDEX, @ref)
       @ref = nil
     end</diff>
      <filename>lib/rufus/lua/objects.rb</filename>
    </modified>
    <modified>
      <diff>@@ -394,6 +394,17 @@ module Rufus::Lua
       k.index('.') ? self.eval(&quot;return #{k}&quot;) : get_global(k)
     end
 
+    # Allows for setting a Lua varible immediately.
+    #
+    #   state['var'] = [ 1, 2, 3 ]
+    #   puts state['var'].to_a[0] # =&gt; 1
+    #
+    def []= (k, v)
+
+      #puts; puts(&quot;#{k} = #{Rufus::Lua.to_lua_s(v)}&quot;)
+      self.eval(&quot;#{k} = #{Rufus::Lua.to_lua_s(v)}&quot;)
+    end
+
     # Binds a Ruby function (callback) in the top environment of Lua
     #
     #   require 'rubygems'</diff>
      <filename>lib/rufus/lua/state.rb</filename>
    </modified>
    <modified>
      <diff>@@ -67,7 +67,7 @@ module Rufus::Lua
     s = if o.is_a?(Array)
       o.collect { |e| to_lua_s(e) }
     else
-      o.collect { |k, v| &quot;#{to_lua_s(k)}: #{to_lua_s(v)}&quot; }
+      o.collect { |k, v| &quot;[#{to_lua_s(k)}] = #{to_lua_s(v)}&quot; }
     end
 
     &quot;{ #{s.join(', ')} }&quot;</diff>
      <filename>lib/rufus/lua/utils.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,7 +8,7 @@
 require File.dirname(__FILE__) + '/spec_base'
 
 
-describe 'Rufus::Lua::State' do
+describe Rufus::Lua::State do
 
   it 'should not crash closing a closed State' do
 
@@ -18,3 +18,38 @@ describe 'Rufus::Lua::State' do
     should.raise(RuntimeError) { @s.close }
   end
 end
+
+describe Rufus::Lua::State do
+
+  before do
+    @s = Rufus::Lua::State.new
+  end
+  after do
+    @s.close
+  end
+
+  it 'should return nil for unbound variables' do
+
+    @s['a'].should.be.nil
+  end
+
+  it 'should accept setting values directly' do
+
+    @s['a'] = 1
+    @s['a'].should.equal(1)
+  end
+
+  it 'should accept setting array values directly' do
+
+    @s['a'] = [ true, false, %w[ alpha bravo charly ] ]
+    @s['a'].to_a[0].should.equal(true)
+    @s['a'].to_a[2].to_a.should.equal(%w[ alpha bravo charly ])
+  end
+
+  it 'should accept setting hash values directly' do
+
+    @s['a'] = { 'a' =&gt; 'alpha', 'b' =&gt; 'bravo' }
+    @s['a'].to_h.should.equal({ 'a' =&gt; 'alpha', 'b' =&gt; 'bravo' })
+  end
+end
+</diff>
      <filename>spec/state_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -21,10 +21,8 @@ describe 'Rufus::Lua (utils)' do
     Rufus::Lua.to_lua_s(
       { 'a' =&gt; 'A', 'b' =&gt; 2}
     ).should.equal(
-      '{ &quot;a&quot;: &quot;A&quot;, &quot;b&quot;: 2 }'
+      '{ [&quot;a&quot;] = &quot;A&quot;, [&quot;b&quot;] = 2 }'
     )
-      # TODO : [&quot;a&quot;] is probably better...
   end
-
 end
 </diff>
      <filename>spec/utils_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9024db4258ac7746925a9caf3f7401359d30d2ad</id>
    </parent>
  </parents>
  <author>
    <name>John Mettraux</name>
    <email>jmettraux@gmail.com</email>
  </author>
  <url>http://github.com/jmettraux/rufus-lua/commit/b012d681eaf81db7cf47ac9b4f76ef4848032d5a</url>
  <id>b012d681eaf81db7cf47ac9b4f76ef4848032d5a</id>
  <committed-date>2009-07-23T23:15:06-07:00</committed-date>
  <authored-date>2009-07-23T23:15:06-07:00</authored-date>
  <message>todo : state['a'] = [ 1, 2, 3 ] now possible</message>
  <tree>2717bd8e3397b47042f4691434a20241bf227d6e</tree>
  <committer>
    <name>John Mettraux</name>
    <email>jmettraux@gmail.com</email>
  </committer>
</commit>
