Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
Conflicts:
	README.md
	lib/generators/ratyrate/templates/ratyrate.js.erb
	lib/ratyrate/helpers.rb
  • Loading branch information
wazery committed Aug 13, 2014
2 parents 767f8b0 + 58b599d commit 22fdf05
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--color
--format documentation
--warnings
--require spec_helper
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ This is a fork against the repository [muratguzel/ratyrate](https://github.com/m

1. Write RSpec tests for this Gem
2. Create a Heroku app to illustrate this Gem's purpose and features (MovieStore)
3. Add option to show the number of users who gave rates
4. Add a share helper to Facebook, Twitter
3. Write a complete tutorial on SitePoint that illustrates how to use this gem
4. Add option to show the number of users who gave rates
5. Add a share helper to Facebook, Twitter

## Detailed view of the new features

Expand Down Expand Up @@ -115,38 +116,44 @@ Speed : <%= rating_for @car, "speed", :star => 10 %>
Speed : <%= rating_for @car, "engine", :star => 7 %>
Speed : <%= rating_for @car, "price" %>
```
2- To enable half stars use the option *enable_half*
2- If you want to disable/enable the rating after user's first rate use the new option *disable_after_rate*
```erb
Speed : <%= rating_for @car, "speed", :disable_after_rate => true %>
```
To enable changes after first user rate set ```disable_after_rate``` to false

3- To enable half stars use the option *enable_half*
```erb
Speed : <%= rating_for @car, "speed", :enable_half => true %>
```
3- To show or hide the half stars use *half_show*
4- To show or hide the half stars use *half_show*
```erb
Speed : <%= rating_for @car, "speed", :half_show => true %>
```
4- To change the path in which the star images (star-on.png, star-off.png, star-half.png, ..etc) are located use
5- To change the path in which the star images (star-on.png, star-off.png, star-half.png, ..etc) are located use
```erb
Speed : <%= rating_for @car, "speed", :star_path => true %>
```

To just change one of the star images choose from these options (star_on, star_off, star_half)

5- To add the cancel button to the left, or right of the stars use **(default is false)**
6- To add the cancel button to the left, or right of the stars use **(default is false)**
```erb
Speed : <%= rating_for @car, "speed", :cancel => true %>
```
6- To change the place of the cancel button (left, or right) use **(default is left)**
7- To change the place of the cancel button (left, or right) use **(default is left)**
```erb
Speed : <%= rating_for @car, "speed", :cancel_place => left %>
```
7- To change the hint on the cancel button use **(default is "Cancel current rating!" )**
8- To change the hint on the cancel button use **(default is "Cancel current rating!" )**
```erb
Speed : <%= rating_for @car, "speed", :cancel_hint => "Cancel this rating!" %>
```
8- To change the image of the cancel on button use
9- To change the image of the cancel on button use
```erb
Speed : <%= rating_for @car, "speed", :cancel_on => "cancel-on2.png" %>
```
9- To change the image of the cancel off use
10- To change the image of the cancel off use
```erb
Speed : <%= rating_for @car, "speed", :cancel_off => "cancel-off2.png" %>
```
Expand Down
13 changes: 8 additions & 5 deletions lib/generators/ratyrate/templates/ratyrate.js.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
$.fn.raty.defaults.path = "/assets";
$.fn.raty.defaults.half_show = true;
$.fn.raty.defaults.half = false;
$.fn.raty.defaults.halfShow = false;
$.fn.raty.defaults.path = "/assets";
$.fn.raty.defaults.cancel = false;

$(function(){
$(".star").each(function() {
var $readonly = ($(this).attr('data-readonly') == 'true');
var $half = ($(this).attr('data-enable-half') == 'true');
var $halfShow = ($(this).attr('data-half-show') == 'true');
var $single = ($(this).attr('data-single') == 'true');
$(this).raty({
score: function() {
return $(this).attr('data-rating')
},
number: function() {
return $(this).attr('data-star-count')
},
half: $(this).attr('data-enable-half'),
half_show: $(this).attr('data-half-show'),
half: $half,
halfShow: $halfShow,
single: $single,
path: $(this).attr('data-star-path'),
starOn: $(this).attr('data-star-on'),
starOff: $(this).attr('data-star-off'),
Expand All @@ -27,7 +31,6 @@ $(function(){
noRatedMsg: $(this).attr('data-no-rated-message'),
round: $(this).attr('data-round'),
space: $(this).attr('data-space'),
// single: $(this).attr('data-single'),
target: $(this).attr('data-target'),
targetText: $(this).attr('data-target-text'),
targetType: $(this).attr('data-target-type'),
Expand Down
10 changes: 5 additions & 5 deletions lib/ratyrate/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def rating_for(rateable_obj, dimension=nil, options={})
avg = cached_average ? cached_average.avg : 0

star = options[:star] || 5
enable_half = options[:enable_half] || true
half_show = options[:half_show] || true
enable_half = options[:enable_half] || false
half_show = options[:half_show] || false
star_path = options[:star_path] || "/assets"
star_on = options[:star_on] || "star-on.png"
star_off = options[:star_off] || "star-off.png"
Expand All @@ -32,7 +32,7 @@ def rating_for(rateable_obj, dimension=nil, options={})
if disable_after_rate
readonly = !(current_user && rateable_obj.can_rate?(current_user, dimension))
else
readonly = false
readonly = !current_user || false
end

if options[:imdb_avg] && readonly
Expand Down Expand Up @@ -83,8 +83,8 @@ def rating_for_user(rateable_obj, rating_user, dimension = nil, options = {})
stars = @rating ? @rating.stars : 0

star = options[:star] || 5
enable_half = options[:enable_half] || true
half_show = options[:half_show] || true
enable_half = options[:enable_half] || false
half_show = options[:half_show] || false
star_path = options[:star_path] || "/assets"
star_on = options[:star_on] || "star-on.png"
star_off = options[:star_off] || "star-off.png"
Expand Down
Binary file added ratyrate-1.0.9.gem
Binary file not shown.
9 changes: 9 additions & 0 deletions spec/ratyrate_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'spec_helper'

describe Ratyrate do
describe ".model" do
it "is rateable" do

end
end
end
78 changes: 78 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause this
# file to always be loaded, without a need to explicitly require it in any files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, make a
# separate helper file that requires this one and then use it only in the specs
# that actually need it.
#
# The `.rspec` file also contains a few flags that are not defaults but that
# users commonly want.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
=begin
# These two settings work together to allow you to limit a spec run
# to individual examples or groups you care about by tagging them with
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
# get run.
config.filter_run :focus
config.run_all_when_everything_filtered = true
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = 'doc'
end
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random
# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# Enable only the newer, non-monkey-patching expect syntax.
# For more details, see:
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
expectations.syntax = :expect
end
# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# Enable only the newer, non-monkey-patching expect syntax.
# For more details, see:
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
mocks.syntax = :expect
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended.
mocks.verify_partial_doubles = true
end
=end
end

0 comments on commit 22fdf05

Please sign in to comment.