minimal_feedback 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -1,24 +1,44 @@
1
- # MinimalFeedback
1
+ # MinimalFeedback[![Build Status](https://secure.travis-ci.org/issuehunter/minimal_feedback.png)](http://travis-ci.org/issuehunter/minimal_feedback)
2
2
 
3
- TODO: Write a gem description
3
+ Feedback functionalities for ActiveRecord models
4
4
 
5
- ## Installation
5
+ ## Usage
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Add to Gemfile:
8
8
 
9
- gem 'minimal_feedback'
9
+ ```ruby
10
+ gem 'minimal_feedback'
11
+ ```
10
12
 
11
- And then execute:
13
+ Run:
12
14
 
13
- $ bundle
15
+ ```ruby
16
+ bundle install
17
+ rails generate minimal_state_machine
18
+ rake db:migrate
19
+ ```
14
20
 
15
- Or install it yourself as:
21
+ ## Quick Start
16
22
 
17
- $ gem install minimal_feedback
23
+ Let's say we have an Issue ActiveRecord model and we want to be able to give it feedback
18
24
 
19
- ## Usage
25
+ ```ruby
26
+ class Issue < ActiveRecord::Base
27
+ end
28
+ ```
29
+
30
+ What would happen with this configuration:
31
+
32
+ ```ruby
33
+ issue = Issue.create
34
+ issue.give_feedback(:positive)
35
+ issue.feedbacks.first.type
36
+ => :positive
20
37
 
21
- TODO: Write usage instructions here
38
+ issue.give_feedback(:negative)
39
+ issue.feedbacks.last.type
40
+ => :negative
41
+ ```
22
42
 
23
43
  ## Contributing
24
44
 
@@ -1,3 +1,3 @@
1
1
  module MinimalFeedback
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -8,6 +8,8 @@ module MinimalFeedback
8
8
  included do
9
9
  has_many :feedbacks, :as => :rateable, :class_name => 'MinimalFeedback::Feedback'
10
10
 
11
+ class InvalidFeedbackError < StandardError; end
12
+
11
13
  def give_feedback(type)
12
14
  feedback_type = type.to_sym
13
15
  case feedback_type
@@ -15,6 +17,8 @@ module MinimalFeedback
15
17
  Feedback.create(:rating => 1) { |f| f.rateable = self }
16
18
  when :negative
17
19
  Feedback.create(:rating => -1) { |f| f.rateable = self }
20
+ else
21
+ raise InvalidFeedbackError
18
22
  end
19
23
  end
20
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minimal_feedback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  segments:
145
145
  - 0
146
- hash: -4218162571524871835
146
+ hash: 4159579160644425485
147
147
  required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  none: false
149
149
  requirements:
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  version: '0'
153
153
  segments:
154
154
  - 0
155
- hash: -4218162571524871835
155
+ hash: 4159579160644425485
156
156
  requirements: []
157
157
  rubyforge_project:
158
158
  rubygems_version: 1.8.24