<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,11 @@
 = swf_fu --- History
 
+== Version 1.2.0 - January 14, 2009
+
+* flashvars[:id] will now default to the DOM id of the object. I didn't want to have any extra defaults than the very basic ones, but there is no easy way to get this from Flash (see http://www.actionscript.org/forums/showthread.php3?t=136044 ) and no easy way to specify that using +swf_default_options+.
+* If flashvars is a string (e.g. &quot;myVar=myValue&quot;) it will be parsed into a hash so that the behaviour for default values apply to strings or hashes. swf_default_options[:flashvars] can also be a string and will also be parsed before being merged.
+* Small bug fix: the options passed as hashes (:flashvars, :parameters and :html_options) were changed if swf_default_options[:flashvars, ...] existed. They are now left unchanged.
+
 == Version 1.1.0 - January 3, 2009
 
 * Improved the way to specify alternate content</diff>
      <filename>CHANGELOG.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -44,12 +44,12 @@ You can specify alternate content either with the options :alt =&gt; &quot;Get Flash!&quot; o
 * &lt;tt&gt;:width, :height&lt;/tt&gt; - the width &amp; height of the Flash object. Defaults to &quot;100%&quot;. These could also specified using :size
 * &lt;tt&gt;:size&lt;/tt&gt; - the size of the Flash object, in the form &quot;400x300&quot;.
 * &lt;tt&gt;:mode&lt;/tt&gt; - Either :dynamic (default) or :static. Refer to SWFObject's doc[http://code.google.com/p/swfobject/wiki/documentation#Should_I_use_the_static_or_dynamic_publishing_method?]
-* &lt;tt&gt;:flashvars&lt;/tt&gt; - a Hash of variables that are passed to the swf. Can also be a string like &lt;tt&gt;&quot;foo=bar&amp;hello=world&quot;&lt;/tt&gt;
+* &lt;tt&gt;:flashvars&lt;/tt&gt; - a Hash of variables that are passed to the swf. Can also be a string like &lt;tt&gt;&quot;foo=bar&amp;hello=world&quot;&lt;/tt&gt;. Defaults to &lt;tt&gt;{:id =&gt; the DOM id}&lt;/tt&gt;
 * &lt;tt&gt;:parameters&lt;/tt&gt; - a Hash of configuration parameters for the swf. See Adobe's doc[http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_12701#optional]
 * &lt;tt&gt;:alt&lt;/tt&gt; - HTML text that is displayed when the Flash player is not available. Defaults to a &quot;Get Flash&quot; image pointing to Adobe Flash's installation page. This can also be specified as a block (see embedding section)
 * &lt;tt&gt;:flash_version&lt;/tt&gt; - the version of the Flash player that is required (e.g. &quot;7&quot; (default) or &quot;8.1.0&quot;)
 * &lt;tt&gt;:auto_install&lt;/tt&gt; - a swf file that will upgrade flash player if needed (defaults to &quot;expressInstall&quot; which was installed by swf_fu)
-* &lt;tt&gt;:javascript_class&lt;/tt&gt; - specify a javascript class (e.g. &quot;MyFlash&quot;) for your flash object. The initialize method will be called when the flash object is ready.
+* &lt;tt&gt;:javascript_class&lt;/tt&gt; - specify a javascript class (e.g. &quot;MyFlash&quot;) for your flash object. If it exists, the initialize method will be called.
 * &lt;tt&gt;:initialize&lt;/tt&gt; - arguments to pass to the initialization method of your javascript class.
 * &lt;tt&gt;:div_id&lt;/tt&gt; - the DOM +id+ of the containing div itself. Defaults to &lt;tt&gt;&quot;#{option[:id]}&quot;_div&lt;/tt&gt;
 </diff>
      <filename>README.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -17,6 +17,6 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
   rdoc.rdoc_dir = 'rdoc'
   rdoc.title    = 'Swf Fu'
   rdoc.options &lt;&lt; '--line-numbers' &lt;&lt; '--inline-source' &lt;&lt; '-m README.rdoc'
-  rdoc.rdoc_files.include('README.rdoc')
+  rdoc.rdoc_files.include('*.rdoc')
   rdoc.rdoc_files.include('lib/**/*.rb')
 end</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -39,42 +39,36 @@ module ActionView #:nodoc:
       alias_method :flashobject_tag, :flashobject_tag_for_compatibility unless defined? flashobject_tag
     
   private
+      DEFAULTS = {
+        :width            =&gt; &quot;100%&quot;,
+        :height           =&gt; &quot;100%&quot;,
+        :flash_version    =&gt; 7,
+        :mode             =&gt; :dynamic,
+        :auto_install     =&gt; &quot;expressInstall&quot;,
+        :alt    =&gt; &lt;&lt;-&quot;EOS&quot;
+          &lt;a href=&quot;http://www.adobe.com/go/getflashplayer&quot;&gt;
+        	  &lt;img src=&quot;http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif&quot; alt=&quot;Get Adobe Flash player&quot; /&gt;
+          &lt;/a&gt;
+        EOS
+      }.freeze
+      
       class Generator # :nodoc:
         VALID_MODES = [:static, :dynamic]
         def initialize(source, options, view)
           @view = view
           @source = view.swf_path(source)
-          @options = ActionView::Base.swf_default_options.merge(options)
+          options = ActionView::Base.swf_default_options.merge(options)
           [:html_options, :parameters, :flashvars].each do |k|
-            @options[k].merge! ActionView::Base.swf_default_options[k] rescue &quot;merge won't work for string or nil, ignore error&quot;
-          end
-          @options.reverse_merge!(
-            :id               =&gt; source.gsub(/^.*\//, '').gsub(/\.swf$/,''),
-            :width            =&gt; &quot;100%&quot;,
-            :height           =&gt; &quot;100%&quot;,
-            :flash_version    =&gt; 7,
-            :parameters       =&gt; {},
-            :flashvars        =&gt; {},
-            :html_options     =&gt; {},
-            :mode             =&gt; :dynamic,
-            :auto_install     =&gt; &quot;expressInstall&quot;,
-            :alt    =&gt; &lt;&lt;-&quot;EOS&quot;
-              &lt;a href=&quot;http://www.adobe.com/go/getflashplayer&quot;&gt;
-            	  &lt;img src=&quot;http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif&quot; alt=&quot;Get Adobe Flash player&quot; /&gt;
-              &lt;/a&gt;
-            EOS
-          )
-          @options[:div_id] ||= @options[:id]+&quot;_div&quot;
-          @options[:width], @options[:height] = @options[:size].scan(/^(\d*%?)x(\d*%?)$/).first if @options[:size]
-          @options[:auto_install] &amp;&amp;= @view.swf_path(@options[:auto_install])
-          # For some strange reason, SWFObject will only accept a string as parameters[:flashvars] and a hash as a direct argument (dynamic method)
-          # To allow both string and hash forms, we simply do our own conversion to string...
-          if @options[:flashvars].is_a?(Hash)
-            @options[:flashvars] = @options[:flashvars].map do |key_value|
-              key_value.map{|val| CGI::escape(val.to_s)}.join(&quot;=&quot;)
-            end.join(&quot;&amp;&quot;)
+            options[k] = convert_to_hash(options[k]).reverse_merge convert_to_hash(ActionView::Base.swf_default_options[k])
           end
-          @mode = @options.delete(:mode)
+          options.reverse_merge!(DEFAULTS)
+          options[:id] ||= source.gsub(/^.*\//, '').gsub(/\.swf$/,'')
+          options[:div_id] ||= options[:id]+&quot;_div&quot;
+          options[:width], options[:height] = options[:size].scan(/^(\d*%?)x(\d*%?)$/).first if options[:size]
+          options[:auto_install] &amp;&amp;= @view.swf_path(options[:auto_install])
+          options[:flashvars][:id] ||= options[:id]
+          @mode = options.delete(:mode)
+          @options = options
           unless VALID_MODES.include? @mode
             raise ArgumentError, &quot;options[:mode] should be either #{VALID_MODES.join(' or ')}&quot;
           end
@@ -90,9 +84,32 @@ module ActionView #:nodoc:
         end
         
       private
+        def convert_to_hash(s)
+          case s
+            when Hash
+              s
+            when nil
+              {}
+            when String
+              s.split(&quot;&amp;&quot;).inject({}) do |h, kvp|
+                key, value = kvp.split(&quot;=&quot;)
+                h[key.to_sym] = CGI::unescape(value)
+                h
+              end
+            else
+              raise ArgumentError, &quot;#{s} should be a Hash, a String or nil&quot;
+          end
+        end
+      
+        def convert_to_string(h)
+          h.map do |key_value|
+            key_value.map{|val| CGI::escape(val.to_s)}.join(&quot;=&quot;)
+          end.join(&quot;&amp;&quot;)
+        end
+        
         def static
           param_list = @options[:parameters].map{|k,v| %(&lt;param name=&quot;#{k}&quot; value=&quot;#{v}&quot;/&gt;) }.join(&quot;\n&quot;)
-          param_list += %(\n&lt;param name=&quot;flashvars&quot; value=&quot;#{@options[:flashvars]}&quot;/&gt;) unless @options[:flashvars].empty?
+          param_list += %(\n&lt;param name=&quot;flashvars&quot; value=&quot;#{convert_to_string(@options[:flashvars])}&quot;/&gt;) unless @options[:flashvars].empty?
           html_options = @options[:html_options].map{|k,v| %(#{k}=&quot;#{v}&quot;)}.join(&quot; &quot;)
           r = @view.javascript_tag(%(swfobject.registerObject(&quot;#{@options[:id]}_container&quot;, &quot;#{@options[:flash_version]}&quot;, #{@options[:auto_install].to_json});)) + &lt;&lt;-&quot;EOS&quot;
           
@@ -116,7 +133,6 @@ module ActionView #:nodoc:
         def dynamic
           @options[:html_options] = @options[:html_options].merge(:id =&gt; @options[:id])
           @options[:parameters] = @options[:parameters].dup # don't modify the original parameters
-          @options[:parameters][:flashvars] = @options.delete :flashvars
           args = (([@source] + @options.values_at(:div_id,:width,:height,:flash_version)).map(&amp;:to_s) + 
                   @options.values_at(:auto_install,:flashvars,:parameters,:html_options)
                  ).map(&amp;:to_json).join(&quot;,&quot;)</diff>
      <filename>lib/action_view/helpers/swf_fu_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
-DYNAMIC_RESULT = &lt;&lt;&quot;EOS&quot;
+DYNAMIC_RESULT = &lt;&lt;'EOS'
 &lt;script type=&quot;text/javascript&quot;&gt;
 //&lt;![CDATA[
-swfobject.embedSWF(&quot;/swfs/mySwf.swf&quot;,&quot;mySwf_div&quot;,&quot;456&quot;,&quot;123&quot;,&quot;7&quot;,&quot;/swfs/expressInstall.swf&quot;,null,{&quot;play&quot;: true, &quot;flashvars&quot;: &quot;myVar=value+1+%3E+2&quot;},{&quot;id&quot;: &quot;mySwf&quot;})
+swfobject.embedSWF(&quot;/swfs/mySwf.swf&quot;,&quot;mySwf_div&quot;,&quot;456&quot;,&quot;123&quot;,&quot;7&quot;,&quot;/swfs/expressInstall.swf&quot;,{&quot;myVar&quot;: &quot;value 1 \u003E 2&quot;, &quot;id&quot;: &quot;mySwf&quot;},{&quot;play&quot;: true},{&quot;id&quot;: &quot;mySwf&quot;})
 //]]&gt;
 &lt;/script&gt;
 &lt;div id=&quot;mySwf_div&quot;&gt;
@@ -17,7 +17,7 @@ swfobject.addDomLoadEvent(function(){Object.extend($('mySwf'), SomeClass.prototy
 &lt;/script&gt;
 EOS
 
-STATIC_RESULT = &lt;&lt;&quot;EOS&quot;
+STATIC_RESULT = &lt;&lt;'EOS'
 &lt;script type=&quot;text/javascript&quot;&gt;
 //&lt;![CDATA[
 swfobject.registerObject(&quot;mySwf_container&quot;, &quot;7&quot;, &quot;/swfs/expressInstall.swf&quot;);
@@ -26,11 +26,11 @@ swfobject.registerObject(&quot;mySwf_container&quot;, &quot;7&quot;, &quot;/swfs/expressInstall.swf&quot;);
 &lt;div id=&quot;mySwf_div&quot;&gt;&lt;object classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot; width=&quot;456&quot; height=&quot;123&quot; id=&quot;mySwf_container&quot; class=&quot;lots&quot;&gt;
 &lt;param name=&quot;movie&quot; value=&quot;/swfs/mySwf.swf&quot; /&gt;
 &lt;param name=&quot;play&quot; value=&quot;true&quot;/&gt;
-&lt;param name=&quot;flashvars&quot; value=&quot;myVar=value+1+%3E+2&quot;/&gt;
+&lt;param name=&quot;flashvars&quot; value=&quot;myVar=value+1+%3E+2&amp;id=mySwf&quot;/&gt;
 &lt;!--[if !IE]&gt;--&gt;
 &lt;object type=&quot;application/x-shockwave-flash&quot; data=&quot;/swfs/mySwf.swf&quot; width=&quot;456&quot; height=&quot;123&quot; id=&quot;mySwf&quot;&gt;
 &lt;param name=&quot;play&quot; value=&quot;true&quot;/&gt;
-&lt;param name=&quot;flashvars&quot; value=&quot;myVar=value+1+%3E+2&quot;/&gt;
+&lt;param name=&quot;flashvars&quot; value=&quot;myVar=value+1+%3E+2&amp;id=mySwf&quot;/&gt;
 &lt;!--&lt;![endif]--&gt;
 &lt;a href=&quot;http://www.adobe.com/go/getflashplayer&quot;&gt;
 &lt;img src=&quot;http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif&quot; alt=&quot;Get Adobe Flash player&quot; /&gt;</diff>
      <filename>test/results.rb</filename>
    </modified>
    <modified>
      <diff>@@ -63,9 +63,9 @@ class SwfFuTest &lt; ActionView::TestCase
 
     context &quot;with custom defaults&quot; do
       setup do
-        test = {:flashvars=&gt; {:xyz =&gt; &quot;abc&quot;}, :mode =&gt; :static, :size =&gt; &quot;400x300&quot;}
+        test = {:flashvars=&gt; {:xyz =&gt; &quot;abc&quot;, :hello =&gt; &quot;world&quot;}.freeze, :mode =&gt; :static, :size =&gt; &quot;400x300&quot;}.freeze
         @expect = swf_tag(&quot;test&quot;, test)
-        @expect_with_hello = swf_tag(&quot;test&quot;, :flashvars =&gt; {:xyz =&gt; &quot;abc&quot;, :hello =&gt; &quot;world&quot;}, :mode =&gt; :static, :size =&gt; &quot;400x300&quot;)
+        @expect_with_hello = swf_tag(&quot;test&quot;, :flashvars =&gt; {:xyz =&gt; &quot;abc&quot;, :hello =&gt; &quot;my friend&quot;}, :mode =&gt; :static, :size =&gt; &quot;400x300&quot;)
         ActionView::Base.swf_default_options = test
       end
       
@@ -74,7 +74,7 @@ class SwfFuTest &lt; ActionView::TestCase
       end
       
       should &quot;merge suboptions&quot; do
-        assert_equal @expect_with_hello, swf_tag(&quot;test&quot;, :flashvars =&gt; {:hello =&gt; &quot;world&quot;})
+        assert_equal @expect_with_hello, swf_tag(&quot;test&quot;, :flashvars =&gt; {:hello =&gt; &quot;my friend&quot;}.freeze)
       end
 
       teardown { ActionView::Base.swf_default_options = {} }        </diff>
      <filename>test/swf_fu_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>bd9413b786d1d98c1362bd3507ed3b01168a93de</id>
    </parent>
  </parents>
  <author>
    <name>Marc-Andre Lafortune</name>
    <email>github@marc-andre.ca</email>
  </author>
  <url>http://github.com/marcandre/swf_fu/commit/526dd7f6e5bde8674d31c4e2517645fccf443bcf</url>
  <id>526dd7f6e5bde8674d31c4e2517645fccf443bcf</id>
  <committed-date>2009-01-14T18:47:54-08:00</committed-date>
  <authored-date>2009-01-14T18:47:54-08:00</authored-date>
  <message>v1.2.0, with better handling of flashvars (see CHANGELOG)</message>
  <tree>61bacc08201a6dfbcf19bf8b47292658164698ee</tree>
  <committer>
    <name>Marc-Andre Lafortune</name>
    <email>github@marc-andre.ca</email>
  </committer>
</commit>
