ajaxful_rating 3.0.0.beta3 → 3.0.0.beta4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/ajaxful_rating.gemspec +32 -43
- data/lib/axr/model.rb +25 -17
- data/lib/axr/stars_builder.rb +1 -1
- metadata +11 -16
- data/.gitignore +0 -4
    
        data/Rakefile
    CHANGED
    
    | @@ -6,7 +6,7 @@ begin | |
| 6 6 |  | 
| 7 7 | 
             
              Jeweler::Tasks.new do |spec|
         | 
| 8 8 | 
             
                spec.name                   = "ajaxful_rating"
         | 
| 9 | 
            -
                spec.version                = "3.0.0. | 
| 9 | 
            +
                spec.version                = "3.0.0.beta4"
         | 
| 10 10 | 
             
                spec.summary                = "Provides a simple way to add rating functionality to your application."
         | 
| 11 11 | 
             
                spec.description            = "Provides a simple way to add rating functionality to your application."
         | 
| 12 12 | 
             
                spec.homepage               = "http://github.com/edgarjs/ajaxful-rating"
         | 
    
        data/ajaxful_rating.gemspec
    CHANGED
    
    | @@ -1,67 +1,56 @@ | |
| 1 1 | 
             
            # Generated by jeweler
         | 
| 2 2 | 
             
            # DO NOT EDIT THIS FILE DIRECTLY
         | 
| 3 | 
            -
            # Instead, edit Jeweler::Tasks in Rakefile, and run  | 
| 3 | 
            +
            # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
         | 
| 4 4 | 
             
            # -*- encoding: utf-8 -*-
         | 
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = %q{ajaxful_rating}
         | 
| 8 | 
            -
              s.version = "3.0.0. | 
| 8 | 
            +
              s.version = "3.0.0.beta4"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["Edgar J. Suarez", "Denis Odorcic"]
         | 
| 12 | 
            -
              s.date = %q{ | 
| 12 | 
            +
              s.date = %q{2011-08-16}
         | 
| 13 13 | 
             
              s.description = %q{Provides a simple way to add rating functionality to your application.}
         | 
| 14 14 | 
             
              s.email = ["edgar.js@gmail.com", "denis.odorcic@gmail.com"]
         | 
| 15 15 | 
             
              s.extra_rdoc_files = [
         | 
| 16 16 | 
             
                "README.textile"
         | 
| 17 17 | 
             
              ]
         | 
| 18 18 | 
             
              s.files = [
         | 
| 19 | 
            -
                " | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
                 "test/test_helper.rb"
         | 
| 19 | 
            +
                "CHANGELOG",
         | 
| 20 | 
            +
                "Manifest",
         | 
| 21 | 
            +
                "README.textile",
         | 
| 22 | 
            +
                "Rakefile",
         | 
| 23 | 
            +
                "ajaxful_rating.gemspec",
         | 
| 24 | 
            +
                "lib/ajaxful_rating.rb",
         | 
| 25 | 
            +
                "lib/axr/css_builder.rb",
         | 
| 26 | 
            +
                "lib/axr/errors.rb",
         | 
| 27 | 
            +
                "lib/axr/helpers.rb",
         | 
| 28 | 
            +
                "lib/axr/locale.rb",
         | 
| 29 | 
            +
                "lib/axr/model.rb",
         | 
| 30 | 
            +
                "lib/axr/stars_builder.rb",
         | 
| 31 | 
            +
                "lib/generators/ajaxful_rating/USAGE",
         | 
| 32 | 
            +
                "lib/generators/ajaxful_rating/ajaxful_rating_generator.rb",
         | 
| 33 | 
            +
                "lib/generators/ajaxful_rating/templates/images/star.png",
         | 
| 34 | 
            +
                "lib/generators/ajaxful_rating/templates/images/star_small.png",
         | 
| 35 | 
            +
                "lib/generators/ajaxful_rating/templates/migration.rb",
         | 
| 36 | 
            +
                "lib/generators/ajaxful_rating/templates/model.rb",
         | 
| 37 | 
            +
                "lib/generators/ajaxful_rating/templates/style.css",
         | 
| 38 | 
            +
                "test/fixtures/car.rb",
         | 
| 39 | 
            +
                "test/fixtures/cars.yml",
         | 
| 40 | 
            +
                "test/fixtures/rate.rb",
         | 
| 41 | 
            +
                "test/fixtures/rates.yml",
         | 
| 42 | 
            +
                "test/fixtures/schema.rb",
         | 
| 43 | 
            +
                "test/fixtures/user.rb",
         | 
| 44 | 
            +
                "test/fixtures/users.yml",
         | 
| 45 | 
            +
                "test/lib/model_test.rb",
         | 
| 46 | 
            +
                "test/test_helper.rb"
         | 
| 48 47 | 
             
              ]
         | 
| 49 48 | 
             
              s.homepage = %q{http://github.com/edgarjs/ajaxful-rating}
         | 
| 50 | 
            -
              s.rdoc_options = ["--charset=UTF-8"]
         | 
| 51 49 | 
             
              s.require_paths = ["lib"]
         | 
| 52 | 
            -
              s.rubygems_version = %q{1. | 
| 50 | 
            +
              s.rubygems_version = %q{1.6.2}
         | 
| 53 51 | 
             
              s.summary = %q{Provides a simple way to add rating functionality to your application.}
         | 
| 54 | 
            -
              s.test_files = [
         | 
| 55 | 
            -
                "test/fixtures/car.rb",
         | 
| 56 | 
            -
                 "test/fixtures/rate.rb",
         | 
| 57 | 
            -
                 "test/fixtures/schema.rb",
         | 
| 58 | 
            -
                 "test/fixtures/user.rb",
         | 
| 59 | 
            -
                 "test/lib/model_test.rb",
         | 
| 60 | 
            -
                 "test/test_helper.rb"
         | 
| 61 | 
            -
              ]
         | 
| 62 52 |  | 
| 63 53 | 
             
              if s.respond_to? :specification_version then
         | 
| 64 | 
            -
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         | 
| 65 54 | 
             
                s.specification_version = 3
         | 
| 66 55 |  | 
| 67 56 | 
             
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         | 
    
        data/lib/axr/model.rb
    CHANGED
    
    | @@ -21,16 +21,13 @@ module AjaxfulRating # :nodoc: | |
| 21 21 | 
             
                  has_many :rates_without_dimension, :as => :rateable, :class_name => 'Rate',
         | 
| 22 22 | 
             
                    :dependent => :destroy, :conditions => {:dimension => nil}
         | 
| 23 23 | 
             
                  has_many :raters_without_dimension, :through => :rates_without_dimension, :source => :rater
         | 
| 24 | 
            -
                  
         | 
| 25 | 
            -
                  options[:dimensions].each do |dimension|
         | 
| 26 | 
            -
                    has_many "#{dimension}_rates", :dependent => :destroy,
         | 
| 27 | 
            -
                      :conditions => {:dimension => dimension.to_s}, :class_name => 'Rate', :as => :rateable
         | 
| 28 | 
            -
                    has_many "#{dimension}_raters", :through => "#{dimension}_rates", :source => :rater
         | 
| 29 | 
            -
                  end if options[:dimensions].is_a?(Array)
         | 
| 30 24 |  | 
| 31 25 | 
             
                  class << self
         | 
| 32 | 
            -
                    def axr_config
         | 
| 33 | 
            -
                       | 
| 26 | 
            +
                    def axr_config(dimension = nil)
         | 
| 27 | 
            +
                      dimension ||= :default
         | 
| 28 | 
            +
                      @axr_config ||= {}
         | 
| 29 | 
            +
                      dimension = dimension.to_sym
         | 
| 30 | 
            +
                      @axr_config[dimension] ||= {
         | 
| 34 31 | 
             
                        :stars => 5,
         | 
| 35 32 | 
             
                        :allow_update => true,
         | 
| 36 33 | 
             
                        :cache_column => :rating_average
         | 
| @@ -39,8 +36,19 @@ module AjaxfulRating # :nodoc: | |
| 39 36 |  | 
| 40 37 | 
             
                    alias_method :ajaxful_rating_options, :axr_config
         | 
| 41 38 | 
             
                  end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  if options[:dimensions].is_a?(Array)
         | 
| 41 | 
            +
                    options[:dimensions].each do |dimension|
         | 
| 42 | 
            +
                      has_many "#{dimension}_rates", :dependent => :destroy,
         | 
| 43 | 
            +
                        :conditions => {:dimension => dimension.to_s}, :class_name => 'Rate', :as => :rateable
         | 
| 44 | 
            +
                      has_many "#{dimension}_raters", :through => "#{dimension}_rates", :source => :rater
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                      axr_config(dimension).update(options)
         | 
| 47 | 
            +
                    end 
         | 
| 48 | 
            +
                  else
         | 
| 49 | 
            +
                      axr_config.update(options)
         | 
| 50 | 
            +
                  end
         | 
| 42 51 |  | 
| 43 | 
            -
                  axr_config.update(options)
         | 
| 44 52 |  | 
| 45 53 | 
             
                  include AjaxfulRating::InstanceMethods
         | 
| 46 54 | 
             
                  extend AjaxfulRating::SingletonMethods
         | 
| @@ -56,8 +64,8 @@ module AjaxfulRating # :nodoc: | |
| 56 64 | 
             
              module InstanceMethods
         | 
| 57 65 |  | 
| 58 66 | 
             
                # Proxy for axr_config singleton method.
         | 
| 59 | 
            -
                def axr_config
         | 
| 60 | 
            -
                  self.class.axr_config
         | 
| 67 | 
            +
                def axr_config(dimension = nil)
         | 
| 68 | 
            +
                  self.class.axr_config(dimension)
         | 
| 61 69 | 
             
                end
         | 
| 62 70 |  | 
| 63 71 | 
             
                # Submits a new rate. Accepts a hash of tipical Ajax request.
         | 
| @@ -71,9 +79,9 @@ module AjaxfulRating # :nodoc: | |
| 71 79 | 
             
                #   end
         | 
| 72 80 | 
             
                def rate(stars, user, dimension = nil)
         | 
| 73 81 | 
             
                  return false if (stars.to_i > self.class.max_stars)
         | 
| 74 | 
            -
                  raise Errors::AlreadyRatedError if (!self.class.axr_config[:allow_update] && rated_by?(user, dimension))
         | 
| 82 | 
            +
                  raise Errors::AlreadyRatedError if (!self.class.axr_config(dimension)[:allow_update] && rated_by?(user, dimension))
         | 
| 75 83 |  | 
| 76 | 
            -
                  rate = if self.class.axr_config[:allow_update] && rated_by?(user, dimension)
         | 
| 84 | 
            +
                  rate = if self.class.axr_config(dimension)[:allow_update] && rated_by?(user, dimension)
         | 
| 77 85 | 
             
                    rate_by(user, dimension)
         | 
| 78 86 | 
             
                  else
         | 
| 79 87 | 
             
                    rates(dimension).build.tap do |r|
         | 
| @@ -132,7 +140,7 @@ module AjaxfulRating # :nodoc: | |
| 132 140 | 
             
                # Based on if the user has already rated the object or the
         | 
| 133 141 | 
             
                # :allow_update option is enabled.
         | 
| 134 142 | 
             
                def can_rate_by?(user, dimension = nil)
         | 
| 135 | 
            -
                  !rated_by?(user, dimension) || self.class.axr_config[:allow_update]
         | 
| 143 | 
            +
                  !rated_by?(user, dimension) || self.class.axr_config(dimension)[:allow_update]
         | 
| 136 144 | 
             
                end
         | 
| 137 145 |  | 
| 138 146 | 
             
                # Instance's total rates.
         | 
| @@ -189,8 +197,8 @@ module AjaxfulRating # :nodoc: | |
| 189 197 | 
             
                # Change it by passing the :stars option to +ajaxful_rateable+
         | 
| 190 198 | 
             
                #
         | 
| 191 199 | 
             
                #   ajaxful_rateable :stars => 10
         | 
| 192 | 
            -
                def max_stars
         | 
| 193 | 
            -
                  axr_config[:stars]
         | 
| 200 | 
            +
                def max_stars(dimension = nil)
         | 
| 201 | 
            +
                  axr_config(dimension)[:stars]
         | 
| 194 202 | 
             
                end
         | 
| 195 203 |  | 
| 196 204 | 
             
                # Name of the class for the user model.
         | 
| @@ -254,7 +262,7 @@ module AjaxfulRating # :nodoc: | |
| 254 262 |  | 
| 255 263 | 
             
                # Returns the name of the cache column for the passed dimension.
         | 
| 256 264 | 
             
                def caching_column_name(dimension = nil)
         | 
| 257 | 
            -
                  name = axr_config[:cache_column].to_s
         | 
| 265 | 
            +
                  name = axr_config(dimension)[:cache_column].to_s
         | 
| 258 266 | 
             
                  name += "_#{dimension.to_s.underscore}" unless dimension.blank?
         | 
| 259 267 | 
             
                  name
         | 
| 260 268 | 
             
                end
         | 
    
        data/lib/axr/stars_builder.rb
    CHANGED
    
    | @@ -79,7 +79,7 @@ module AjaxfulRating # :nodoc: | |
| 79 79 | 
             
                  })
         | 
| 80 80 |  | 
| 81 81 | 
             
                  @template.content_tag(:li) do
         | 
| 82 | 
            -
                    if !options[:force_static] && (user && options[:current_user] == user && (!already_rated || rateable.axr_config[:allow_update]))
         | 
| 82 | 
            +
                    if !options[:force_static] && (user && options[:current_user] == user && (!already_rated || rateable.axr_config(options[:dimension])[:allow_update]))
         | 
| 83 83 | 
             
                      link_star_tag(value, css_class)
         | 
| 84 84 | 
             
                    else
         | 
| 85 85 | 
             
                      @template.content_tag(:span, show_value, :class => css_class, :title => i18n(:current))
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,15 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: ajaxful_rating
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 5 | 
            -
              prerelease:  | 
| 4 | 
            +
              hash: 62196427
         | 
| 5 | 
            +
              prerelease: 6
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 3
         | 
| 8 8 | 
             
              - 0
         | 
| 9 9 | 
             
              - 0
         | 
| 10 | 
            -
              -  | 
| 11 | 
            -
               | 
| 10 | 
            +
              - beta
         | 
| 11 | 
            +
              - 4
         | 
| 12 | 
            +
              version: 3.0.0.beta4
         | 
| 12 13 | 
             
            platform: ruby
         | 
| 13 14 | 
             
            authors: 
         | 
| 14 15 | 
             
            - Edgar J. Suarez
         | 
| @@ -17,7 +18,7 @@ autorequire: | |
| 17 18 | 
             
            bindir: bin
         | 
| 18 19 | 
             
            cert_chain: []
         | 
| 19 20 |  | 
| 20 | 
            -
            date:  | 
| 21 | 
            +
            date: 2011-08-16 00:00:00 -05:00
         | 
| 21 22 | 
             
            default_executable: 
         | 
| 22 23 | 
             
            dependencies: []
         | 
| 23 24 |  | 
| @@ -32,7 +33,6 @@ extensions: [] | |
| 32 33 | 
             
            extra_rdoc_files: 
         | 
| 33 34 | 
             
            - README.textile
         | 
| 34 35 | 
             
            files: 
         | 
| 35 | 
            -
            - .gitignore
         | 
| 36 36 | 
             
            - CHANGELOG
         | 
| 37 37 | 
             
            - Manifest
         | 
| 38 38 | 
             
            - README.textile
         | 
| @@ -66,8 +66,8 @@ homepage: http://github.com/edgarjs/ajaxful-rating | |
| 66 66 | 
             
            licenses: []
         | 
| 67 67 |  | 
| 68 68 | 
             
            post_install_message: 
         | 
| 69 | 
            -
            rdoc_options: 
         | 
| 70 | 
            -
             | 
| 69 | 
            +
            rdoc_options: []
         | 
| 70 | 
            +
             | 
| 71 71 | 
             
            require_paths: 
         | 
| 72 72 | 
             
            - lib
         | 
| 73 73 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| @@ -93,14 +93,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 93 93 | 
             
            requirements: []
         | 
| 94 94 |  | 
| 95 95 | 
             
            rubyforge_project: 
         | 
| 96 | 
            -
            rubygems_version: 1. | 
| 96 | 
            +
            rubygems_version: 1.6.2
         | 
| 97 97 | 
             
            signing_key: 
         | 
| 98 98 | 
             
            specification_version: 3
         | 
| 99 99 | 
             
            summary: Provides a simple way to add rating functionality to your application.
         | 
| 100 | 
            -
            test_files: 
         | 
| 101 | 
            -
             | 
| 102 | 
            -
            - test/fixtures/rate.rb
         | 
| 103 | 
            -
            - test/fixtures/schema.rb
         | 
| 104 | 
            -
            - test/fixtures/user.rb
         | 
| 105 | 
            -
            - test/lib/model_test.rb
         | 
| 106 | 
            -
            - test/test_helper.rb
         | 
| 100 | 
            +
            test_files: []
         | 
| 101 | 
            +
             | 
    
        data/.gitignore
    DELETED