achiever 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -0
- data/LICENSE +20 -0
- data/README.markdown +25 -0
- data/Rakefile +10 -0
- data/init.rb +1 -0
- data/lib/achiever.rb +6 -0
- data/lib/achiever/achievement.rb +11 -0
- data/lib/achiever/achiever.rb +26 -0
- data/spec/spec_helper.rb +20 -0
- metadata +75 -0
data/Gemfile
ADDED
File without changes
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Achiever
|
2
|
+
========
|
3
|
+
|
4
|
+
Achiever is a simple way to add achievements into your rails application.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
In *Rails 3*, add this to your Gemfile and run bundle install.
|
10
|
+
|
11
|
+
gem "achiever"
|
12
|
+
|
13
|
+
Run the migration
|
14
|
+
|
15
|
+
bundle exec rake db:migrate
|
16
|
+
|
17
|
+
Getting Started
|
18
|
+
---------------
|
19
|
+
|
20
|
+
1. Define your achievements
|
21
|
+
|
22
|
+
achieves :award, :for => :user
|
23
|
+
|
24
|
+
|
25
|
+
|
data/Rakefile
ADDED
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'achiever'
|
data/lib/achiever.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Achiever
|
2
|
+
|
3
|
+
ALL_ACHIEVEMENTS = []
|
4
|
+
|
5
|
+
def achieves(award, options={})
|
6
|
+
ALL_ACHIEVEMENTS << award
|
7
|
+
|
8
|
+
user = options[:for]
|
9
|
+
|
10
|
+
class_eval <<-EOF
|
11
|
+
after_save :award_#{award.to_s}?
|
12
|
+
|
13
|
+
def award_#{award.to_s}?
|
14
|
+
achievement = Achievements::#{award.to_s.camelize}.new :user => self.#{user}
|
15
|
+
achievement.model = self
|
16
|
+
|
17
|
+
if achievement.award?
|
18
|
+
achievement.save
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
EOF
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
Bundler.require(:default)
|
5
|
+
|
6
|
+
require 'supermodel'
|
7
|
+
require 'active_support/all'
|
8
|
+
require 'achiever/achiever'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
12
|
+
config.filter_run :focus => true
|
13
|
+
config.run_all_when_everything_filtered = true
|
14
|
+
config.mock_with :rr
|
15
|
+
config.before(:each) do
|
16
|
+
Project.delete_all
|
17
|
+
Category.delete_all
|
18
|
+
end
|
19
|
+
config.extend WithModel
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: achiever
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Scott Raio
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70316751757740 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.6.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70316751757740
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rails
|
27
|
+
requirement: &70316751757100 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.2.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70316751757100
|
36
|
+
description: Achiever is a simple way to add achievements into your rails application.
|
37
|
+
email: scottraio@gmail.com
|
38
|
+
executables: []
|
39
|
+
extensions: []
|
40
|
+
extra_rdoc_files: []
|
41
|
+
files:
|
42
|
+
- lib/achiever/achievement.rb
|
43
|
+
- lib/achiever/achiever.rb
|
44
|
+
- lib/achiever.rb
|
45
|
+
- spec/spec_helper.rb
|
46
|
+
- Gemfile
|
47
|
+
- LICENSE
|
48
|
+
- Rakefile
|
49
|
+
- README.markdown
|
50
|
+
- init.rb
|
51
|
+
homepage: http://github.com/scottraio/achiever
|
52
|
+
licenses: []
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.3.4
|
69
|
+
requirements: []
|
70
|
+
rubyforge_project: achiever
|
71
|
+
rubygems_version: 1.8.15
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Achiever is a simple way to add achievements into your rails application.
|
75
|
+
test_files: []
|