<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>ajaxful_rating.gemspec</filename>
    </added>
    <added>
      <filename>lib/ajaxful_rating_model.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,3 @@
-ajaxful-rating.gemspec
 CHANGELOG
 generators/ajaxful_rating/ajaxful_rating_generator.rb
 generators/ajaxful_rating/templates/images/star.png
@@ -8,9 +7,9 @@ generators/ajaxful_rating/templates/model.rb
 generators/ajaxful_rating/templates/style.css
 generators/ajaxful_rating/USAGE
 init.rb
-lib/ajaxful-rating.rb
 lib/ajaxful_rating.rb
 lib/ajaxful_rating_helper.rb
+lib/ajaxful_rating_model.rb
 Manifest
 Rakefile
 README.textile</diff>
      <filename>Manifest</filename>
    </modified>
    <modified>
      <diff>@@ -23,7 +23,11 @@ To install the plugin:
 
 Or the gem
 
-  @sudo gem install edgarjs-ajaxful-rating --source=http://gems.github.com@
+  @sudo gem install edgarjs-ajaxful_rating --source=http://gems.github.com@
+  
+You can configure it in your environment.rb file also:
+
+  @config.gem &quot;edgarjs-ajaxful_rating&quot;, :lib =&gt; &quot;ajaxful_rating&quot;, :source =&gt; &quot;http://gems.github.com&quot;@
 
 h3. Generate
 </diff>
      <filename>README.textile</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@ require 'rubygems'
 require 'rake'
 require 'echoe'
 
-Echoe.new('ajaxful-rating', '2.1.0') do |p|
+Echoe.new('ajaxful_rating', '2.1.0') do |p|
   p.description    = &quot;Provides a simple way to add rating functionality to your application.&quot;
   p.url            = &quot;http://github.com/edgarjs/ajaxful-rating&quot;
   p.author         = &quot;Edgar J. Suarez&quot;</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1 @@
-require 'ajaxful-rating'
+require 'ajaxful_rating'</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,223 +1,2 @@
-module AjaxfulRating # :nodoc:
-  class AlreadyRatedError &lt; StandardError
-    def to_s
-      &quot;Model has already been rated by this user. To allow update of ratings pass :allow_update =&gt; true to the ajaxful_rateable call.&quot;
-    end
-  end
-
-  def self.included(base)
-    base.extend ClassMethods
-  end
-
-  module ClassMethods
-    attr_reader :options
-
-    # Extends the model to be easy ajaxly rateable.
-    #
-    # Options:
-    # * &lt;tt&gt;:stars&lt;/tt&gt; Max number of stars that can be submitted.
-    # * &lt;tt&gt;:allow_update&lt;/tt&gt; Set to true if you want users to be able to update their votes.
-    # * &lt;tt&gt;:cache_column&lt;/tt&gt; Name of the column for storing the cached rating average.
-    #
-    # Example:
-    #   class Article &lt; ActiveRecord::Base
-    #     ajaxful_rateable :stars =&gt; 10, :cache_column =&gt; :custom_column
-    #   end
-    def ajaxful_rateable(options = {})
-      has_many :rates_without_dimension, :as =&gt; :rateable, :class_name =&gt; 'Rate',
-        :dependent =&gt; :destroy, :conditions =&gt; {:dimension =&gt; nil}
-
-      
-      options[:dimensions].each do |dimension|
-        has_many &quot;#{dimension}_rates&quot;, :dependent =&gt; :destroy,
-          :conditions =&gt; {:dimension =&gt; dimension.to_s}, :class_name =&gt; 'Rate', :as =&gt; :rateable
-      end if options[:dimensions].is_a?(Array)
-
-      @options = options.reverse_merge(
-        :stars =&gt; 5,
-        :allow_update =&gt; true,
-        :cache_column =&gt; :rating_average
-      )
-      include AjaxfulRating::InstanceMethods
-      extend AjaxfulRating::SingletonMethods
-    end
-
-    # Makes the association between user and Rate model.
-    def ajaxful_rater(options = {})
-      has_many :rates, options
-    end
-
-    # Maximum value accepted when rating the model. Default is 5.
-    #
-    # Change it by passing the :stars option to +ajaxful_rateable+
-    #
-    #   ajaxful_rateable :stars =&gt; 10
-    def max_rate_value
-      options[:stars]
-    end
-  end
-
-  # Instance methods for the rateable object.
-  module InstanceMethods
-
-    # Submits a new rate. Accepts a hash of tipical Ajax request.
-    #
-    # Example:
-    #   # Articles Controller
-    #   def rate
-    #     @article = Article.find(params[:id])
-    #     @article.rate(params[:stars], current_user, params[:dimension])
-    #     # some page update here ...
-    #   end
-    def rate(stars, user, dimension = nil)
-      return false if (stars.to_i &gt; self.class.max_rate_value)
-      raise AlreadyRatedError if (!self.class.options[:allow_update] &amp;&amp; rated_by?(user, dimension))
-
-      rate = (self.class.options[:allow_update] &amp;&amp; rated_by?(user, dimension)) ?
-        rate_by(user, dimension) : rates(dimension).build
-      rate.stars = stars
-      if user.respond_to?(:rates)
-        user.rates &lt;&lt; rate
-      else
-        rate.send &quot;#{self.class.user_class_name}_id=&quot;, user.id
-      end if rate.new_record?
-      rate.save!
-      self.update_cached_average(dimension)
-    end
-
-    # Returns an array with all users that have rated this object.
-    def raters
-      eval(self.class.user_class_name.classify).find_by_sql(
-        [&quot;SELECT DISTINCT u.* FROM #{self.class.user_class_name.pluralize} u INNER JOIN rates r ON &quot; +
-            &quot;u.[id] = r.[#{self.class.user_class_name}_id] WHERE r.[rateable_id] = ? AND r.[rateable_type] = ?&quot;,
-          id, self.class.name]
-      )
-    end
-
-    # Finds the rate made by the user if he/she has already voted.
-    def rate_by(user, dimension = nil)
-      filter = &quot;find_by_#{self.class.user_class_name}_id&quot;
-      rates(dimension).send filter, user
-    end
-
-    # Return true if the user has rated the object, otherwise false
-    def rated_by?(user, dimension = nil)
-      !rate_by(user, dimension).nil?
-    end
-
-    # Instance's total rates.
-    def total_rates(dimension = nil)
-      rates(dimension).size
-    end
-
-    # Total sum of the rates.
-    def rates_sum(dimension = nil)
-      rates(dimension).sum(:stars)
-    end
-
-    # Rating average for the object.
-    #
-    # Pass false as param to force the calculation if you are caching it.
-    def rate_average(cached = true, dimension = nil)
-      avg = if cached &amp;&amp; self.class.caching_average?(dimension)
-        send(caching_column_name(dimension)).to_f
-      else
-        self.rates_sum(dimension).to_f / self.total_rates(dimension).to_f
-      end
-      avg.nan? ? 0.0 : avg
-    end
-
-    # Overrides the default +rates+ method and returns the propper array
-    # for the dimension passed.
-    #
-    # It may works as an alias for +dimension_rates+ methods.
-    def rates(dimension = nil)
-      unless dimension.blank?
-        send(&quot;#{dimension}_rates&quot;)
-      else
-        rates_without_dimension
-      end
-    end
-
-    # Returns the name of the cache column for the passed dimension.
-    def caching_column_name(dimension = nil)
-      self.class.caching_column_name(dimension)
-    end
-
-    # Updates the cached average column in the rateable model.
-    def update_cached_average(dimension = nil)
-      if self.class.caching_average?(dimension)
-        rates(:refresh).size if self.respond_to?(:rates_count)
-        send(&quot;#{caching_column_name(dimension)}=&quot;, self.rate_average(false, dimension))
-        save!
-      end
-    end
-  end
-
-  module SingletonMethods
-
-    # Name of the class for the user model.
-    def user_class_name
-      @@user_class_name ||= Rate.column_names.find do |c|
-        u = c.scan(/(\w+)_id$/).flatten.first
-        break u if u &amp;&amp; u != 'rateable'
-      end
-    end
-
-    # Finds all rateable objects rated by the +user+.
-    def find_rated_by(user)
-      find_statement(:user_id, user.id)
-    end
-
-    # Finds all rateable objects rated with +stars+.
-    def find_rated_with(stars)
-      find_statement(:stars, stars)
-    end
-
-    # Finds the rateable object with the highest rate average.
-    def find_most_popular(dimension = nil)
-      all.sort_by { |o| o.rate_average(true, dimension) }.last
-    end
-
-    # Finds the rateable object with the lowest rate average.
-    def find_less_popular(dimension = nil)
-      all.sort_by { |o| o.rate_average(true, dimension) }.first
-    end
-
-    # Finds rateable objects by Rate's attribute.
-    def find_statement(attr_name, attr_value)
-      rateable = self.base_class.name
-      sql = sanitize_sql([&quot;SELECT DISTINCT r2.* FROM rates r1 INNER JOIN &quot; +
-            &quot;#{rateable.constantize.table_name} r2 ON r1.rateable_id = r2.id &quot; +
-            &quot;WHERE (r1.[rateable_type] = ? AND r1.[#{attr_name}] = ?)&quot;,
-          rateable, attr_value])
-      find_by_sql(sql)
-    end
-
-    # Indicates if the rateable model is able to cache the rate average.
-    #
-    # Include a column named +rating_average+ in your rateable model with
-    # default null, as decimal:
-    #
-    #   t.decimal :rating_average, :precision =&gt; 3, :scale =&gt; 1, :default =&gt; 0
-    #
-    # To customize the name of the column specify the option &lt;tt&gt;:cache_column&lt;/tt&gt; to ajaxful_rateable
-    #
-    #   ajaxful_rateable :cache_column =&gt; :my_custom_column
-    #
-    def caching_average?(dimension = nil)
-      column_names.include?(caching_column_name(dimension))
-    end
-
-    # Returns the name of the cache column for the passed dimension.
-    def caching_column_name(dimension = nil)
-      name = options[:cache_column].to_s
-      name += &quot;_#{dimension.to_s.underscore}&quot; unless dimension.blank?
-      name
-    end
-  end
-end
-
-class ActiveRecord::Base
-  include AjaxfulRating
-end
+require 'ajaxful_rating_model'
+require 'ajaxful_rating_helper'</diff>
      <filename>lib/ajaxful_rating.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>ajaxful-rating.gemspec</filename>
    </removed>
    <removed>
      <filename>lib/ajaxful-rating.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>ea52518d2760072d8c888ecb869444659e16733e</id>
    </parent>
  </parents>
  <author>
    <name>edgarjs</name>
    <email>edgar.js@gmail.com</email>
  </author>
  <url>http://github.com/edgarjs/ajaxful-rating/commit/39ec4a0ba48ab7b4a7d0eb8db0c7d10c6bc8c482</url>
  <id>39ec4a0ba48ab7b4a7d0eb8db0c7d10c6bc8c482</id>
  <committed-date>2009-07-25T15:04:57-07:00</committed-date>
  <authored-date>2009-07-25T15:04:57-07:00</authored-date>
  <message>Underscored gem name &quot;ajaxful_rating&quot;</message>
  <tree>5bc5c98a8a09205f8f046da1e4f7b28f221a9774</tree>
  <committer>
    <name>edgarjs</name>
    <email>edgar.js@gmail.com</email>
  </committer>
</commit>
