go_gamification 0.0.7 → 0.0.13
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.
- checksums.yaml +4 -4
- data/app/assets/images/go_gamification/hair.png +0 -0
- data/app/assets/images/go_gamification/head.png +0 -0
- data/app/assets/images/go_gamification/leftArm-jump.png +0 -0
- data/app/assets/images/go_gamification/leftArm.png +0 -0
- data/app/assets/images/go_gamification/legs-jump.png +0 -0
- data/app/assets/images/go_gamification/legs.png +0 -0
- data/app/assets/images/go_gamification/rightArm-jump.png +0 -0
- data/app/assets/images/go_gamification/rightArm.png +0 -0
- data/app/assets/images/go_gamification/torso.png +0 -0
- data/app/assets/javascripts/go_gamification/character.js.erb +193 -0
- data/app/assets/javascripts/go_gamification/excanvas.js +924 -0
- data/app/controllers/gamification/levels_controller.rb +63 -0
- data/app/controllers/gamification/rewards_controller.rb +51 -0
- data/app/helpers/{go_gamification → gamification}/application_helper.rb +1 -1
- data/app/helpers/gamification/rewards_helper.rb +6 -0
- data/app/models/application_record.rb +3 -0
- data/app/models/gamification.rb +6 -0
- data/{lib/go_gamification/concerns/models → app/models/gamification}/goal.rb +3 -7
- data/app/models/gamification/level.rb +6 -0
- data/app/models/gamification/medal.rb +7 -0
- data/{lib/go_gamification/concerns/models → app/models/gamification}/reward.rb +3 -5
- data/app/uploaders/{go_gamification → gamification}/image_uploader.rb +1 -1
- data/app/views/gamification/levels/_form.html.erb +17 -0
- data/app/views/gamification/levels/edit.html.erb +6 -0
- data/app/views/gamification/levels/index.html.erb +24 -0
- data/app/views/gamification/levels/new.html.erb +5 -0
- data/app/views/gamification/levels/show.html.erb +4 -0
- data/app/views/{go_gamification → gamification}/rewards/_presentation.html.erb +2 -0
- data/app/views/{go_gamification → gamification}/rewards/_reward.html.erb +1 -1
- data/app/views/{go_gamification → gamification}/scorings/create.html.erb +0 -0
- data/config/initializers/assets.rb +2 -0
- data/config/routes.rb +5 -1
- data/db/migrate/20171020181447_create_go_gamification_tasks.rb +1 -1
- data/db/migrate/20171020181620_create_go_gamification_scorings.rb +2 -2
- data/db/migrate/20171020182027_rename_everything.rb +5 -5
- data/db/migrate/20171020182119_create_go_gamification_medals.rb +1 -1
- data/db/migrate/20171020182210_add_description_to_go_gamification_medals.rb +1 -1
- data/db/migrate/20171020182248_rename_go_gamification_tasks_to_goals.rb +3 -3
- data/db/migrate/20171020182329_add_seen_at_to_go_gamification_rewards.rb +2 -2
- data/db/migrate/20171023230506_create_go_gamification_levels.rb +9 -0
- data/lib/go_gamification.rb +1 -3
- data/lib/go_gamification/engine.rb +2 -19
- data/lib/go_gamification/version.rb +1 -1
- metadata +49 -25
- data/app/controllers/go_gamification/application_controller.rb +0 -4
- data/app/controllers/go_gamification/rewards_controller.rb +0 -7
- data/app/helpers/go_gamification/rewards_helper.rb +0 -20
- data/app/models/go_gamification/goal.rb +0 -5
- data/app/models/go_gamification/medal.rb +0 -5
- data/app/models/go_gamification/reward.rb +0 -5
- data/lib/go_gamification/activerecord.rb +0 -13
- data/lib/go_gamification/checksum.rb +0 -28
- data/lib/go_gamification/concerns.rb +0 -6
- data/lib/go_gamification/concerns/controllers.rb +0 -3
- data/lib/go_gamification/concerns/controllers/rewards_controller.rb +0 -55
- data/lib/go_gamification/concerns/models.rb +0 -5
- data/lib/go_gamification/concerns/models/medal.rb +0 -13
- data/lib/go_gamification/concerns/rewardable.rb +0 -12
- data/lib/go_gamification/concerns/rewarding.rb +0 -7
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_gamification
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- João Carlos Ottobboni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: draper
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: carrierwave
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sqlite3
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: go_gamification engine
|
56
70
|
email:
|
57
71
|
- jcottobboni@gmail.com
|
@@ -61,17 +75,37 @@ extra_rdoc_files: []
|
|
61
75
|
files:
|
62
76
|
- MIT-LICENSE
|
63
77
|
- Rakefile
|
64
|
-
- app/
|
65
|
-
- app/
|
66
|
-
- app/
|
67
|
-
- app/
|
68
|
-
- app/
|
69
|
-
- app/
|
70
|
-
- app/
|
71
|
-
- app/
|
72
|
-
- app/
|
73
|
-
- app/
|
74
|
-
- app/
|
78
|
+
- app/assets/images/go_gamification/hair.png
|
79
|
+
- app/assets/images/go_gamification/head.png
|
80
|
+
- app/assets/images/go_gamification/leftArm-jump.png
|
81
|
+
- app/assets/images/go_gamification/leftArm.png
|
82
|
+
- app/assets/images/go_gamification/legs-jump.png
|
83
|
+
- app/assets/images/go_gamification/legs.png
|
84
|
+
- app/assets/images/go_gamification/rightArm-jump.png
|
85
|
+
- app/assets/images/go_gamification/rightArm.png
|
86
|
+
- app/assets/images/go_gamification/torso.png
|
87
|
+
- app/assets/javascripts/go_gamification/character.js.erb
|
88
|
+
- app/assets/javascripts/go_gamification/excanvas.js
|
89
|
+
- app/controllers/gamification/levels_controller.rb
|
90
|
+
- app/controllers/gamification/rewards_controller.rb
|
91
|
+
- app/helpers/gamification/application_helper.rb
|
92
|
+
- app/helpers/gamification/rewards_helper.rb
|
93
|
+
- app/models/application_record.rb
|
94
|
+
- app/models/gamification.rb
|
95
|
+
- app/models/gamification/goal.rb
|
96
|
+
- app/models/gamification/level.rb
|
97
|
+
- app/models/gamification/medal.rb
|
98
|
+
- app/models/gamification/reward.rb
|
99
|
+
- app/uploaders/gamification/image_uploader.rb
|
100
|
+
- app/views/gamification/levels/_form.html.erb
|
101
|
+
- app/views/gamification/levels/edit.html.erb
|
102
|
+
- app/views/gamification/levels/index.html.erb
|
103
|
+
- app/views/gamification/levels/new.html.erb
|
104
|
+
- app/views/gamification/levels/show.html.erb
|
105
|
+
- app/views/gamification/rewards/_presentation.html.erb
|
106
|
+
- app/views/gamification/rewards/_reward.html.erb
|
107
|
+
- app/views/gamification/scorings/create.html.erb
|
108
|
+
- config/initializers/assets.rb
|
75
109
|
- config/routes.rb
|
76
110
|
- db/migrate/20171020181447_create_go_gamification_tasks.rb
|
77
111
|
- db/migrate/20171020181620_create_go_gamification_scorings.rb
|
@@ -80,18 +114,8 @@ files:
|
|
80
114
|
- db/migrate/20171020182210_add_description_to_go_gamification_medals.rb
|
81
115
|
- db/migrate/20171020182248_rename_go_gamification_tasks_to_goals.rb
|
82
116
|
- db/migrate/20171020182329_add_seen_at_to_go_gamification_rewards.rb
|
117
|
+
- db/migrate/20171023230506_create_go_gamification_levels.rb
|
83
118
|
- lib/go_gamification.rb
|
84
|
-
- lib/go_gamification/activerecord.rb
|
85
|
-
- lib/go_gamification/checksum.rb
|
86
|
-
- lib/go_gamification/concerns.rb
|
87
|
-
- lib/go_gamification/concerns/controllers.rb
|
88
|
-
- lib/go_gamification/concerns/controllers/rewards_controller.rb
|
89
|
-
- lib/go_gamification/concerns/models.rb
|
90
|
-
- lib/go_gamification/concerns/models/goal.rb
|
91
|
-
- lib/go_gamification/concerns/models/medal.rb
|
92
|
-
- lib/go_gamification/concerns/models/reward.rb
|
93
|
-
- lib/go_gamification/concerns/rewardable.rb
|
94
|
-
- lib/go_gamification/concerns/rewarding.rb
|
95
119
|
- lib/go_gamification/engine.rb
|
96
120
|
- lib/go_gamification/version.rb
|
97
121
|
- lib/tasks/go_gamification_tasks.rake
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module GoGamification
|
2
|
-
module RewardsHelper
|
3
|
-
|
4
|
-
# Present unseen rewards for the given user.
|
5
|
-
#
|
6
|
-
# options - A Hash of options:
|
7
|
-
# for: A rewardable model.
|
8
|
-
#
|
9
|
-
# Returns HTML.
|
10
|
-
def present_rewards options
|
11
|
-
rewardable = options[:for]
|
12
|
-
rewards = rewardable.rewards.unseen
|
13
|
-
presentation = render partial: 'go_gamification/rewards/presentation', locals: { rewards: rewards }
|
14
|
-
|
15
|
-
rewards.see
|
16
|
-
|
17
|
-
presentation
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module GoGamification::ActiveRecord
|
2
|
-
module Extensions
|
3
|
-
def rewarding
|
4
|
-
include GoGamification::Concerns::Rewarding
|
5
|
-
end
|
6
|
-
|
7
|
-
def rewardable
|
8
|
-
include GoGamification::Concerns::Rewardable
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
::ActiveRecord::Base.send :extend, GoGamification::ActiveRecord::Extensions if defined?(ActiveRecord)
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module GoGamification
|
2
|
-
module Checksum
|
3
|
-
# Generate a checksum from the given values.
|
4
|
-
#
|
5
|
-
# values - An Array of values.
|
6
|
-
#
|
7
|
-
# Returns a String.
|
8
|
-
def self.generate values
|
9
|
-
Digest::MD5.hexdigest "#{secret_key}#{values.join}"
|
10
|
-
end
|
11
|
-
|
12
|
-
# Verify a given checksum against the given values.
|
13
|
-
#
|
14
|
-
# checksum - A String describing a checksum.
|
15
|
-
# values - An Array of values.
|
16
|
-
#
|
17
|
-
# Returns a boolean.
|
18
|
-
def self.verify checksum, values
|
19
|
-
checksum == generate(values)
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def self.secret_key
|
25
|
-
Rails.application.secrets[:secret_key_base]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
module GoGamification
|
2
|
-
module Concerns::Controllers::RewardsController
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
before_action :verify_checksum
|
7
|
-
|
8
|
-
def create
|
9
|
-
if rewarding.is_a? ::GoGamification::Goal
|
10
|
-
rewarding.complete_for rewardable
|
11
|
-
else
|
12
|
-
rewarding.goals.each do |goal|
|
13
|
-
goal.complete_for rewardable
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
respond_to do |format|
|
18
|
-
format.json { render json: {}, status: :created }
|
19
|
-
format.html { redirect_to redirect_url }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def verify_checksum
|
26
|
-
render text: "Invalid checksum", status: :forbidden unless Checksum.verify(params[:checksum],
|
27
|
-
[rewarding.class.name, rewarding.id, rewardable.class.name, rewardable.id])
|
28
|
-
end
|
29
|
-
|
30
|
-
def redirect_url
|
31
|
-
params[:redirect_url] || request.env['HTTP_REFERER']
|
32
|
-
end
|
33
|
-
|
34
|
-
def rewarding
|
35
|
-
rewarding_model.find reward_params[:rewarding_id]
|
36
|
-
end
|
37
|
-
|
38
|
-
def rewardable
|
39
|
-
rewardable_model.find reward_params[:rewardable_id]
|
40
|
-
end
|
41
|
-
|
42
|
-
def rewarding_model
|
43
|
-
reward_params[:rewarding_type].constantize
|
44
|
-
end
|
45
|
-
|
46
|
-
def rewardable_model
|
47
|
-
reward_params[:rewardable_type].constantize
|
48
|
-
end
|
49
|
-
|
50
|
-
def reward_params
|
51
|
-
params.require(:reward).permit(:rewarding_type, :rewarding_id, :rewardable_type, :rewardable_id)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module GoGamification::Concerns::Rewardable
|
2
|
-
extend ActiveSupport::Concern
|
3
|
-
|
4
|
-
included do
|
5
|
-
has_many :rewards, class_name: '::GoGamification::Reward', as: :rewardable
|
6
|
-
has_many :goals, through: :rewards, class_name: '::GoGamification::Goal'
|
7
|
-
|
8
|
-
def medals
|
9
|
-
rewards.includes(goal: :medal).collect(&:medal).compact || []
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|