letsrate 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ - jruby-19mode # JRuby in 1.9 mode
6
+ - rbx-18mode
7
+ - rbx-19mode
8
+ # uncomment this line if your project needs to run something other than `rake`:
9
+ # script: bundle exec rspec spec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rateme (1.0.3)
4
+ letsrate (1.0.8)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -61,4 +61,4 @@ PLATFORMS
61
61
 
62
62
  DEPENDENCIES
63
63
  jquery-rails
64
- rateme!
64
+ letsrate!
data/README.md CHANGED
@@ -1,10 +1,14 @@
1
- # Letsrate Rating Gem
1
+ # Letsrate Rating Gem
2
2
 
3
3
  Provides the best way to add rating capabilites to your Rails application with jQuery Raty plugin.
4
4
 
5
+ [![Build Status](https://secure.travis-ci.org/muratguzel/letsrate.png)](http://travis-ci.org/muratguzel/letsrate)
6
+ [![Dependency Status](https://gemnasium.com/muratguzel/letsrate.png)](https://gemnasium.com/muratguzel/letsrate)
7
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/muratguzel/letsrate)
8
+
5
9
  ## Repository
6
10
 
7
- Find it at [github.com/muratguzel/letsrate](github.com/muratguzel/letsrate)
11
+ Find it at [github.com/muratguzel/letsrate](https://github.com/muratguzel/letsrate)
8
12
 
9
13
  ## Instructions
10
14
 
@@ -12,82 +16,100 @@ Find it at [github.com/muratguzel/letsrate](github.com/muratguzel/letsrate)
12
16
 
13
17
  Add the letsrate gem into your Gemfile
14
18
 
15
- gem 'letsrate'
16
-
19
+ ```ruby
20
+ gem 'letsrate'
21
+ ```
22
+
17
23
  ### Generate
18
24
 
19
- rails g letsrate User
25
+ ```
26
+ rails g letsrate User
27
+ ```
20
28
 
21
29
  The generator takes one argument which is the name of your existing devise user model UserModelName. This is necessary to bind the user and rating datas.
22
30
  Also the generator copies necessary files (jquery raty plugin files, star icons and javascripts)
23
31
 
24
- Example:
32
+ Example:
33
+
34
+ Suppose you will have a devise user model which name is User. The devise generator and letsrate generator should be like below
25
35
 
26
- Suppose you will have a devise user model which name is User. The generator should be like below
36
+ ```
37
+ rails g devise:install
38
+ rails g devise user
27
39
 
28
- rails g letsrate user # => user is the model generated by devise
29
-
30
- This generator will create Rate and RatingCache models and link to your user model.
40
+ rails g letsrate user # => user is the model generated by devise
41
+ ```
42
+
43
+ This generator will create Rate and RatingCache models and link to your user model.
31
44
 
32
45
  ### Prepare
33
46
 
34
- I suppose you have a car model
47
+ I suppose you have a car model
35
48
 
36
- rails g model car name:string
49
+ ```
50
+ rails g model car name:string
51
+ ```
37
52
 
38
53
  You should add the letsrate_rateable function with its dimensions option. You can add multiple dimensions.
39
54
 
40
- class Car < ActiveRecord::Base
41
- letsrate_rateable "speed", "engine", "price"
42
- end
43
-
44
- Then you need to add a call letsrate_rater in the user model.
45
-
46
- class User < ActiveRecord::Base
47
- letsrate_rater
48
- end
49
-
50
-
55
+ ```ruby
56
+ class Car < ActiveRecord::Base
57
+ letsrate_rateable "speed", "engine", "price"
58
+ end
59
+ ```
60
+
61
+ Then you need to add a call letsrate_rater in the user model.
62
+
63
+ ```ruby
64
+ class User < ActiveRecord::Base
65
+ letsrate_rater
66
+ end
67
+ ```
68
+
51
69
  ### Using
52
70
 
53
- There is a helper method which name is rating_for to add the star links. By default rating_for will display the average rating and accept the
54
- new rating value from authenticated user.
71
+ There is a helper method which name is rating_for to add the star links. By default rating_for will display the average rating and accept the
72
+ new rating value from authenticated user.
73
+
74
+ ```erb
75
+ <%# show.html.erb -> /cars/1 %>
55
76
 
56
- #show.html.erb -> /cars/1
57
-
58
- Speed : <%= rating_for @car, "speed" %>
59
- Engine : <%= rating_for @car, "engine" %>
60
- Price : <%= rating_for @car, "price" %>
77
+ Speed : <%= rating_for @car, "speed" %>
78
+ Engine : <%= rating_for @car, "engine" %>
79
+ Price : <%= rating_for @car, "price" %>
80
+ ```
61
81
 
62
82
  If you need to change the star number, you should use star option like below.
63
-
64
- Speed : <%= rating_for @car, "speed", :star => 10 %>
65
- Speed : <%= rating_for @car, "speed", :star => 7 %>
66
- Speed : <%= rating_for @car, "speed" %>
67
-
68
- ### Important
69
-
70
- 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
83
+
84
+ ```erb
85
+ Speed : <%= rating_for @car, "speed", :star => 10 %>
86
+ Speed : <%= rating_for @car, "engine", :star => 7 %>
87
+ Speed : <%= rating_for @car, "price" %>
88
+ ```
89
+
90
+ ### Important
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
71
93
  as you will.
72
94
 
73
- #rater_controller.rb
74
-
75
- def create
76
- if current_user.present?
77
- obj = eval "#{params[:klass]}.find(#{params[:id]})"
78
- if params[:dimension].present?
79
- obj.rate params[:score].to_i, current_user.id, "#{params[:dimension]}"
80
- else
81
- obj.rate params[:score].to_i, current_user.id
82
- end
83
-
84
- render :json => true
85
- else
86
- render :json => false
87
- end
88
- end
89
-
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
112
+ ```
113
+
90
114
  ## Feedback
91
- If you find bugs please open a ticket at [github.com/muratguzel/letsrate/issues](github.com/muratguzel/letsrate/issues)
92
-
93
-
115
+ If you find bugs please open a ticket at [https://github.com/muratguzel/letsrate/issues](https://github.com/muratguzel/letsrate/issues)
data/Rakefile CHANGED
@@ -1 +1,12 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ desc "Bundle the gem"
4
+ task :bundle do
5
+ sh('bundle install')
6
+ sh 'gem build *.gemspec'
7
+ sh 'gem install *.gem'
8
+ sh 'rm *.gem'
9
+ end
10
+
11
+ task(:default).clear
12
+ task :default => :bundle
data/letsrate.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Letsrate::VERSION
8
8
  s.authors = ["Murat GUZEL"]
9
9
  s.email = ["guzelmurat@gmail.com"]
10
- s.homepage = ""
10
+ s.homepage = "http://github.com/muratguzel/letsrate"
11
11
  s.summary = %q{Provides the best solution to add rating functionality to your models.}
12
12
  s.description = %q{Provides the best solution to add rating functionality to your models.}
13
13
 
@@ -27,7 +27,7 @@ module Letsrate
27
27
  end
28
28
  else
29
29
  a = average(dimension)
30
- a.avg = (a.avg + stars) / (a.qty+1)
30
+ a.avg = (a.avg*a.qty + stars) / (a.qty+1)
31
31
  a.qty = a.qty + 1
32
32
  a.save!
33
33
  end
@@ -1,3 +1,3 @@
1
1
  module Letsrate
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: letsrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-07 00:00:00.000000000 Z
12
+ date: 2013-01-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Provides the best solution to add rating functionality to your models.
15
15
  email:
@@ -18,14 +18,13 @@ executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
- - .DS_Store
22
21
  - .gitignore
22
+ - .travis.yml
23
23
  - Gemfile
24
24
  - Gemfile.lock
25
25
  - README.md
26
26
  - Rakefile
27
27
  - letsrate.gemspec
28
- - lib/.DS_Store
29
28
  - lib/generators/letsrate/USAGE
30
29
  - lib/generators/letsrate/letsrate_generator.rb
31
30
  - lib/generators/letsrate/templates/cache_migration.rb
@@ -42,7 +41,7 @@ files:
42
41
  - lib/letsrate/helpers.rb
43
42
  - lib/letsrate/model.rb
44
43
  - lib/letsrate/version.rb
45
- homepage: ''
44
+ homepage: http://github.com/muratguzel/letsrate
46
45
  licenses: []
47
46
  post_install_message:
48
47
  rdoc_options: []