letsrate 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3d94d55984e0dd1c0c3ec42fb753c79ba46098c2
4
+ data.tar.gz: 2ad702581410c7b7dd1d714ec08715a25f4ab5d1
5
+ SHA512:
6
+ metadata.gz: ec62fbdf163528e4b0b8b755cfe803ebad07f56723b49a52c3e6b591f249567071d19df4b6f26394a058b425476d0500c42443ed4c088c3e43b62cd2d23b8157
7
+ data.tar.gz: 0717e7c5d049fa70ec10ae6f732006ac371c9a80ddd2e36dfb97653eb38d98fc7fadfc43532ee72cab217b9129f52305c254bb0c12280a1f56010132871b59df
@@ -1,7 +1,8 @@
1
1
  language: ruby
2
- rvm:
2
+ rvm:
3
3
  - "1.9.2"
4
- - "1.9.3"
4
+ - "1.9.3"
5
+ - "2.0.0"
5
6
  - jruby-19mode # JRuby in 1.9 mode
6
7
  - rbx-18mode
7
8
  - rbx-19mode
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "http://rubygems.org"
2
2
 
3
3
  gem 'jquery-rails'
4
4
 
@@ -1,60 +1,45 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- letsrate (1.0.8)
4
+ letsrate (1.0.9)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- actionpack (3.2.2)
10
- activemodel (= 3.2.2)
11
- activesupport (= 3.2.2)
12
- builder (~> 3.0.0)
9
+ actionpack (4.0.2)
10
+ activesupport (= 4.0.2)
11
+ builder (~> 3.1.0)
13
12
  erubis (~> 2.7.0)
14
- journey (~> 1.0.1)
15
- rack (~> 1.4.0)
16
- rack-cache (~> 1.1)
17
- rack-test (~> 0.6.1)
18
- sprockets (~> 2.1.2)
19
- activemodel (3.2.2)
20
- activesupport (= 3.2.2)
21
- builder (~> 3.0.0)
22
- activesupport (3.2.2)
23
- i18n (~> 0.6)
24
- multi_json (~> 1.0)
25
- builder (3.0.0)
13
+ rack (~> 1.5.2)
14
+ rack-test (~> 0.6.2)
15
+ activesupport (4.0.2)
16
+ i18n (~> 0.6, >= 0.6.4)
17
+ minitest (~> 4.2)
18
+ multi_json (~> 1.3)
19
+ thread_safe (~> 0.1)
20
+ tzinfo (~> 0.3.37)
21
+ atomic (1.1.14)
22
+ builder (3.1.4)
26
23
  erubis (2.7.0)
27
- hike (1.2.1)
28
- i18n (0.6.0)
29
- journey (1.0.3)
30
- jquery-rails (2.0.1)
31
- railties (< 5.0, >= 3.2.0)
32
- thor (~> 0.14)
33
- json (1.6.5)
34
- multi_json (1.1.0)
35
- rack (1.4.1)
36
- rack-cache (1.2)
37
- rack (>= 0.4)
38
- rack-ssl (1.3.2)
39
- rack
40
- rack-test (0.6.1)
24
+ i18n (0.6.9)
25
+ jquery-rails (3.0.4)
26
+ railties (>= 3.0, < 5.0)
27
+ thor (>= 0.14, < 2.0)
28
+ minitest (4.7.5)
29
+ multi_json (1.8.2)
30
+ rack (1.5.2)
31
+ rack-test (0.6.2)
41
32
  rack (>= 1.0)
42
- railties (3.2.2)
43
- actionpack (= 3.2.2)
44
- activesupport (= 3.2.2)
45
- rack-ssl (~> 1.3.2)
33
+ railties (4.0.2)
34
+ actionpack (= 4.0.2)
35
+ activesupport (= 4.0.2)
46
36
  rake (>= 0.8.7)
47
- rdoc (~> 3.4)
48
- thor (~> 0.14.6)
49
- rake (0.9.2.2)
50
- rdoc (3.12)
51
- json (~> 1.4)
52
- sprockets (2.1.2)
53
- hike (~> 1.2)
54
- rack (~> 1.0)
55
- tilt (!= 1.3.0, ~> 1.1)
56
- thor (0.14.6)
57
- tilt (1.3.3)
37
+ thor (>= 0.18.1, < 2.0)
38
+ rake (10.1.1)
39
+ thor (0.18.1)
40
+ thread_safe (0.1.3)
41
+ atomic
42
+ tzinfo (0.3.38)
58
43
 
59
44
  PLATFORMS
60
45
  ruby
data/README.md CHANGED
@@ -87,29 +87,12 @@ Speed : <%= rating_for @car, "engine", :star => 7 %>
87
87
  Speed : <%= rating_for @car, "price" %>
88
88
  ```
89
89
 
90
- ### Important
90
+ You can use the rating_for_user helper method to show the star rating for the user.
91
91
 
92
- By default rating_for tries to call devise current_user method as the rater instance in the rater_controller.rb file. You can change the current_user method
93
- as you will.
94
-
95
- ```ruby
96
- #rater_controller.rb
97
-
98
- def create
99
- if current_user.present?
100
- obj = eval "#{params[:klass]}.find(#{params[:id]})"
101
- if params[:dimension].present?
102
- obj.rate params[:score].to_i, current_user.id, "#{params[:dimension]}"
103
- else
104
- obj.rate params[:score].to_i, current_user.id
105
- end
106
-
107
- render :json => true
108
- else
109
- render :json => false
110
- end
111
- end
92
+ ```erb
93
+ Speed : <%= rating_for_user @car, current_user, "speed", :star => 10 %>
112
94
  ```
113
95
 
96
+
114
97
  ## Feedback
115
98
  If you find bugs please open a ticket at [https://github.com/muratguzel/letsrate/issues](https://github.com/muratguzel/letsrate/issues)
@@ -1,49 +1,40 @@
1
1
  require 'rails/generators/migration'
2
- class LetsrateGenerator < Rails::Generators::NamedBase
2
+ require 'rails/generators/active_record'
3
+ class LetsrateGenerator < ActiveRecord::Generators::Base
3
4
  include Rails::Generators::Migration
4
-
5
- source_root File.expand_path('../templates', __FILE__)
6
-
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
7
8
  desc "copying jquery.raty files to assets directory ..."
8
9
  def copying
9
10
  copy_file 'jquery.raty.js', 'app/assets/javascripts/jquery.raty.js'
10
11
  copy_file 'star-on.png', 'app/assets/images/star-on.png'
11
12
  copy_file 'star-off.png', 'app/assets/images/star-off.png'
12
13
  copy_file 'star-half.png', 'app/assets/images/star-half.png'
13
- copy_file 'letsrate.js', 'app/assets/javascripts/letsrate.js.erb'
14
+ copy_file 'letsrate.js.erb', 'app/assets/javascripts/letsrate.js.erb'
14
15
  copy_file 'rater_controller.rb', 'app/controllers/rater_controller.rb'
15
- end
16
-
16
+ end
17
+
17
18
  desc "model is creating..."
18
- def create_model
19
+ def create_model
19
20
  model_file = File.join('app/models', "#{file_path}.rb")
20
21
  raise "User model (#{model_file}) must exits." unless File.exists?(model_file)
21
22
  class_collisions 'Rate'
22
- template 'model.rb', File.join('app/models', "rate.rb")
23
+ template 'model.rb', File.join('app/models', "rate.rb")
23
24
  template 'cache_model.rb', File.join('app/models', "rating_cache.rb")
24
- end
25
-
25
+ end
26
+
26
27
  def add_rate_path_to_route
27
- route "match '/rate' => 'rater#create', :as => 'rate'"
28
+ route "post '/rate' => 'rater#create', :as => 'rate'"
28
29
  end
29
30
 
30
31
  desc "cacheable rating average migration is creating ..."
31
32
  def create_cacheable_migration
32
33
  migration_template "cache_migration.rb", "db/migrate/create_rating_caches.rb"
33
34
  end
34
-
35
+
35
36
  desc "migration is creating ..."
36
37
  def create_migration
37
- migration_template "migration.rb", "db/migrate/create_rates.rb"
38
- end
39
-
40
-
41
- private
42
- def self.next_migration_number(dirname)
43
- if ActiveRecord::Base.timestamped_migrations
44
- Time.now.utc.strftime("%Y%m%d%H%M%S%L")
45
- else
46
- "%.3d" % (current_migration_number(dirname) + 1)
47
- end
38
+ migration_template "migration.rb", "db/migrate/create_rates.rb"
48
39
  end
49
- end
40
+ end
@@ -1,9 +1,9 @@
1
1
  class CreateRatingCaches < ActiveRecord::Migration
2
-
2
+
3
3
  def self.up
4
4
  create_table :rating_caches do |t|
5
5
  t.belongs_to :cacheable, :polymorphic => true
6
- t.float :avg, :null => false
6
+ t.float :avg, :null => false
7
7
  t.integer :qty, :null => false
8
8
  t.string :dimension
9
9
  t.timestamps
@@ -14,6 +14,6 @@ class CreateRatingCaches < ActiveRecord::Migration
14
14
 
15
15
  def self.down
16
16
  drop_table :rating_caches
17
- end
18
-
17
+ end
18
+
19
19
  end
@@ -1,3 +1,3 @@
1
1
  class RatingCache < ActiveRecord::Base
2
- belongs_to :cacheable, :polymorphic => true
2
+ belongs_to :cacheable, :polymorphic => true
3
3
  end
@@ -27,7 +27,7 @@
27
27
  return this.each(function() {
28
28
  var self = this,
29
29
  $this = $(self).empty();
30
-
30
+
31
31
  self.opt = $.extend(true, {}, $.fn.raty.defaults, settings);
32
32
 
33
33
  $this.data('settings', self.opt);
@@ -47,7 +47,7 @@
47
47
  }
48
48
 
49
49
  if (self.opt.score) {
50
- self.opt.score = methods.between(self.opt.score, 0, self.opt.number);
50
+ self.opt.score = methods.between(self.opt.score, 0, self.opt.number);
51
51
  }
52
52
 
53
53
  for (var i = 1; i <= self.opt.number; i++) {
@@ -71,7 +71,7 @@
71
71
  }
72
72
 
73
73
  if (self.opt.iconRange) {
74
- methods.fill.call(self, self.opt.score);
74
+ methods.fill.call(self, self.opt.score);
75
75
  }
76
76
 
77
77
  methods.setTarget.call(self, self.opt.score, self.opt.targetKeep);
@@ -186,7 +186,7 @@
186
186
  });
187
187
  }, cancel: function(isClick) {
188
188
  return $(this).each(function() {
189
- var self = this,
189
+ var self = this,
190
190
  $this = $(self);
191
191
 
192
192
  if ($this.data('readonly') === true) {
@@ -424,7 +424,7 @@
424
424
  return methods.init.apply(this, arguments);
425
425
  } else {
426
426
  $.error('Method ' + method + ' does not exist!');
427
- }
427
+ }
428
428
  };
429
429
 
430
430
  $.fn.raty.defaults = {
@@ -0,0 +1,36 @@
1
+ $.fn.raty.defaults.path = "/assets";
2
+ $.fn.raty.defaults.half_show = true;
3
+
4
+ $(function(){
5
+ $(".star").each(function() {
6
+ var $readonly = ($(this).attr('data-readonly') == 'true');
7
+ $(this).raty({
8
+ score: function(){
9
+ return $(this).attr('data-rating')
10
+ },
11
+ number: function() {
12
+ return $(this).attr('data-star-count')
13
+ },
14
+ readOnly: $readonly,
15
+ click: function(score, evt) {
16
+ var _this = this;
17
+ $.post('<%= Rails.application.class.routes.url_helpers.rate_path %>',
18
+ {
19
+ score: score,
20
+ dimension: $(this).attr('data-dimension'),
21
+ id: $(this).attr('data-id'),
22
+ klass: $(this).attr('data-classname')
23
+ },
24
+ function(data) {
25
+ if(data) {
26
+ // success code goes here ...
27
+
28
+ if ($(_this).attr('data-disable-after-rate') == 'true') {
29
+ $(_this).raty('set', { readOnly: true, score: score });
30
+ }
31
+ }
32
+ });
33
+ }
34
+ });
35
+ });
36
+ });
@@ -1,5 +1,5 @@
1
1
  class CreateRates < ActiveRecord::Migration
2
-
2
+
3
3
  def self.up
4
4
  create_table :rates do |t|
5
5
  t.belongs_to :rater
@@ -15,6 +15,6 @@ class CreateRates < ActiveRecord::Migration
15
15
 
16
16
  def self.down
17
17
  drop_table :rates
18
- end
19
-
18
+ end
19
+
20
20
  end
@@ -1,7 +1,7 @@
1
1
  class Rate < ActiveRecord::Base
2
2
  belongs_to :rater, :class_name => "<%= file_name.classify %>"
3
3
  belongs_to :rateable, :polymorphic => true
4
-
5
- attr_accessible :rate, :dimension
6
-
4
+
5
+ #attr_accessible :rate, :dimension
6
+
7
7
  end
@@ -1,19 +1,14 @@
1
- class RaterController < ApplicationController
2
-
3
- def create
4
- if current_user.present?
5
- obj = eval "#{params[:klass]}.find(#{params[:id]})"
6
- if params[:dimension].present?
7
- obj.rate params[:score].to_i, current_user.id, "#{params[:dimension]}"
8
- else
9
- obj.rate params[:score].to_i, current_user.id
10
- end
11
-
12
- render :json => true
1
+ class RaterController < ApplicationController
2
+
3
+ def create
4
+ if user_signed_in?
5
+ obj = params[:klass].classify.constantize.find(params[:id])
6
+ obj.rate params[:score].to_i, current_user, params[:dimension]
7
+
8
+ render :json => true
13
9
  else
14
- render :json => false
10
+ render :json => false
15
11
  end
16
- end
17
-
18
-
19
- end
12
+ end
13
+
14
+ end
@@ -1,29 +1,45 @@
1
- module Helpers
2
- def rating_for(rateable_obj, dimension=nil, options={})
3
-
4
- if dimension.nil?
5
- klass = rateable_obj.average
6
- else
7
- klass = rateable_obj.average "#{dimension}"
8
- end
9
-
10
- if klass.nil?
11
- avg = 0
12
- else
13
- avg = klass.avg
14
- end
15
-
1
+ module Helpers
2
+ def rating_for(rateable_obj, dimension=nil, options={})
3
+
4
+ cached_average = rateable_obj.average dimension
5
+
6
+ avg = cached_average ? cached_average.avg : 0
7
+
16
8
  star = options[:star] || 5
17
-
18
- content_tag :div, "", "data-dimension" => dimension, :class => "star", "data-rating" => avg,
19
- "data-id" => rateable_obj.id, "data-classname" => rateable_obj.class.name,
20
- "data-star-count" => star
21
-
22
-
9
+
10
+ disable_after_rate = options[:disable_after_rate] || true
11
+
12
+ readonly = !(current_user && rateable_obj.can_rate?(current_user, dimension))
13
+
14
+ content_tag :div, '', "data-dimension" => dimension, :class => "star", "data-rating" => avg,
15
+ "data-id" => rateable_obj.id, "data-classname" => rateable_obj.class.name,
16
+ "data-disable-after-rate" => disable_after_rate,
17
+ "data-readonly" => readonly,
18
+ "data-star-count" => star
23
19
  end
24
-
20
+
21
+ def rating_for_user(rateable_obj, rating_user, dimension = nil, options = {})
22
+ @object = rateable_obj
23
+ @user = rating_user
24
+ @rating = Rate.find_by_rater_id_and_rateable_id_and_dimension(@user.id, @object.id, dimension)
25
+ stars = @rating ? @rating.stars : 0
26
+
27
+ disable_after_rate = options[:disable_after_rate] || false
28
+
29
+ readonly=false
30
+ if disable_after_rate
31
+ readonly = current_user.present? ? !rateable_obj.can_rate?(current_user.id, dimension) : true
32
+ end
33
+
34
+ content_tag :div, '', "data-dimension" => dimension, :class => "star", "data-rating" => stars,
35
+ "data-id" => rateable_obj.id, "data-classname" => rateable_obj.class.name,
36
+ "data-disable-after-rate" => disable_after_rate,
37
+ "data-readonly" => readonly,
38
+ "data-star-count" => stars
39
+ end
40
+
25
41
  end
26
42
 
27
43
  class ActionView::Base
28
44
  include Helpers
29
- end
45
+ end
@@ -1,101 +1,113 @@
1
1
  require 'active_support/concern'
2
2
  module Letsrate
3
3
  extend ActiveSupport::Concern
4
-
5
- def rate(stars, user_id, dimension=nil)
6
- if can_rate? user_id, dimension
7
- rates(dimension).build do |r|
4
+
5
+ def rate(stars, user, dimension=nil, dirichlet_method=false)
6
+ dimension = nil if dimension.blank?
7
+
8
+ if can_rate? user, dimension
9
+ rates(dimension).create! do |r|
8
10
  r.stars = stars
9
- r.rater_id = user_id
10
- r.save!
11
- end
12
- update_rate_average(stars, dimension)
11
+ r.rater = user
12
+ end
13
+ if dirichlet_method
14
+ update_rate_average_dirichlet(stars, dimension)
15
+ else
16
+ update_rate_average(stars, dimension)
17
+ end
13
18
  else
14
- raise "User has already rated."
19
+ raise "User has already rated."
15
20
  end
16
- end
17
-
21
+ end
22
+
23
+ def update_rate_average_dirichlet(stars, dimension=nil)
24
+ ## assumes 5 possible vote categories
25
+ dp = {1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1}
26
+ stars_group = Hash[rates(dimension).group(:stars).count.map{|k,v| [k.to_i,v] }]
27
+ posterior = dp.merge(stars_group){|key, a, b| a + b}
28
+ sum = posterior.map{ |i, v| v }.inject { |a, b| a + b }
29
+ davg = posterior.map{ |i, v| i * v }.inject { |a, b| a + b }.to_f / sum
30
+
31
+ if average(dimension).nil?
32
+ RatingCache.create! do |avg|
33
+ avg.cacheable_id = self.id
34
+ avg.cacheable_type = self.class.name
35
+ avg.qty = 1
36
+ avg.avg = davg
37
+ avg.dimension = dimension
38
+ end
39
+ else
40
+ a = average(dimension)
41
+ a.qty = rates(dimension).count
42
+ a.avg = davg
43
+ a.save!(validate: false)
44
+ end
45
+ end
46
+
18
47
  def update_rate_average(stars, dimension=nil)
19
48
  if average(dimension).nil?
20
- RatingCache.create do |avg|
49
+ RatingCache.create! do |avg|
21
50
  avg.cacheable_id = self.id
22
51
  avg.cacheable_type = self.class.name
23
52
  avg.avg = stars
24
53
  avg.qty = 1
25
54
  avg.dimension = dimension
26
- avg.save!
27
- end
55
+ end
28
56
  else
29
57
  a = average(dimension)
30
- a.avg = (a.avg*a.qty + stars) / (a.qty+1)
31
- a.qty = a.qty + 1
32
- a.save!
33
- end
34
- end
35
-
58
+ a.qty = rates(dimension).count
59
+ a.avg = rates(dimension).average(:stars)
60
+ a.save!(validate: false)
61
+ end
62
+ end
63
+
36
64
  def average(dimension=nil)
37
- if dimension.nil?
38
- self.send "rate_average_without_dimension"
39
- else
40
- self.send "#{dimension}_average"
41
- end
42
- end
43
-
44
- def can_rate?(user_id, dimension=nil)
45
- val = self.connection.select_value("select count(*) as cnt from rates where rateable_id=#{self.id} and rateable_type='#{self.class.name}' and rater_id=#{user_id} and dimension='#{dimension}'").to_i
46
- if val == 0
47
- true
48
- else
49
- false
50
- end
51
- end
52
-
65
+ dimension ? self.send("#{dimension}_average") : rate_average_without_dimension
66
+ end
67
+
68
+ def can_rate?(user, dimension=nil)
69
+ user.ratings_given.where(dimension: dimension, rateable_id: id, rateable_type: self.class.name).size.zero?
70
+ end
71
+
53
72
  def rates(dimension=nil)
54
- if dimension.nil?
55
- self.send "rates_without_dimension"
56
- else
57
- self.send "#{dimension}_rates"
58
- end
73
+ dimension ? self.send("#{dimension}_rates") : rates_without_dimension
59
74
  end
60
-
75
+
61
76
  def raters(dimension=nil)
62
- if dimension.nil?
63
- self.send "raters_without_dimension"
64
- else
65
- self.send "#{dimension}_raters"
66
- end
77
+ dimension ? self.send("#{dimension}_raters") : raters_without_dimension
67
78
  end
68
79
 
69
80
  module ClassMethods
70
-
81
+
71
82
  def letsrate_rater
72
- has_many :ratings_given, :class_name => "Rate", :foreign_key => :rater_id
73
- end
74
-
83
+ has_many :ratings_given, :class_name => "Rate", :foreign_key => :rater_id
84
+ end
85
+
75
86
  def letsrate_rateable(*dimensions)
76
- has_many :rates_without_dimension, :as => :rateable, :class_name => "Rate", :dependent => :destroy, :conditions => {:dimension => nil}
77
- has_many :raters_without_dimension, :through => :rates_without_dimension, :source => :rater
78
-
79
- has_one :rate_average_without_dimension, :as => :cacheable, :class_name => "RatingCache",
80
- :dependent => :destroy, :conditions => {:dimension => nil}
81
-
82
-
83
- dimensions.each do |dimension|
84
- has_many "#{dimension}_rates", :dependent => :destroy,
85
- :conditions => {:dimension => dimension.to_s},
86
- :class_name => "Rate",
87
- :as => :rateable
88
-
89
- has_many "#{dimension}_raters", :through => "#{dimension}_rates", :source => :rater
90
-
91
- has_one "#{dimension}_average", :as => :cacheable, :class_name => "RatingCache",
92
- :dependent => :destroy, :conditions => {:dimension => dimension.to_s}
93
- end
87
+ has_many :rates_without_dimension, -> { where dimension: nil}, :as => :rateable, :class_name => "Rate", :dependent => :destroy
88
+ has_many :raters_without_dimension, :through => :rates_without_dimension, :source => :rater
89
+
90
+ has_one :rate_average_without_dimension, -> { where dimension: nil}, :as => :cacheable,
91
+ :class_name => "RatingCache", :dependent => :destroy
92
+
93
+
94
+ dimensions.each do |dimension|
95
+ has_many "#{dimension}_rates".to_sym, -> {where dimension: dimension.to_s},
96
+ :dependent => :destroy,
97
+ :class_name => "Rate",
98
+ :as => :rateable
99
+
100
+ has_many "#{dimension}_raters".to_sym, :through => "#{dimension}_rates", :source => :rater
101
+
102
+ has_one "#{dimension}_average".to_sym, -> { where dimension: dimension.to_s },
103
+ :as => :cacheable, :class_name => "RatingCache",
104
+ :dependent => :destroy
105
+ end
94
106
  end
95
107
  end
96
-
97
- end
108
+
109
+ end
98
110
 
99
111
  class ActiveRecord::Base
100
112
  include Letsrate
101
- end
113
+ end
@@ -1,3 +1,3 @@
1
1
  module Letsrate
2
- VERSION = "1.0.8"
2
+ VERSION = "1.0.9"
3
3
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: letsrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
5
- prerelease:
4
+ version: 1.0.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - Murat GUZEL
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-18 00:00:00.000000000 Z
11
+ date: 2014-01-02 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Provides the best solution to add rating functionality to your models.
15
14
  email:
@@ -30,7 +29,7 @@ files:
30
29
  - lib/generators/letsrate/templates/cache_migration.rb
31
30
  - lib/generators/letsrate/templates/cache_model.rb
32
31
  - lib/generators/letsrate/templates/jquery.raty.js
33
- - lib/generators/letsrate/templates/letsrate.js
32
+ - lib/generators/letsrate/templates/letsrate.js.erb
34
33
  - lib/generators/letsrate/templates/migration.rb
35
34
  - lib/generators/letsrate/templates/model.rb
36
35
  - lib/generators/letsrate/templates/rater_controller.rb
@@ -43,26 +42,25 @@ files:
43
42
  - lib/letsrate/version.rb
44
43
  homepage: http://github.com/muratguzel/letsrate
45
44
  licenses: []
45
+ metadata: {}
46
46
  post_install_message:
47
47
  rdoc_options: []
48
48
  require_paths:
49
49
  - lib
50
50
  required_ruby_version: !ruby/object:Gem::Requirement
51
- none: false
52
51
  requirements:
53
- - - ! '>='
52
+ - - '>='
54
53
  - !ruby/object:Gem::Version
55
54
  version: '0'
56
55
  required_rubygems_version: !ruby/object:Gem::Requirement
57
- none: false
58
56
  requirements:
59
- - - ! '>='
57
+ - - '>='
60
58
  - !ruby/object:Gem::Version
61
59
  version: '0'
62
60
  requirements: []
63
61
  rubyforge_project: letsrate
64
- rubygems_version: 1.8.24
62
+ rubygems_version: 2.0.3
65
63
  signing_key:
66
- specification_version: 3
64
+ specification_version: 4
67
65
  summary: Provides the best solution to add rating functionality to your models.
68
66
  test_files: []
@@ -1,27 +0,0 @@
1
- $.fn.raty.defaults.path = "/assets";
2
- $.fn.raty.defaults.half_show = true;
3
-
4
- $(function(){
5
- $(".star").raty({
6
- score: function(){
7
- return $(this).attr('data-rating')
8
- },
9
- number: function() {
10
- return $(this).attr('data-star-count')
11
- },
12
- click: function(score, evt) {
13
- $.post('<%= Rails.application.class.routes.url_helpers.rate_path %>',
14
- {
15
- score: score,
16
- dimension: $(this).attr('data-dimension'),
17
- id: $(this).attr('data-id'),
18
- klass: $(this).attr('data-classname')
19
- },
20
- function(data) {
21
- if(data) {
22
- // success code goes here ...
23
- }
24
- });
25
- }
26
- });
27
- });