strong_arms 0.1.1 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0141fa031130367f64912bf360d670154e5e430105f516571b407353df1e32c3
4
- data.tar.gz: 6fe45f23829d4faba9ab85ef8440e48baad05718fec7f817306d80d00afd2b1e
3
+ metadata.gz: 23685eb2142510bfc4548b6487562729bb6d53aca759df88a9da0ba1bb037ee8
4
+ data.tar.gz: 6086b2ad57b9c22cefcdc9fd4fbdc9c8354dd876e56c5a2c84ce04344618990c
5
5
  SHA512:
6
- metadata.gz: bc34e47b39dc89a4d763293c1a9ea929103d08003718ebe735e5c6ea379de83b6b53a2b93175c1ebf79506923f51999ee92da4fe7dfdb90a0bbd2b39e620e335
7
- data.tar.gz: 463c3d93e8bdc7c398bece9bb7eefe70ef696058f5ff0e5ff6457ea41b2ebfaaf00508405cba2902a21c9c70d73d229b61bc2fd8f9018c4489ddc6f52752db17
6
+ metadata.gz: b08e387370c2e9df00a9045b90ed076c2373c1d8f019e762546e50a6eb51b46c8281ec774bea0bcc13f180aa94d7752dfa977eff85833eed5e2f0be6083f4fc2
7
+ data.tar.gz: 609813edde773416b08425e3a0b9da593027d923fb41c1858ea2f92704b74cb9c3ed32d8d424551146780f5efec25b4324ea915cc063a485edaac6d412f37f3c
data/.travis.yml CHANGED
@@ -4,4 +4,4 @@ language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
6
  - 2.5.3
7
- before_install: gem install bundler -v 1.17.1
7
+ before_install: gem install bundler -v 1.17.3
data/Gemfile.lock CHANGED
@@ -1,22 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strong_arms (0.1.0)
4
+ strong_arms (0.2.0)
5
5
  activesupport (>= 5.1.6)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (5.2.1)
10
+ activesupport (5.2.3)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 0.7, < 2)
13
13
  minitest (~> 5.1)
14
14
  tzinfo (~> 1.1)
15
- concurrent-ruby (1.1.3)
15
+ coderay (1.1.2)
16
+ concurrent-ruby (1.1.5)
16
17
  diff-lcs (1.3)
17
- i18n (1.1.1)
18
+ i18n (1.6.0)
18
19
  concurrent-ruby (~> 1.0)
20
+ method_source (0.9.2)
19
21
  minitest (5.11.3)
22
+ pry (0.12.2)
23
+ coderay (~> 1.1.0)
24
+ method_source (~> 0.9.0)
20
25
  rake (10.5.0)
21
26
  rspec (3.8.0)
22
27
  rspec-core (~> 3.8.0)
@@ -40,9 +45,10 @@ PLATFORMS
40
45
 
41
46
  DEPENDENCIES
42
47
  bundler (~> 1.17)
48
+ pry
43
49
  rake (~> 10.0)
44
50
  rspec (~> 3.0)
45
51
  strong_arms!
46
52
 
47
53
  BUNDLED WITH
48
- 1.17.1
54
+ 1.17.3
data/README.md CHANGED
@@ -58,6 +58,8 @@ end
58
58
  # app/strong_arms
59
59
 
60
60
  class PostStrongArm
61
+ extend StrongArms
62
+
61
63
  ignore :created_at, :updated_at
62
64
 
63
65
  permit :id
@@ -69,6 +71,8 @@ class PostStrongArm
69
71
  end
70
72
 
71
73
  class CommentStrongArm
74
+ extend StrongArms
75
+
72
76
  ignore :created_at, :updated_at
73
77
 
74
78
  permit :id
@@ -85,6 +89,8 @@ If parameters are passed to Strong Arms without being permitted, Strong Arms wil
85
89
 
86
90
  ```ruby
87
91
  class UserStrongArm
92
+ extend StrongArms
93
+
88
94
  permit :id
89
95
  end
90
96
  ```
@@ -99,6 +105,8 @@ If it is absent, Strong Arms will raise an exception.
99
105
 
100
106
  ```ruby
101
107
  class UserStrongArm
108
+ extend StrongArms
109
+
102
110
  permit :id
103
111
  permit :email, required: true
104
112
  end
@@ -112,6 +120,8 @@ Commonly ignored parameters include auto incremented or optional (nillable) valu
112
120
 
113
121
  ```ruby
114
122
  class UserStrongArm
123
+ extend StrongArms
124
+
115
125
  ignore :created_at, :updated_at
116
126
 
117
127
  permit :id
@@ -127,6 +137,8 @@ This is similar to how Rails handles association declarations with `has_many` an
127
137
 
128
138
  ```ruby
129
139
  class UserStrongArm
140
+ extend StrongArms
141
+
130
142
  ignore :created_at, :updated_at
131
143
 
132
144
  permit :id
@@ -137,6 +149,8 @@ class UserStrongArm
137
149
  end
138
150
 
139
151
  class PostStrongArm
152
+ extend StrongArms
153
+
140
154
  ignore :created_at, :updated_at
141
155
 
142
156
  permit :id
@@ -145,6 +159,8 @@ class PostStrongArm
145
159
  end
146
160
 
147
161
  class ProfileStrongArm
162
+ extend StrongArms
163
+
148
164
  ignore :created_at, :updated_at
149
165
 
150
166
  permit :id
@@ -170,7 +186,18 @@ If you do not wish to use `accepts_nested_attributes_for`, provide the `:format`
170
186
 
171
187
  If Strong Arms cannot find the relevant Strong Arms class for the nested resource, it will raise an exception.
172
188
 
189
+ ## Model Option
190
+
191
+ Sometimes failure to find the relevant Strong Arm occurs due to irregular plural conjugations.
192
+
193
+ You can pass the appropriate model name via the `:model` option:
194
+
195
+ ```ruby
196
+ many_nested :loaves, model: :loaf
197
+ one_nested :address, model: :address
198
+ ```
173
199
 
200
+ This also comes in handy for plural words ending in `es`, or if you'd like to match the key to an alias Strong Arm.
174
201
 
175
202
  ## Development
176
203
 
@@ -6,7 +6,7 @@ module ExceptionMethods
6
6
 
7
7
  def unhandled_keys_exception(args)
8
8
  keys = unhandled_keys(args)
9
- Errors::UnhandledKeys.
9
+ StrongArms::UnhandledKeys.
10
10
  new("#{name} received unhandled keys: #{keys.join(', ')}.")
11
11
  end
12
12
 
@@ -26,14 +26,26 @@ module Utilities
26
26
  end
27
27
  end
28
28
 
29
- def model_name_from_attributes_key(name)
30
- name.to_s.gsub('s_attributes', '').camelize
29
+ def find_strong_arm(attributes_key, options)
30
+ model_alias = options[:model]
31
+ model_name =
32
+ model_name_from_attributes_key(attributes_key, model_alias: model_alias)
33
+ strong_arm = "#{model_name}StrongArm"
34
+ strong_arm.constantize
31
35
  end
32
36
 
33
- def find_strong_arm(nested_attributes_key)
34
- model_name = model_name_from_attributes_key(nested_attributes_key)
35
- strong_arm = model_name + "StrongArm"
36
- strong_arm.constantize
37
+ def handlers_values
38
+ handlers.values
39
+ end
40
+
41
+ private
42
+
43
+ def model_name_from_attributes_key(name, model_alias: nil)
44
+ if model_alias
45
+ model_alias.to_s.camelize
46
+ else
47
+ name.to_s.gsub('s_attributes', '').camelize
48
+ end
37
49
  end
38
50
 
39
51
  def unhandled_keys(args)
@@ -45,9 +57,6 @@ module Utilities
45
57
  handlers.keys.flatten.uniq
46
58
  end
47
59
 
48
- def handlers_values
49
- handlers.values
50
- end
51
60
 
52
61
  def symbolized_keys_array(args)
53
62
  args.keys.map(&:to_sym)
@@ -1,3 +1,3 @@
1
1
  module StrongArms
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/strong_arms.rb CHANGED
@@ -1,29 +1,25 @@
1
1
  require "strong_arms/version"
2
2
  require "strong_arms/utilities"
3
- require "strong_arms/errors"
4
3
  require "strong_arms/exception_methods"
5
4
  require "strong_arms/assertions"
6
5
  require "active_support/all"
7
6
 
8
7
  module StrongArms
9
8
  include Utilities
10
- include Errors
11
9
  include ExceptionMethods
12
10
  include Assertions
13
11
  include ActiveSupport
14
12
 
15
- def handlers
16
- @handlers ||= {}
13
+ class UnhandledKeys < StandardError
14
+ def initialize(msg)
15
+ super
16
+ end
17
17
  end
18
18
 
19
19
  def ignore(*args)
20
20
  @keys_to_ignore = args
21
21
  end
22
22
 
23
- def keys_to_ignore
24
- @keys_to_ignore ||= []
25
- end
26
-
27
23
  def permit(attribute, **options)
28
24
  attributes = [attribute].flatten
29
25
 
@@ -34,19 +30,29 @@ module StrongArms
34
30
  set_handler(attribute, options, type: :input)
35
31
  end
36
32
 
37
- def one_nested(association, format: true)
33
+ def one_nested(association, options = {})
34
+ format = options.fetch(:format, true)
35
+ model = options[:model]
36
+ merged_handler_options = { has_many: false }.merge(model: model)
37
+ handler_options = model ? merged_handler_options : { has_many: false }
38
38
  modified_key = format ? nested_attributes_key(association) : association
39
- set_handler(modified_key, { has_many: false }, type: :association)
39
+
40
+ set_handler(modified_key, handler_options, type: :association)
40
41
  end
41
42
 
42
- def many_nested(association, format: true)
43
+ def many_nested(association, options = {})
44
+ format = options.fetch(:format, true)
45
+ model = options[:model]
46
+ merged_handler_options = { has_many: true }.merge(model: model)
47
+ handler_options = model ? merged_handler_options : { has_many: true }
43
48
  modified_key = format ? nested_attributes_key(association) : association
44
- set_handler(modified_key, { has_many: true }, type: :association)
49
+
50
+ set_handler(modified_key, handler_options, type: :association)
45
51
  end
46
52
 
47
53
  def flex(args)
48
- _args = action_controller_args?(args) ? accessible_hash(args) : args
49
- exposed_args = expose_data_key_if_present(_args)
54
+ useful_args = action_controller_args?(args) ? accessible_hash(args) : args
55
+ exposed_args = expose_data_key_if_present(useful_args)
50
56
 
51
57
  raise empty_arguments_exception if exposed_args.blank?
52
58
  if unhandled_keys_present?(exposed_args)
@@ -56,6 +62,14 @@ module StrongArms
56
62
  reduce_handlers(handlers_values, exposed_args)
57
63
  end
58
64
 
65
+ def handlers
66
+ @handlers ||= {}
67
+ end
68
+
69
+ def keys_to_ignore
70
+ @keys_to_ignore ||= []
71
+ end
72
+
59
73
  def nested_attributes_key(association)
60
74
  "#{association}_attributes".to_sym
61
75
  end
@@ -90,12 +104,12 @@ module StrongArms
90
104
  send("parse_#{type}", name: name, value: value_at_name, options: options)
91
105
  end
92
106
 
93
- def parse_input(name:, value:, options:) # options goes unused
107
+ def parse_input(name:, value:, options:)
94
108
  { name => value }
95
109
  end
96
110
 
97
111
  def parse_association(name:, value:, options:)
98
- strong_arm = find_strong_arm(name)
112
+ strong_arm = find_strong_arm(name, options)
99
113
  wrapped_values = [value].flatten
100
114
  has_many = options[:has_many]
101
115
 
data/rubocop.yml ADDED
@@ -0,0 +1,655 @@
1
+ AllCops:
2
+ Exclude:
3
+ - db/schema.rb
4
+ - db/migrate/*
5
+ - Gemfile*
6
+ - config/*
7
+ - node_modules/**/*
8
+ - vendor/**/*
9
+
10
+ Naming/AccessorMethodName:
11
+ Description: Check the naming of accessor methods for get_/set_.
12
+ Enabled: false
13
+
14
+ Style/Alias:
15
+ Description: 'Use alias_method instead of alias.'
16
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method'
17
+ Enabled: false
18
+
19
+ Style/ArrayJoin:
20
+ Description: 'Use Array#join instead of Array#*.'
21
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#array-join'
22
+ Enabled: false
23
+
24
+ Style/AsciiComments:
25
+ Description: 'Use only ascii symbols in comments.'
26
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments'
27
+ Enabled: false
28
+
29
+ Naming/AsciiIdentifiers:
30
+ Description: 'Use only ascii symbols in identifiers.'
31
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-identifiers'
32
+ Enabled: false
33
+
34
+ Style/Attr:
35
+ Description: 'Checks for uses of Module#attr.'
36
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr'
37
+ Enabled: false
38
+
39
+ Metrics/BlockNesting:
40
+ Description: 'Avoid excessive block nesting'
41
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count'
42
+ Enabled: false
43
+
44
+ Style/CaseEquality:
45
+ Description: 'Avoid explicit use of the case equality operator(===).'
46
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-case-equality'
47
+ Enabled: false
48
+
49
+ Style/CharacterLiteral:
50
+ Description: 'Checks for uses of character literals.'
51
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-character-literals'
52
+ Enabled: false
53
+
54
+ Style/ClassAndModuleChildren:
55
+ Description: 'Checks style of children classes and modules.'
56
+ Enabled: true
57
+ EnforcedStyle: nested
58
+
59
+ Metrics/ClassLength:
60
+ Description: 'Avoid classes longer than 100 lines of code.'
61
+ Enabled: false
62
+
63
+ Metrics/ModuleLength:
64
+ Description: 'Avoid modules longer than 100 lines of code.'
65
+ Enabled: false
66
+
67
+ Style/ClassVars:
68
+ Description: 'Avoid the use of class variables.'
69
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars'
70
+ Enabled: false
71
+
72
+ Style/CollectionMethods:
73
+ Enabled: true
74
+ PreferredMethods:
75
+ find: detect
76
+ inject: reduce
77
+ collect: map
78
+ find_all: select
79
+
80
+ Style/ColonMethodCall:
81
+ Description: 'Do not use :: for method call.'
82
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#double-colons'
83
+ Enabled: false
84
+
85
+ Style/CommentAnnotation:
86
+ Description: >-
87
+ Checks formatting of special comments
88
+ (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
89
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#annotate-keywords'
90
+ Enabled: false
91
+
92
+ Metrics/AbcSize:
93
+ Description: >-
94
+ A calculated magnitude based on number of assignments,
95
+ branches, and conditions.
96
+ Enabled: false
97
+
98
+ Metrics/BlockLength:
99
+ CountComments: true # count full line comments?
100
+ Max: 25
101
+ ExcludedMethods: []
102
+ Exclude:
103
+ - "spec/**/*"
104
+
105
+ Metrics/CyclomaticComplexity:
106
+ Description: >-
107
+ A complexity metric that is strongly correlated to the number
108
+ of test cases needed to validate a method.
109
+ Enabled: false
110
+
111
+ Rails/Delegate:
112
+ Description: 'Prefer delegate method for delegations.'
113
+ Enabled: false
114
+
115
+ Style/PreferredHashMethods:
116
+ Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
117
+ StyleGuide: '#hash-key'
118
+ Enabled: false
119
+
120
+ Style/Documentation:
121
+ Description: 'Document classes and non-namespace modules.'
122
+ Enabled: false
123
+
124
+ Style/DoubleNegation:
125
+ Description: 'Checks for uses of double negation (!!).'
126
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-bang-bang'
127
+ Enabled: false
128
+
129
+ Style/EachWithObject:
130
+ Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
131
+ Enabled: false
132
+
133
+ Style/EmptyLiteral:
134
+ Description: 'Prefer literals to Array.new/Hash.new/String.new.'
135
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#literal-array-hash'
136
+ Enabled: false
137
+
138
+ # Checks whether the source file has a utf-8 encoding comment or not
139
+ # AutoCorrectEncodingComment must match the regex
140
+ # /#.*coding\s?[:=]\s?(?:UTF|utf)-8/
141
+ Style/Encoding:
142
+ Enabled: false
143
+
144
+ Style/EvenOdd:
145
+ Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
146
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
147
+ Enabled: false
148
+
149
+ Naming/FileName:
150
+ Description: 'Use snake_case for source file names.'
151
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
152
+ Enabled: false
153
+
154
+ Style/FrozenStringLiteralComment:
155
+ Description: >-
156
+ Add the frozen_string_literal comment to the top of files
157
+ to help transition from Ruby 2.3.0 to Ruby 3.0.
158
+ Enabled: false
159
+
160
+ Style/FlipFlop:
161
+ Description: 'Checks for flip flops'
162
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops'
163
+ Enabled: false
164
+
165
+ Style/FormatString:
166
+ Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
167
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf'
168
+ Enabled: false
169
+
170
+ Style/GlobalVars:
171
+ Description: 'Do not introduce global variables.'
172
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars'
173
+ Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html'
174
+ Enabled: false
175
+
176
+ Style/GuardClause:
177
+ Description: 'Check for conditionals that can be replaced with guard clauses'
178
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
179
+ Enabled: false
180
+
181
+ Style/IfUnlessModifier:
182
+ Description: >-
183
+ Favor modifier if/unless usage when you have a
184
+ single-line body.
185
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
186
+ Enabled: false
187
+
188
+ Style/IfWithSemicolon:
189
+ Description: 'Do not use if x; .... Use the ternary operator instead.'
190
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs'
191
+ Enabled: false
192
+
193
+ Style/InlineComment:
194
+ Description: 'Avoid inline comments.'
195
+ Enabled: false
196
+
197
+ Style/Lambda:
198
+ Description: 'Use the new lambda literal syntax for single-line blocks.'
199
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#lambda-multi-line'
200
+ Enabled: false
201
+
202
+ Style/LambdaCall:
203
+ Description: 'Use lambda.call(...) instead of lambda.(...).'
204
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc-call'
205
+ Enabled: false
206
+
207
+ Style/LineEndConcatenation:
208
+ Description: >-
209
+ Use \ instead of + or << to concatenate two string literals at
210
+ line end.
211
+ Enabled: false
212
+
213
+ Metrics/LineLength:
214
+ Description: 'Limit lines to 80 characters.'
215
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
216
+ Max: 80
217
+
218
+ Metrics/MethodLength:
219
+ Description: 'Avoid methods longer than 10 lines of code.'
220
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
221
+ Enabled: false
222
+
223
+ Style/ModuleFunction:
224
+ Description: 'Checks for usage of `extend self` in modules.'
225
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#module-function'
226
+ Enabled: false
227
+
228
+ Style/MultilineBlockChain:
229
+ Description: 'Avoid multi-line chains of blocks.'
230
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
231
+ Enabled: false
232
+
233
+ Style/NegatedIf:
234
+ Description: >-
235
+ Favor unless over if for negative conditions
236
+ (or control flow or).
237
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives'
238
+ Enabled: false
239
+
240
+ Style/NegatedWhile:
241
+ Description: 'Favor until over while for negative conditions.'
242
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#until-for-negatives'
243
+ Enabled: false
244
+
245
+ Style/Next:
246
+ Description: 'Use `next` to skip iteration instead of a condition at the end.'
247
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
248
+ Enabled: false
249
+
250
+ Style/NilComparison:
251
+ Description: 'Prefer x.nil? to x == nil.'
252
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
253
+ Enabled: false
254
+
255
+ Style/Not:
256
+ Description: 'Use ! instead of not.'
257
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bang-not-not'
258
+ Enabled: false
259
+
260
+ Style/NumericLiterals:
261
+ Description: >-
262
+ Add underscores to large numeric literals to improve their
263
+ readability.
264
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics'
265
+ Enabled: false
266
+
267
+ Style/OneLineConditional:
268
+ Description: >-
269
+ Favor the ternary operator(?:) over
270
+ if/then/else/end constructs.
271
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator'
272
+ Enabled: false
273
+
274
+ Naming/BinaryOperatorParameterName:
275
+ Description: 'When defining binary operators, name the argument other.'
276
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#other-arg'
277
+ Enabled: false
278
+
279
+ Metrics/ParameterLists:
280
+ Description: 'Avoid parameter lists longer than three or four parameters.'
281
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params'
282
+ Enabled: false
283
+
284
+ Style/PercentLiteralDelimiters:
285
+ Description: 'Use `%`-literal delimiters consistently'
286
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-literal-braces'
287
+ Enabled: false
288
+
289
+ Style/PerlBackrefs:
290
+ Description: 'Avoid Perl-style regex back references.'
291
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
292
+ Enabled: false
293
+
294
+ Naming/PredicateName:
295
+ Description: 'Check the names of predicate methods.'
296
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark'
297
+ NamePrefixBlacklist:
298
+ - is_
299
+ Exclude:
300
+ - spec/**/*
301
+
302
+ Style/Proc:
303
+ Description: 'Use proc instead of Proc.new.'
304
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc'
305
+ Enabled: false
306
+
307
+ Style/RaiseArgs:
308
+ Description: 'Checks the arguments passed to raise/fail.'
309
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#exception-class-messages'
310
+ Enabled: false
311
+
312
+ Style/RegexpLiteral:
313
+ Description: 'Use / or %r around regular expressions.'
314
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r'
315
+ Enabled: false
316
+
317
+ Style/SelfAssignment:
318
+ Description: >-
319
+ Checks for places where self-assignment shorthand should have
320
+ been used.
321
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment'
322
+ Enabled: false
323
+
324
+ Style/SingleLineBlockParams:
325
+ Description: 'Enforces the names of some block params.'
326
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks'
327
+ Enabled: false
328
+
329
+ Style/SingleLineMethods:
330
+ Description: 'Avoid single-line methods.'
331
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods'
332
+ Enabled: false
333
+
334
+ Style/SignalException:
335
+ Description: 'Checks for proper usage of fail and raise.'
336
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
337
+ Enabled: false
338
+
339
+ Style/SpecialGlobalVars:
340
+ Description: 'Avoid Perl-style global variables.'
341
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms'
342
+ Enabled: false
343
+
344
+ Style/StringLiterals:
345
+ Description: 'Checks if uses of quotes match the configured preference.'
346
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals'
347
+ EnforcedStyle: double_quotes
348
+ Enabled: false
349
+
350
+ Style/TrailingCommaInArguments:
351
+ Description: 'Checks for trailing comma in argument lists.'
352
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
353
+ EnforcedStyleForMultiline: comma
354
+ SupportedStylesForMultiline:
355
+ - comma
356
+ - consistent_comma
357
+ - no_comma
358
+ Enabled: true
359
+
360
+ Style/TrailingCommaInArrayLiteral:
361
+ Description: 'Checks for trailing comma in array literals.'
362
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
363
+ EnforcedStyleForMultiline: comma
364
+ SupportedStylesForMultiline:
365
+ - comma
366
+ - consistent_comma
367
+ - no_comma
368
+ Enabled: true
369
+
370
+ Style/TrailingCommaInHashLiteral:
371
+ Description: 'Checks for trailing comma in hash literals.'
372
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
373
+ EnforcedStyleForMultiline: comma
374
+ SupportedStylesForMultiline:
375
+ - comma
376
+ - consistent_comma
377
+ - no_comma
378
+ Enabled: true
379
+
380
+ Style/TrivialAccessors:
381
+ Description: 'Prefer attr_* methods to trivial readers/writers.'
382
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr_family'
383
+ Enabled: false
384
+
385
+ Style/VariableInterpolation:
386
+ Description: >-
387
+ Don't interpolate global, instance and class variables
388
+ directly in strings.
389
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#curlies-interpolate'
390
+ Enabled: false
391
+
392
+ Style/WhenThen:
393
+ Description: 'Use when x then ... for one-line cases.'
394
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#one-line-cases'
395
+ Enabled: false
396
+
397
+ Style/WhileUntilModifier:
398
+ Description: >-
399
+ Favor modifier while/until usage when you have a
400
+ single-line body.
401
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier'
402
+ Enabled: false
403
+
404
+ Style/WordArray:
405
+ Description: 'Use %w or %W for arrays of words.'
406
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w'
407
+ Enabled: false
408
+
409
+ # Layout
410
+
411
+ Layout/AlignParameters:
412
+ Description: 'Here we check if the parameters on a multi-line method call or definition are aligned.'
413
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent'
414
+ Enabled: false
415
+
416
+ Layout/ConditionPosition:
417
+ Description: >-
418
+ Checks for condition placed in a confusing position relative to
419
+ the keyword.
420
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
421
+ Enabled: false
422
+
423
+ Layout/DotPosition:
424
+ Description: 'Checks the position of the dot in multi-line method calls.'
425
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
426
+ EnforcedStyle: trailing
427
+
428
+ Layout/ExtraSpacing:
429
+ Description: 'Do not use unnecessary spacing.'
430
+ Enabled: true
431
+
432
+ Layout/MultilineOperationIndentation:
433
+ Description: >-
434
+ Checks indentation of binary operations that span more than
435
+ one line.
436
+ Enabled: true
437
+ EnforcedStyle: indented
438
+
439
+ Layout/MultilineMethodCallIndentation:
440
+ Description: >-
441
+ Checks indentation of method calls with the dot operator
442
+ that span more than one line.
443
+ Enabled: true
444
+ EnforcedStyle: indented
445
+
446
+ Layout/InitialIndentation:
447
+ Description: >-
448
+ Checks the indentation of the first non-blank non-comment line in a file.
449
+ Enabled: false
450
+
451
+ # Lint
452
+
453
+ Lint/AmbiguousOperator:
454
+ Description: >-
455
+ Checks for ambiguous operators in the first argument of a
456
+ method invocation without parentheses.
457
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args'
458
+ Enabled: false
459
+
460
+ Lint/AmbiguousRegexpLiteral:
461
+ Description: >-
462
+ Checks for ambiguous regexp literals in the first argument of
463
+ a method invocation without parenthesis.
464
+ Enabled: false
465
+
466
+ Lint/AssignmentInCondition:
467
+ Description: "Don't use assignment in conditions."
468
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition'
469
+ Enabled: false
470
+
471
+ Lint/CircularArgumentReference:
472
+ Description: "Don't refer to the keyword argument in the default value."
473
+ Enabled: false
474
+
475
+ Lint/DeprecatedClassMethods:
476
+ Description: 'Check for deprecated class method calls.'
477
+ Enabled: false
478
+
479
+ Lint/DuplicatedKey:
480
+ Description: 'Check for duplicate keys in hash literals.'
481
+ Enabled: false
482
+
483
+ Lint/EachWithObjectArgument:
484
+ Description: 'Check for immutable argument given to each_with_object.'
485
+ Enabled: false
486
+
487
+ Lint/ElseLayout:
488
+ Description: 'Check for odd code arrangement in an else block.'
489
+ Enabled: false
490
+
491
+ Lint/FormatParameterMismatch:
492
+ Description: 'The number of parameters to format/sprint must match the fields.'
493
+ Enabled: false
494
+
495
+ Lint/HandleExceptions:
496
+ Description: "Don't suppress exception."
497
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
498
+ Enabled: false
499
+
500
+ Lint/LiteralAsCondition:
501
+ Description: 'Checks of literals used in conditions.'
502
+ Enabled: false
503
+
504
+ Lint/LiteralInInterpolation:
505
+ Description: 'Checks for literals used in interpolation.'
506
+ Enabled: false
507
+
508
+ Lint/Loop:
509
+ Description: >-
510
+ Use Kernel#loop with break rather than begin/end/until or
511
+ begin/end/while for post-loop tests.
512
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#loop-with-break'
513
+ Enabled: false
514
+
515
+ Lint/NestedMethodDefinition:
516
+ Description: 'Do not use nested method definitions.'
517
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-methods'
518
+ Enabled: false
519
+
520
+ Lint/NonLocalExitFromIterator:
521
+ Description: 'Do not use return in iterator to cause non-local exit.'
522
+ Enabled: false
523
+
524
+ Lint/ParenthesesAsGroupedExpression:
525
+ Description: >-
526
+ Checks for method calls with a space before the opening
527
+ parenthesis.
528
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
529
+ Enabled: false
530
+
531
+ Lint/RequireParentheses:
532
+ Description: >-
533
+ Use parentheses in the method call to avoid confusion
534
+ about precedence.
535
+ Enabled: false
536
+
537
+ Lint/UnderscorePrefixedVariableName:
538
+ Description: 'Do not use prefix `_` for a variable that is used.'
539
+ Enabled: false
540
+
541
+ Lint/UnneededCopDisableDirective:
542
+ Description: >-
543
+ Checks for rubocop:disable comments that can be removed.
544
+ Note: this cop is not disabled when disabling all cops.
545
+ It must be explicitly disabled.
546
+ Enabled: false
547
+
548
+ Lint/Void:
549
+ Description: 'Possible use of operator/literal/variable in void context.'
550
+ Enabled: false
551
+
552
+ # Performance
553
+
554
+ Performance/CaseWhenSplat:
555
+ Description: >-
556
+ Place `when` conditions that use splat at the end
557
+ of the list of `when` branches.
558
+ Enabled: false
559
+
560
+ Performance/Count:
561
+ Description: >-
562
+ Use `count` instead of `select...size`, `reject...size`,
563
+ `select...count`, `reject...count`, `select...length`,
564
+ and `reject...length`.
565
+ Enabled: false
566
+
567
+ Performance/Detect:
568
+ Description: >-
569
+ Use `detect` instead of `select.first`, `find_all.first`,
570
+ `select.last`, and `find_all.last`.
571
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
572
+ Enabled: false
573
+
574
+ Performance/FlatMap:
575
+ Description: >-
576
+ Use `Enumerable#flat_map`
577
+ instead of `Enumerable#map...Array#flatten(1)`
578
+ or `Enumberable#collect..Array#flatten(1)`
579
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code'
580
+ Enabled: false
581
+
582
+ Performance/ReverseEach:
583
+ Description: 'Use `reverse_each` instead of `reverse.each`.'
584
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
585
+ Enabled: false
586
+
587
+ Performance/Sample:
588
+ Description: >-
589
+ Use `sample` instead of `shuffle.first`,
590
+ `shuffle.last`, and `shuffle[Fixnum]`.
591
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
592
+ Enabled: false
593
+
594
+ Performance/Size:
595
+ Description: >-
596
+ Use `size` instead of `count` for counting
597
+ the number of elements in `Array` and `Hash`.
598
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code'
599
+ Enabled: false
600
+
601
+ Performance/StringReplacement:
602
+ Description: >-
603
+ Use `tr` instead of `gsub` when you are replacing the same
604
+ number of characters. Use `delete` instead of `gsub` when
605
+ you are deleting characters.
606
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
607
+ Enabled: false
608
+
609
+ # Rails
610
+
611
+ Rails/ActionFilter:
612
+ Description: 'Enforces consistent use of action filter methods.'
613
+ Enabled: false
614
+
615
+ Rails/Date:
616
+ Description: >-
617
+ Checks the correct usage of date aware methods,
618
+ such as Date.today, Date.current etc.
619
+ Enabled: false
620
+
621
+ Rails/FindBy:
622
+ Description: 'Prefer find_by over where.first.'
623
+ Enabled: false
624
+
625
+ Rails/FindEach:
626
+ Description: 'Prefer all.find_each over all.find.'
627
+ Enabled: false
628
+
629
+ Rails/HasAndBelongsToMany:
630
+ Description: 'Prefer has_many :through to has_and_belongs_to_many.'
631
+ Enabled: false
632
+
633
+ Rails/Output:
634
+ Description: 'Checks for calls to puts, print, etc.'
635
+ Enabled: false
636
+
637
+ Rails/ReadWriteAttribute:
638
+ Description: >-
639
+ Checks for read_attribute(:attr) and
640
+ write_attribute(:attr, val).
641
+ Enabled: false
642
+
643
+ Rails/ScopeArgs:
644
+ Description: 'Checks the arguments of ActiveRecord scopes.'
645
+ Enabled: false
646
+
647
+ Rails/TimeZone:
648
+ Description: 'Checks the correct usage of time zone aware methods.'
649
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
650
+ Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
651
+ Enabled: false
652
+
653
+ Rails/Validation:
654
+ Description: 'Use validates :attribute, hash of validations.'
655
+ Enabled: false
data/strong_arms.gemspec CHANGED
@@ -44,6 +44,7 @@ Gem::Specification.new do |spec|
44
44
  spec.add_development_dependency "bundler", "~> 1.17"
45
45
  spec.add_development_dependency "rake", "~> 10.0"
46
46
  spec.add_development_dependency "rspec", "~> 3.0"
47
+ spec.add_development_dependency "pry"
47
48
 
48
49
  spec.add_runtime_dependency(%q<activesupport>, [">= 5.1.6"])
49
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strong_arms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mrjonesbot
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-29 00:00:00.000000000 Z
11
+ date: 2019-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
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
  - !ruby/object:Gem::Dependency
56
70
  name: activesupport
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -86,10 +100,10 @@ files:
86
100
  - bin/setup
87
101
  - lib/strong_arms.rb
88
102
  - lib/strong_arms/assertions.rb
89
- - lib/strong_arms/errors.rb
90
103
  - lib/strong_arms/exception_methods.rb
91
104
  - lib/strong_arms/utilities.rb
92
105
  - lib/strong_arms/version.rb
106
+ - rubocop.yml
93
107
  - strong_arms.gemspec
94
108
  homepage: https://github.com/launchpadlab/strong_arms
95
109
  licenses:
@@ -111,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
125
  - !ruby/object:Gem::Version
112
126
  version: '0'
113
127
  requirements: []
114
- rubyforge_project:
115
- rubygems_version: 2.7.6
128
+ rubygems_version: 3.0.3
116
129
  signing_key:
117
130
  specification_version: 4
118
131
  summary: Strong Parameters alternative for Ruby/Rails applications
@@ -1,7 +0,0 @@
1
- module Errors
2
- class UnhandledKeys < StandardError
3
- def initialize(msg)
4
- super
5
- end
6
- end
7
- end