star_ratings 0.0.1.alpha

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in star_ratings.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # StarRatings
2
+
3
+ Display 5 star rating rating in your app.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'star_ratings'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install star_ratings
19
+
20
+ ## Usage
21
+
22
+ This gem displays 5 star rating in a view. once you install this gem, you get a helper method called as "render_stars". All you need to do is pass a number or float inside this method as an argument and it will display the star rating image for you.
23
+
24
+ It will also round the rating so if you pass 2.21 as the rating it will display 2 stars.
25
+
26
+
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it ( http://github.com/Manik-Ratnas/star_ratings/fork )
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
Binary file
@@ -0,0 +1,48 @@
1
+ .stars{
2
+ background-image: url('star_ratings.png');
3
+ background-repeat: no-repeat;
4
+ text-indent: -9999px;
5
+ height:20px;
6
+ }
7
+
8
+ .stars.rating_0_5{
9
+ background-position: 0 -18px;
10
+ }
11
+
12
+ .stars.rating_1_0{
13
+ background-position: 0 -37px;
14
+ }
15
+
16
+
17
+ .stars.rating_1_5{
18
+ background-position: 0 -56px;
19
+ }
20
+
21
+ .stars.rating_2_0{
22
+ background-position: 0 -76px;
23
+ }
24
+
25
+ .stars.rating_2_5{
26
+ background-position: 0 -96px;
27
+ }
28
+
29
+ .stars.rating_3_0{
30
+ background-position: 0 -115px;
31
+ }
32
+
33
+ .stars.rating_3_5{
34
+ background-position: 0 -134px;
35
+ }
36
+
37
+ .stars.rating_4_0{
38
+ background-position: 0 -154px;
39
+ }
40
+
41
+ .stars.rating_4_5{
42
+ background-position: 0 -173px;
43
+ }
44
+
45
+ .stars.rating_5_0{
46
+ background-position: 0 -193px;
47
+ }
48
+
@@ -0,0 +1,23 @@
1
+ module StarsRenderer
2
+
3
+ def render_stars(rating)
4
+ p 'ratinggg ==========> ', rating
5
+ do_render_stars(rating, self)
6
+ end
7
+
8
+ private
9
+ def do_render_stars(rating,template)
10
+ @template = template
11
+ content_tag :div, "&nbsp", :class => "stars rating_#{round_rating(rating).to_s.gsub(".", "_")}"
12
+ end
13
+
14
+ def method_missing(*args, &block)
15
+ @template.send(*args, &block)
16
+ end
17
+
18
+ def round_rating(rating)
19
+ (rating * 2.0).round / 2.0
20
+ end
21
+
22
+ end
23
+ ActionView::Base.send(:include,StarsRenderer)
@@ -0,0 +1,3 @@
1
+ module StarRatings
2
+ VERSION = "0.0.1.alpha"
3
+ end
@@ -0,0 +1,14 @@
1
+ require "star_ratings/version"
2
+ require "star_ratings/star_renderer"
3
+
4
+ module StarRating
5
+ class Engine < Rails::Engine
6
+ initializer :assets do |config|
7
+ Rails.application.config.assets.precompile += %w( /app/assets/styleseets/print.css /app/assets/images/star_ratings.png )
8
+ end
9
+
10
+
11
+ end
12
+ end
13
+
14
+
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'star_ratings/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "star_ratings"
8
+ spec.version = StarRatings::VERSION
9
+ spec.authors = ["Manish Puri"]
10
+ spec.email = ["manishspuri@gmail.com"]
11
+ spec.summary = %q{A simple engine to display star ratings in rails}
12
+ spec.description = %q{A simple engine to display star ratings in rails}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rails"
24
+
25
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: star_ratings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.alpha
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Manish Puri
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-02-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.5'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.5'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rails
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: A simple engine to display star ratings in rails
63
+ email:
64
+ - manishspuri@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - app/assets/images/star_ratings.png
75
+ - app/assets/stylesheets/star_ratings.css.erb
76
+ - lib/star_ratings.rb
77
+ - lib/star_ratings/star_renderer.rb
78
+ - lib/star_ratings/version.rb
79
+ - star_ratings.gemspec
80
+ homepage: ''
81
+ licenses:
82
+ - MIT
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>'
97
+ - !ruby/object:Gem::Version
98
+ version: 1.3.1
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 1.8.23
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: A simple engine to display star ratings in rails
105
+ test_files: []