<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,22 +1,12 @@
 How to Run
 ==========
 
-In the first time you run these scripts you must pass the id of the &quot;next item&quot; as a command-line argument. Example:
+In the first time you run these scripts you must provide the id of the initial item as a command-line argument. Example:
 
 $ ruby malvados.rb 1198
 
-This will generate the XML file. In the next run you can do just like this:
+This will generate the XML file. In the next time you don't need it anymore:
 
 $ ruby malvados.rb
 
 Now rssifier.rb will try to get the next item (based on the last item number present in the XML file) and update the XML.
-
-How to create a new feed
-========================
-
-The 'rssify' method takes some parameters, with two special cases: the parameter ':get_body' must contain a Proc that gets a 
-string 's' containing the body of the feed item and formats it. The parameter ':next_item_getter' (yeah, I must fix these 
-names...) doest the same for the next item number.
-
-The guess_next_item method acts sequentially, adding 1 to the next_item number and trying to download it based on a template. 
-If it's successful (!= '404'), the XML file containing the feed is updated.</diff>
      <filename>README.txt</filename>
    </modified>
    <modified>
      <diff>@@ -9,15 +9,19 @@
 require 'rssify'
 
 rssify do
-  { 
+  {
     :filename =&gt; 'malvados.xml',
     :home =&gt; 'http://www.malvados.com.br/',
     :title =&gt; 'Malvados - Quadrinhos de Humor',
     :description =&gt; 'Unofficial Malvados feed by Dirceu Pereira Tiegs - http://dirceu.info',
-    :title_templ =&gt;  'Malvados #{next_item}',
-    :link_templ =&gt; 'http://www.malvados.com.br/index#{next_item}.html',
-    :get_body =&gt; Proc.new {|s| &quot;&lt;p&gt;&lt;img src='http://www.malvados.com.br/&quot; + s.scan(/(tirinha\d+.gif)/)[0][0] + &quot;' /&gt;&lt;/p&gt;&quot; },
-    :next_item_getter =&gt; Proc.new { |next_item| next_item },
-    :next_item =&gt; ARGV[0],
+    :templates =&gt; {
+      :title =&gt;  'Malvados #{next_item}',
+      :link =&gt; 'http://www.malvados.com.br/index#{next_item}.html',
+    },
+    :procs =&gt; {
+      :body =&gt; Proc.new {|s| &quot;&lt;p&gt;&lt;img src='http://www.malvados.com.br/&quot; + s.scan(/(tirinha\d+.gif)/)[0][0] + &quot;' /&gt;&lt;/p&gt;&quot; },
+      :next_item =&gt; Proc.new { |next_item| next_item },
+    },
+    :initial_item =&gt; ARGV[0],
   }
 end</diff>
      <filename>malvados.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,15 +9,19 @@
 require 'rssify'
 
 rssify do
-  { 
+  {
     :filename =&gt; 'oots.xml',
     :home =&gt; 'http://www.giantitp.com/comics/oots.html',
     :title =&gt; 'The Order of the Stick',
     :description =&gt; 'Unofficial OOtS feed by Dirceu Pereira Tiegs - http://dirceu.info',
-    :title_templ =&gt;  'OOtS #{next_item}',
-    :link_templ =&gt; 'http://www.giantitp.com/comics/oots#{next_item}.html',
-    :get_body =&gt; Proc.new {|s| &quot;&lt;p&gt;&lt;img src='http://www.giantitp.com/&quot; + s.scan(/(\/comics\/images\/.+.gif)/)[0][0] + &quot;' /&gt;&lt;/p&gt;&quot; },
-    :next_item_getter =&gt; Proc.new { |next_item| &quot;0#{next_item.to_i}&quot; if next_item.to_i &lt; 1000 },
-    :next_item =&gt; ARGV[0],
+    :templates =&gt; {
+      :title =&gt; 'OOtS #{next_item}',
+      :link =&gt; 'http://www.giantitp.com/comics/oots#{next_item}.html',
+    },
+    :procs =&gt; {
+      :body =&gt; Proc.new {|s| &quot;&lt;p&gt;&lt;img src='http://www.giantitp.com/&quot; + s.scan(/(\/comics\/images\/.+.gif)/)[0][0] + &quot;' /&gt;&lt;/p&gt;&quot; },
+      :next_item =&gt; Proc.new { |next_item| &quot;0#{next_item.to_i}&quot; if next_item.to_i &lt; 1000 },
+    },
+    :initial_item =&gt; ARGV[0],
   }
 end</diff>
      <filename>oots.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,37 +1,33 @@
 require 'net/http'
 require 'uri'
-require 'rss/2.0'
 require 'rss/maker'
 
 class RSSifier
-  
+
   def initialize(p)
-    # FIXME: These is fcking ugly!
-    @home,@title,@description,@title_templ,@link_templ,@get_body,@next_item_getter,@next_item = p[:home],p[:title],p[:description],p[:title_templ],p[:link_templ],p[:get_body],p[:next_item_getter],p[:next_item]
+    @p = p
     @rss_filename = File.expand_path('.') + '/' + p[:filename]
+
+    @next_item = p[:initial_item]
     if !@next_item
       guess_next_item
     end
   end
 
   def next_item
-    @next_item = @next_item_getter.call(@next_item)
+    @next_item = @p[:procs][:next_item].call(@next_item)
   end
 
   def _render_templ(s)
     s.gsub('#{next_item}', next_item.to_s)
   end
-  
+
   def link_templ
-    _render_templ(@link_templ)
-  end
-  
-  def title_templ
-    _render_templ(@title_templ)
+    _render_templ(@p[:templates][:link])
   end
 
-  def get_body(s)
-    @get_body.call(s)
+  def title_templ
+    _render_templ(@p[:templates][:title])
   end
 
   def guess_next_item
@@ -44,12 +40,12 @@ class RSSifier
       Process.exit
     end
   end
-  
+
   def create_feed
     @content = RSS::Maker.make('2.0') do |m|
-      m.channel.title = @title
-      m.channel.link = @home
-      m.channel.description = @description
+      m.channel.title = @p[:title]
+      m.channel.link = @p[:home]
+      m.channel.description = @p[:description]
       m.items.do_sort = true
 
       2.downto 0 do |n|
@@ -57,7 +53,7 @@ class RSSifier
         if response.code != &quot;404&quot;
           i = m.items.new_item
           i.title = title_templ
-          i.description = get_body(response.body)
+          i.description = @p[:procs][:body].call(response.body)
           i.link = link_templ
           i.date = Time.parse(response['last-modified'])
         end
@@ -65,7 +61,7 @@ class RSSifier
       end
     end
   end
-  
+
   def write_feed
     File.open(@rss_filename, &quot;w&quot;) do |f|
       f.write(@content)</diff>
      <filename>rssify.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c392beba1b937601daa34bcc18b222ddae57fca5</id>
    </parent>
  </parents>
  <author>
    <name>Dirceu Pereira Tiegs</name>
    <email>dirceutiegs@gmail.com</email>
  </author>
  <url>http://github.com/dirceu/rssifier/commit/007335e9ee83334e8d536a8b983993e3cf008ca4</url>
  <id>007335e9ee83334e8d536a8b983993e3cf008ca4</id>
  <committed-date>2009-01-11T19:34:06-08:00</committed-date>
  <authored-date>2009-01-11T19:34:06-08:00</authored-date>
  <message>Refactoring rssify code</message>
  <tree>7a6d2fc4c94464329438d522b2b4f7adcfb738ac</tree>
  <committer>
    <name>Dirceu Pereira Tiegs</name>
    <email>dirceutiegs@gmail.com</email>
  </committer>
</commit>
