rails_location_header 1.0.0 → 1.0.1

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: 696b01eca7e43eed0195a37b7b4e5e5ba72ab9ac1e725241b8f267cfd8220d8b
4
- data.tar.gz: 674590529d3ec6e6001a76956453d63294e8d0da5009dffb9c1add4303585e82
3
+ metadata.gz: 941141f446f4cdf43b321c173f20fed5afbf132f4a0d34fe3265c4b4d974b182
4
+ data.tar.gz: e411dc790ef6ccf393e7d24c2bd6c86ba3826adfa5a52b9a99e2121b823be160
5
5
  SHA512:
6
- metadata.gz: 60333c451604134cab7190adf7a7f2e35923db147768b476a4cb4e32207fa6b36fd70c80d2b14cd0da90e80222c9d50536af10da39e6931c6e5aae9fb076f905
7
- data.tar.gz: c905acb2cf8d99fa27d86c44a532dad223c52e85a92fdf012dd75f370bdf5faa51f2e7f1216a7d560bccf5d0aa0f643e0c795d83a912043263b309f88b19d651
6
+ metadata.gz: bdfd34a0e402297aaab4735e34d5bd3b865f0b733120805c83014798b0c1938d150a97a2fef7306edab2feab48e4be84e97db8692178d16aabb919505d5537d4
7
+ data.tar.gz: bd1d9a54e8cca01da0a9ae4e557bdd18d7279b682aa60d44a5e483aad903bb90a5e0df403ec7be33ec26b5c91b7a8a972edf90a56933da0f1dd7571b5f244718
data/.rubocop.yml CHANGED
@@ -1,8 +1,313 @@
1
+ plugins:
2
+ - rubocop-performance
3
+
4
+ inherit_mode:
5
+ merge:
6
+ - Exclude
7
+
1
8
  AllCops:
2
- TargetRubyVersion: 3.0
9
+ NewCops: enable
10
+ SuggestExtensions: false
11
+ Exclude:
12
+ - "data/**/*"
13
+ - "db/**/*"
14
+
15
+ # All cops except your using extensions are disabled by default.
16
+ Bundler:
17
+ Enabled: false
18
+ Gemspec:
19
+ Enabled: false
20
+ Layout:
21
+ Enabled: false
22
+ Lint:
23
+ Enabled: false
24
+ Metrics:
25
+ Enabled: false
26
+ Naming:
27
+ Enabled: false
28
+ Performance:
29
+ Enabled: false
30
+ Exclude:
31
+ - "test/**/*"
32
+ - "spec/**/*"
33
+ Security:
34
+ Enabled: false
35
+ Style:
36
+ Enabled: false
37
+
38
+ # Align `when` with `end`.
39
+ Layout/CaseIndentation:
40
+ Enabled: true
41
+ EnforcedStyle: end
42
+
43
+ # Align comments with method definitions.
44
+ Layout/CommentIndentation:
45
+ Enabled: true
46
+
47
+ Layout/ElseAlignment:
48
+ Enabled: true
49
+
50
+ Layout/EmptyLineAfterMagicComment:
51
+ Enabled: true
52
+
53
+ Layout/EmptyLinesAroundBlockBody:
54
+ Enabled: true
55
+
56
+ # In a regular class definition, no empty lines around the body.
57
+ Layout/EmptyLinesAroundClassBody:
58
+ Enabled: true
59
+
60
+ # In a regular method definition, no empty lines around the body.
61
+ Layout/EmptyLinesAroundMethodBody:
62
+ Enabled: true
63
+
64
+ # In a regular module definition, no empty lines around the body.
65
+ Layout/EmptyLinesAroundModuleBody:
66
+ Enabled: true
67
+
68
+ # Align `end` with the matching keyword or starting expression except for
69
+ # assignments, where it should be aligned with the LHS.
70
+ Layout/EndAlignment:
71
+ Enabled: true
72
+ EnforcedStyleAlignWith: variable
73
+
74
+ # Method definitions after `private` or `protected` isolated calls need one
75
+ # extra level of indentation.
76
+ #
77
+ # We break this rule in context, though, e.g. for private-only concerns,
78
+ # so we leave it disabled.
79
+ Layout/IndentationConsistency:
80
+ Enabled: false
81
+ EnforcedStyle: indented_internal_methods
82
+
83
+ # Detect hard tabs, no hard tabs.
84
+ Layout/IndentationStyle:
85
+ Enabled: true
86
+
87
+ # Two spaces, no tabs (for indentation).
88
+ #
89
+ # Doesn't behave properly with private-only concerns, so it's disabled.
90
+ Layout/IndentationWidth:
91
+ Enabled: false
92
+
93
+ Layout/LeadingCommentSpace:
94
+ Enabled: true
95
+
96
+ Layout/SpaceAfterColon:
97
+ Enabled: true
98
+
99
+ Layout/SpaceAfterComma:
100
+ Enabled: true
101
+
102
+ Layout/SpaceAroundEqualsInParameterDefault:
103
+ Enabled: true
104
+
105
+ Layout/SpaceAroundKeyword:
106
+ Enabled: true
107
+
108
+ # Use `foo {}` not `foo{}`.
109
+ Layout/SpaceBeforeBlockBraces:
110
+ Enabled: true
111
+
112
+ Layout/SpaceBeforeComma:
113
+ Enabled: true
114
+
115
+ Layout/SpaceBeforeFirstArg:
116
+ Enabled: true
117
+
118
+ # Use `[ a, [ b, c ] ]` not `[a, [b, c]]`
119
+ # Use `[]` not `[ ]`
120
+ Layout/SpaceInsideArrayLiteralBrackets:
121
+ Enabled: true
122
+ EnforcedStyle: no_space
123
+ EnforcedStyleForEmptyBrackets: no_space
124
+
125
+ # Use `%w[ a b ]` not `%w[ a b ]`.
126
+ Layout/SpaceInsideArrayPercentLiteral:
127
+ Enabled: true
128
+
129
+ # Use `foo { bar }` not `foo {bar}`.
130
+ # Use `foo { }` not `foo {}`.
131
+ Layout/SpaceInsideBlockBraces:
132
+ Enabled: true
133
+ EnforcedStyleForEmptyBraces: space
134
+
135
+ # Use `{ a: 1 }` not `{a:1}`.
136
+ # Use `{}` not `{ }`.
137
+ Layout/SpaceInsideHashLiteralBraces:
138
+ Enabled: true
139
+ EnforcedStyle: space
140
+ EnforcedStyleForEmptyBraces: no_space
141
+
142
+ # Use `foo(bar)` not `foo( bar )`
143
+ Layout/SpaceInsideParens:
144
+ Enabled: true
145
+
146
+ # Requiring a space is not yet supported as of 0.59.2
147
+ # Use `%w[ foo ]` not `%w[foo]`
148
+ Layout/SpaceInsidePercentLiteralDelimiters:
149
+ Enabled: false
150
+ #EnforcedStyle: space
151
+
152
+ # Use `hash[:key]` not `hash[ :key ]`
153
+ Layout/SpaceInsideReferenceBrackets:
154
+ Enabled: true
155
+
156
+ # Blank lines should not have any spaces.
157
+ Layout/TrailingEmptyLines:
158
+ Enabled: true
3
159
 
160
+ # No trailing whitespace.
161
+ Layout/TrailingWhitespace:
162
+ Enabled: true
163
+
164
+ Lint/RedundantStringCoercion:
165
+ Enabled: true
166
+
167
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
168
+ Lint/RequireParentheses:
169
+ Enabled: true
170
+
171
+ Lint/UriEscapeUnescape:
172
+ Enabled: true
173
+
174
+ Performance/FlatMap:
175
+ Enabled: true
176
+
177
+ # We generally prefer &&/|| but like low-precedence and/or in context
178
+ Style/AndOr:
179
+ Enabled: false
180
+
181
+ # Prefer Foo.method over Foo::method
182
+ Style/ColonMethodCall:
183
+ Enabled: true
184
+
185
+ Style/DefWithParentheses:
186
+ Enabled: true
187
+
188
+ # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
189
+ Style/HashSyntax:
190
+ Enabled: true
191
+ EnforcedShorthandSyntax: either
192
+
193
+ # Defining a method with parameters needs parentheses.
194
+ Style/MethodDefParentheses:
195
+ Enabled: true
196
+
197
+ Style/ParenthesesAroundCondition:
198
+ Enabled: true
199
+
200
+ Style/PercentLiteralDelimiters:
201
+ Enabled: true
202
+ PreferredDelimiters:
203
+ default: "()"
204
+ "%i": "[]"
205
+ "%I": "[]"
206
+ "%r": "{}"
207
+ "%w": "[]"
208
+ "%W": "[]"
209
+
210
+ # Use quotes for string literals when they are enough.
211
+ Style/RedundantPercentQ:
212
+ Enabled: false
213
+
214
+ Style/RedundantReturn:
215
+ Enabled: true
216
+ AllowMultipleReturnValues: false
217
+
218
+ Style/Semicolon:
219
+ Enabled: true
220
+ AllowAsExpressionSeparator: true
221
+
222
+ Style/StabbyLambdaParentheses:
223
+ Enabled: true
224
+
225
+ # Use `"foo"` not `'foo'` unless escaping is required
4
226
  Style/StringLiterals:
5
- EnforcedStyle: double_quotes
227
+ Enabled: true
228
+ EnforcedStyle: single_quotes
229
+ Include:
230
+ - "app/**/*"
231
+ - "config/**/*"
232
+ - "lib/**/*"
233
+ - "test/**/*"
234
+ - "spec/**/*"
235
+ - "Gemfile"
236
+
237
+ Style/TrailingCommaInArrayLiteral:
238
+ Enabled: true
239
+
240
+ Style/TrailingCommaInHashLiteral:
241
+ Enabled: true
242
+
243
+ Layout/EmptyLinesAroundAccessModifier:
244
+ Enabled: true
245
+
246
+ Layout/EmptyLineBetweenDefs:
247
+ Enabled: true
248
+
249
+ Layout/LineLength:
250
+ Enabled: true
251
+ Exclude:
252
+ - "db/**/*"
253
+ - "config/routes.rb"
254
+ - "bin/**/*"
255
+
256
+ Metrics/AbcSize:
257
+ Enabled: true
258
+ Max: 17
259
+ Exclude:
260
+ - "db/**/*"
261
+ - "config/routes.rb"
262
+ - "bin/**/*"
263
+
264
+ Metrics/BlockLength:
265
+ Enabled: true
266
+ Exclude:
267
+ - "db/**/*"
268
+ - "spec/**/*"
269
+ - "config/routes.rb"
270
+ - "bin/**/*"
271
+
272
+ Metrics/BlockNesting:
273
+ Enabled: true
274
+ Max: 1
275
+ Exclude:
276
+ - "db/**/*"
277
+ - "config/routes.rb"
278
+ - "bin/**/*"
279
+
280
+ Metrics/CyclomaticComplexity:
281
+ Enabled: true
282
+ Exclude:
283
+ - "db/**/*"
284
+ - "config/routes.rb"
285
+ - "bin/**/*"
286
+
287
+ Metrics/MethodLength:
288
+ Enabled: true
289
+ Max: 8
290
+ Exclude:
291
+ - "db/**/*"
292
+ - "config/routes.rb"
293
+ - "bin/**/*"
294
+
295
+ Metrics/PerceivedComplexity:
296
+ Enabled: true
297
+ Exclude:
298
+ - "db/**/*"
299
+ - "config/routes.rb"
300
+ - "bin/**/*"
301
+
302
+ Style/Documentation:
303
+ Enabled: false
304
+
305
+ Style/FrozenStringLiteralComment:
306
+ Enabled: false
307
+
308
+ Style/MethodCallWithArgsParentheses:
309
+ Enabled: true
310
+ EnforcedStyle: omit_parentheses
6
311
 
7
- Style/StringLiteralsInInterpolation:
8
- EnforcedStyle: double_quotes
312
+ Layout/EmptyLineAfterGuardClause:
313
+ Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,4 +1,44 @@
1
- ## [Unreleased]
1
+ ## [1.0.1] - 2025-03-24
2
+
3
+ ### Added
4
+
5
+ - Introduced `rubocop-performance` gem for enhanced linting capabilities.
6
+ - Enabled additional RuboCop cops for improved code quality and consistency.
7
+
8
+ ### Changed
9
+
10
+ - Updated `.rubocop.yml` to include detailed configuration for various cops.
11
+ - Updated `Gemfile` to use single quotes for consistency.
12
+ - Updated `Gemfile.lock` to reflect the addition of `rubocop-performance`.
13
+ - Updated `rails_location_header.gemspec` to improve formatting and readability.
14
+ - Updated `lib/rails_location_header.rb` and other files to align with RuboCop's style guidelines:
15
+ - Replaced double quotes with single quotes where applicable.
16
+ - Adjusted method calls to remove unnecessary parentheses.
17
+ - Improved formatting for multi-line method calls.
18
+
19
+ ### Fixed
20
+
21
+ - Fixed minor inconsistencies in the `ControllerExtension` and `Railtie` modules.
22
+ - Fixed version mismatch in `lib/rails_location_header/version.rb` (updated to `1.0.1`).
23
+
24
+ ### Removed
25
+
26
+ - Removed unnecessary comments and redundant code from `rails_location_header.gemspec`.
27
+
28
+ ## [1.0.0] - 2025-03-24
29
+
30
+ ### Added
31
+
32
+ - Added `X-Entity-ID` and `Location` headers to `create` actions via `ControllerExtension`.
33
+ - Introduced `Middleware` class for potential future enhancements.
34
+ - Integrated `Railtie` to automatically include `ControllerExtension` in Rails controllers.
35
+ - Updated gemspec with metadata, dependencies, and author information.
36
+ - Enhanced README with installation, usage, and contribution guidelines.
37
+
38
+ ### Changed
39
+
40
+ - Updated version to `1.0.0` in `version.rb`.
41
+ - Improved gemspec description and summary.
2
42
 
3
43
  ## [0.1.0] - 2025-03-24
4
44
 
@@ -11,22 +11,22 @@ module CreatedEntityHeader
11
11
  def add_location_header
12
12
  return unless response.status == 201
13
13
 
14
- created_resource = instance_variable_get("@#{controller_name.singularize}")
15
- return unless created_resource.respond_to?(:id)
14
+ created_resource = instance_variable_get "@#{controller_name.singularize}"
15
+ return unless created_resource.respond_to? :id
16
16
 
17
- response.headers["X-Entity-ID"] = created_resource.id.to_s
17
+ response.headers['X-Entity-ID'] = created_resource.id.to_s
18
18
 
19
- response.headers["Location"] = url_for(created_resource)
19
+ response.headers['Location'] = url_for created_resource
20
20
  end
21
21
 
22
22
  def url_for(created_resource)
23
23
  url_helpers = Rails.application.routes.url_helpers
24
- url_helpers.url_for(
24
+ url_helpers.url_for \
25
25
  controller: controller_name, action: :show,
26
26
  id: created_resource.id,
27
27
  only_path: false,
28
28
  host: request.host, port: request.port
29
- )
29
+
30
30
  rescue StandardError => e
31
31
  Rails.logger.warn "[RailsLocationHeader] Could not set Location Header: #{e.message}"
32
32
  end
@@ -1,6 +1,6 @@
1
1
  module CreatedEntityHeader
2
2
  class Railtie < Rails::Railtie
3
- initializer "created_entity_header.configure_controller" do
3
+ initializer 'created_entity_header.configure_controller' do
4
4
  ActiveSupport.on_load :action_controller do
5
5
  include CreatedEntityHeader::ControllerExtension
6
6
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsLocationHeader
4
- VERSION = "1.0.0"
4
+ VERSION = '1.0.1'
5
5
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "rails_location_header/version"
4
- require "rails_location_header/railtie" if defined?(Rails)
5
- require "rails_location_header/controller_extension"
3
+ require_relative 'rails_location_header/version'
4
+ require 'rails_location_header/railtie' if defined?(Rails)
5
+ require 'rails_location_header/controller_extension'
6
6
 
7
7
  module RailsLocationHeader
8
8
  class Middleware
@@ -11,7 +11,7 @@ module RailsLocationHeader
11
11
  end
12
12
 
13
13
  def call(env)
14
- status, headers, response = @app.call(env)
14
+ status, headers, response = @app.call env
15
15
  [status, headers, response]
16
16
  end
17
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_location_header
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eli Sebastian Herrera Aguilar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-03-24 00:00:00.000000000 Z
11
+ date: 2025-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,8 +24,9 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '6.0'
27
- description: A Rails gem that automatically adds X-Entity-ID and Location headers
28
- when a new record is created successfully.
27
+ description: |-
28
+ A Rails gem that automatically adds X-Entity-ID and Location headers when a new record is created
29
+ successfully.
29
30
  email:
30
31
  - esrbastianherrera@gmail.com
31
32
  executables: []