go_gamification 0.0.7 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/go_gamification/hair.png +0 -0
  3. data/app/assets/images/go_gamification/head.png +0 -0
  4. data/app/assets/images/go_gamification/leftArm-jump.png +0 -0
  5. data/app/assets/images/go_gamification/leftArm.png +0 -0
  6. data/app/assets/images/go_gamification/legs-jump.png +0 -0
  7. data/app/assets/images/go_gamification/legs.png +0 -0
  8. data/app/assets/images/go_gamification/rightArm-jump.png +0 -0
  9. data/app/assets/images/go_gamification/rightArm.png +0 -0
  10. data/app/assets/images/go_gamification/torso.png +0 -0
  11. data/app/assets/javascripts/go_gamification/character.js.erb +193 -0
  12. data/app/assets/javascripts/go_gamification/excanvas.js +924 -0
  13. data/app/controllers/gamification/levels_controller.rb +63 -0
  14. data/app/controllers/gamification/rewards_controller.rb +51 -0
  15. data/app/helpers/{go_gamification → gamification}/application_helper.rb +1 -1
  16. data/app/helpers/gamification/rewards_helper.rb +6 -0
  17. data/app/models/application_record.rb +3 -0
  18. data/app/models/gamification.rb +6 -0
  19. data/{lib/go_gamification/concerns/models → app/models/gamification}/goal.rb +3 -7
  20. data/app/models/gamification/level.rb +6 -0
  21. data/app/models/gamification/medal.rb +7 -0
  22. data/{lib/go_gamification/concerns/models → app/models/gamification}/reward.rb +3 -5
  23. data/app/uploaders/{go_gamification → gamification}/image_uploader.rb +1 -1
  24. data/app/views/gamification/levels/_form.html.erb +17 -0
  25. data/app/views/gamification/levels/edit.html.erb +6 -0
  26. data/app/views/gamification/levels/index.html.erb +24 -0
  27. data/app/views/gamification/levels/new.html.erb +5 -0
  28. data/app/views/gamification/levels/show.html.erb +4 -0
  29. data/app/views/{go_gamification → gamification}/rewards/_presentation.html.erb +2 -0
  30. data/app/views/{go_gamification → gamification}/rewards/_reward.html.erb +1 -1
  31. data/app/views/{go_gamification → gamification}/scorings/create.html.erb +0 -0
  32. data/config/initializers/assets.rb +2 -0
  33. data/config/routes.rb +5 -1
  34. data/db/migrate/20171020181447_create_go_gamification_tasks.rb +1 -1
  35. data/db/migrate/20171020181620_create_go_gamification_scorings.rb +2 -2
  36. data/db/migrate/20171020182027_rename_everything.rb +5 -5
  37. data/db/migrate/20171020182119_create_go_gamification_medals.rb +1 -1
  38. data/db/migrate/20171020182210_add_description_to_go_gamification_medals.rb +1 -1
  39. data/db/migrate/20171020182248_rename_go_gamification_tasks_to_goals.rb +3 -3
  40. data/db/migrate/20171020182329_add_seen_at_to_go_gamification_rewards.rb +2 -2
  41. data/db/migrate/20171023230506_create_go_gamification_levels.rb +9 -0
  42. data/lib/go_gamification.rb +1 -3
  43. data/lib/go_gamification/engine.rb +2 -19
  44. data/lib/go_gamification/version.rb +1 -1
  45. metadata +49 -25
  46. data/app/controllers/go_gamification/application_controller.rb +0 -4
  47. data/app/controllers/go_gamification/rewards_controller.rb +0 -7
  48. data/app/helpers/go_gamification/rewards_helper.rb +0 -20
  49. data/app/models/go_gamification/goal.rb +0 -5
  50. data/app/models/go_gamification/medal.rb +0 -5
  51. data/app/models/go_gamification/reward.rb +0 -5
  52. data/lib/go_gamification/activerecord.rb +0 -13
  53. data/lib/go_gamification/checksum.rb +0 -28
  54. data/lib/go_gamification/concerns.rb +0 -6
  55. data/lib/go_gamification/concerns/controllers.rb +0 -3
  56. data/lib/go_gamification/concerns/controllers/rewards_controller.rb +0 -55
  57. data/lib/go_gamification/concerns/models.rb +0 -5
  58. data/lib/go_gamification/concerns/models/medal.rb +0 -13
  59. data/lib/go_gamification/concerns/rewardable.rb +0 -12
  60. data/lib/go_gamification/concerns/rewarding.rb +0 -7
@@ -1,3 +1,3 @@
1
1
  module GoGamification
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.13"
3
3
  end
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.7
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-21 00:00:00.000000000 Z
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: pg
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/controllers/go_gamification/application_controller.rb
65
- - app/controllers/go_gamification/rewards_controller.rb
66
- - app/helpers/go_gamification/application_helper.rb
67
- - app/helpers/go_gamification/rewards_helper.rb
68
- - app/models/go_gamification/goal.rb
69
- - app/models/go_gamification/medal.rb
70
- - app/models/go_gamification/reward.rb
71
- - app/uploaders/go_gamification/image_uploader.rb
72
- - app/views/go_gamification/rewards/_presentation.html.erb
73
- - app/views/go_gamification/rewards/_reward.html.erb
74
- - app/views/go_gamification/scorings/create.html.erb
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,4 +0,0 @@
1
- module GoGamification
2
- class ApplicationController < ::ApplicationController
3
- end
4
- end
@@ -1,7 +0,0 @@
1
- require_dependency "go_gamification/application_controller"
2
-
3
- module GoGamification
4
- class RewardsController < ApplicationController
5
- include GoGamification::Concerns::Controllers::RewardsController
6
- end
7
- end
@@ -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,5 +0,0 @@
1
- module GoGamification
2
- class Goal < ::ActiveRecord::Base
3
- include Concerns::Models::Goal
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- module GoGamification
2
- class Medal < ::ActiveRecord::Base
3
- include Concerns::Models::Medal
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- module GoGamification
2
- class Reward < ::ActiveRecord::Base
3
- include Concerns::Models::Reward
4
- end
5
- 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,6 +0,0 @@
1
- module GoGamification::Concerns
2
- require "go_gamification/concerns/models"
3
- require "go_gamification/concerns/controllers"
4
- require "go_gamification/concerns/rewarding"
5
- require "go_gamification/concerns/rewardable"
6
- end
@@ -1,3 +0,0 @@
1
- module GoGamification::Concerns::Controllers
2
- require "go_gamification/concerns/controllers/rewards_controller"
3
- 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,5 +0,0 @@
1
- module GoGamification::Concerns::Models
2
- require "go_gamification/concerns/models/goal"
3
- require "go_gamification/concerns/models/reward"
4
- require "go_gamification/concerns/models/medal"
5
- end
@@ -1,13 +0,0 @@
1
- require 'carrierwave'
2
-
3
- module GoGamification
4
- module Concerns::Models::Medal
5
- extend ActiveSupport::Concern
6
-
7
- included do
8
- belongs_to :goal
9
-
10
- mount_uploader :image, ::GoGamification::ImageUploader
11
- end
12
- end
13
- 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
@@ -1,7 +0,0 @@
1
- module GoGamification::Concerns::Rewarding
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- has_many :goals, class_name: '::GoGamification::Goal', as: :rewarding
6
- end
7
- end