merit 2.3.3 → 2.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d79f50b24ec0f6cf605b5b77fbd9d2b96c41f16
4
- data.tar.gz: 862c1a7af32018b9344bdccb43d462b97d7339e0
3
+ metadata.gz: 73bf41bfadf2e0f5a4c6ee7e6577d506f60b3eaf
4
+ data.tar.gz: 767294bcaf7a2b004db246471df0294f5fa16105
5
5
  SHA512:
6
- metadata.gz: 783a96fce0128b18e34eba63999a84675011576d8ca0031251d5c4fe5d967007488616b0afe07258b0df2ac1b5c3e853e95b10e712b35a3b93f2e943b94e7c65
7
- data.tar.gz: 0453aa9d1395d6a6d1f86f11276d076ba1d07a2e13b4622b3e07e077cc445e5055c64e99103a5074af555ead4217d05c749f2fc2918d3c9f4e7b264ec1ff04dc
6
+ metadata.gz: 14f72b0cd12dca5f0f02cbb120d8088e2a30b9648de4763f32e891c8ec4f23cd06fe32a1008bd012a28ecab94551152d4be4bd812d08c7b1a83ffa3578c90d7a
7
+ data.tar.gz: 33d894f57a5e03b57abf0ce647c100ceaed2364e86ba6a95e8bf8f224c469faaa3a5b29269f647069288781cb1a5064737ac8e7f72251182c014f2f69c371412
data/NEWS.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  User-visible changes worth mentioning.
4
4
 
5
+ ## 2.3.4
6
+
7
+ - [#247] Fix Ruby warnings
8
+ - [#252] Bug fix: `uninitialized constant Merit::PointRules (NameError)` while
9
+ installing merit.
10
+
5
11
  ## 2.3.3
6
12
 
7
13
  - [#215] Bug fix in API where a `BadgeSash` would be created without failures
data/README.md CHANGED
@@ -89,8 +89,8 @@ Badge rules / conditions are defined in `app/models/merit/badge_rules.rb`
89
89
  * Can be `:itself`, in which case it badges the target object itself
90
90
  (`@model`).
91
91
  * Is `:action_user` by default, which means `current_user`.
92
- * `:model_name` define the controller's name if it's different from
93
- the model's (e.g. `RegistrationsController` for the `User` model).
92
+ * `:model_name` define the model's name if it's different from
93
+ the controller's (e.g. the `User` model for the `RegistrationsController`).
94
94
  * `:multiple` whether or not the badge may be granted multiple times. `false` by default.
95
95
  * `:temporary` whether or not the badge should be revoked if the condition no
96
96
  longer holds. `false` -badges are kept for ever- by default.
@@ -90,7 +90,8 @@ module Merit
90
90
  include Merit::ControllerExtensions
91
91
  rescue NameError => e
92
92
  # Trap NameError if installing/generating files
93
- raise e unless e.to_s =~ /uninitialized constant Merit::BadgeRules/
93
+ raise e unless
94
+ e.to_s =~ /uninitialized constant Merit::(BadgeRules|PointRules)/
94
95
  end
95
96
  end
96
97
  end
@@ -47,15 +47,23 @@ module Merit
47
47
  end
48
48
 
49
49
  def target_object
50
- target_obj = instance_variable_get(:"@#{controller_name.singularize}")
51
- if target_obj.nil?
52
- str = '[merit] No object found, you might need a ' \
53
- "'@#{controller_name.singularize}' variable in " \
54
- "'#{controller_path}_controller' if no reputation is applied. " \
55
- 'If you are using `model_name` option in the rule this is ok.'
56
- Rails.logger.warn str
50
+ variable_name = :"@#{controller_name.singularize}"
51
+ if instance_variable_defined?(variable_name)
52
+ if target_obj = instance_variable_get(variable_name)
53
+ target_obj
54
+ else
55
+ warn_no_object_found
56
+ end
57
57
  end
58
- target_obj
58
+ end
59
+
60
+ def warn_no_object_found
61
+ str = '[merit] No object found, you might need a ' \
62
+ "'@#{controller_name.singularize}' variable in " \
63
+ "'#{controller_path}_controller' if no reputation is applied. " \
64
+ 'If you are using `model_name` option in the rule this is ok.'
65
+ Rails.logger.warn str
66
+ nil
59
67
  end
60
68
 
61
69
  def target_id
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
  s.files = `git ls-files`.split("\n").reject{|f| f =~ /^\./ }
7
7
  s.test_files = `git ls-files -- test/*`.split("\n")
8
8
  s.license = 'MIT'
9
- s.version = '2.3.3'
9
+ s.version = '2.3.4'
10
10
  s.authors = ["Tute Costa"]
11
11
  s.email = 'tutecosta@gmail.com'
12
12
 
@@ -36,7 +36,7 @@ module Merit
36
36
  object.comment.to_i > 0
37
37
  end
38
38
 
39
- score -5, to: :user, on: 'comments#destroy' do |comment|
39
+ score (-5), to: :user, on: 'comments#destroy' do |comment|
40
40
  comment.present?
41
41
  end
42
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.3
4
+ version: 2.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tute Costa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-25 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ambry
@@ -281,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
281
  version: '0'
282
282
  requirements: []
283
283
  rubyforge_project:
284
- rubygems_version: 2.5.1
284
+ rubygems_version: 2.6.2
285
285
  signing_key:
286
286
  specification_version: 4
287
287
  summary: Reputation engine for Rails apps