request_migrations 1.1.1 → 1.1.2

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: '091e4436fcd439967859301cc299fccaf6081f5da326ed79813e7cbce3f4d86c'
4
- data.tar.gz: 4be2f76ade4958a48794ee62e6184c964f747f6c59a44a12ef20dcbbcc8c32a0
3
+ metadata.gz: 9a4bcd66e61c3fbda8dd1a2d68c84953bd44cfb2b1c9fed79e90a0965cb1853d
4
+ data.tar.gz: b772558c45d89f41d9c0eceab0b118e141fd93f31d40e037b810b669f2dfc997
5
5
  SHA512:
6
- metadata.gz: e2a22c88034bd0a67f34849909d85686267a4fd2a62dfbcfcb963766f678397d141a628608b63e0549581fbd9e02184a938619a269c81e44bd1a094d2febe702
7
- data.tar.gz: d92878fd3a359c744c4cc9354325a5fea7d89ca81e9c3aa2718bd033a8b7ed8f7840f8bce0ada3f170dfb8f3a1ea9f1362cff8b08effafee53ffc0b5b59911c4
6
+ metadata.gz: d6727a31da8a3bbf69d013af4c68a873ff7c1c09a17f407906f27469df8c822aa070207e9ab6fa39299e3ef2960c8184efa954f9417c6678c3f242808add7cfa
7
+ data.tar.gz: 7086a2c8604219bef3d9b7040897f0faa30cb2ff19d800ea1ab9011db3dad2d11b25d8e77b2e98b09175b90e2ad93180664278c60ea5af9d47fbe4c52c6b8388
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.2
4
+
5
+ - Remove deprecated `ActiveSupport::Configurable`.
6
+
7
+ ## 1.1.1
8
+
9
+ - Fix minimum required Ruby version from v3.0 to v3.1.
10
+
11
+ ## 1.1.0
12
+
13
+ - Add `request_migrations/testing` for unit testing migrations.
14
+
3
15
  ## 1.0.1
4
16
 
5
17
  - Fix application order of `request` migrations.
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # request_migrations
2
2
 
3
+ [![CI](https://github.com/keygen-sh/request_migrations/actions/workflows/test.yml/badge.svg)](https://github.com/keygen-sh/request_migrations/actions)
3
4
  [![Gem Version](https://badge.fury.io/rb/request_migrations.svg)](https://badge.fury.io/rb/request_migrations)
4
5
 
5
6
  **Make breaking API changes without breaking things!** Use `request_migrations` to craft
@@ -13,9 +14,13 @@ to serve millions of API requests per day.
13
14
 
14
15
  Sponsored by:
15
16
 
16
- [![Keygen logo](https://user-images.githubusercontent.com/6979737/175406169-bd8bf064-7343-4bd1-94b7-a773ecec07b8.png)](https://keygen.sh)
17
+ <a href="https://keygen.sh?ref=request_migrations">
18
+ <div>
19
+ <img src="https://keygen.sh/images/logo-pill.png" width="200" alt="Keygen">
20
+ </div>
21
+ </a>
17
22
 
18
- _A software licensing and distribution API built for developers._
23
+ _A fair source software licensing and distribution API._
19
24
 
20
25
  Links:
21
26
 
@@ -31,6 +36,7 @@ Links:
31
36
  - [Version formats](#version-formats)
32
37
  - [Testing](#testing)
33
38
  - [Tips and tricks](#tips-and-tricks)
39
+ - [Examples](#examples)
34
40
  - [Credits](#credits)
35
41
  - [Contributing](#contributing)
36
42
  - [License](#license)
@@ -217,6 +223,8 @@ The gem makes no assumption on a response's content type or what the migration
217
223
  will do. You could, for example, migrate the response body, or mutate the
218
224
  headers, or even change the response's status code.
219
225
 
226
+ The `response` method can be used multiple times per-migration.
227
+
220
228
  ### Request migrations
221
229
 
222
230
  Request migrations define a change on a request. For example, modifying a request's
@@ -244,6 +252,8 @@ headers. It's up to you, all it does is provide the request.
244
252
 
245
253
  Request migrations should [avoid using the `migrate` method](#avoid-migrate-for-request-migrations).
246
254
 
255
+ The `request` method can be used multiple times.
256
+
247
257
  ### Data migrations
248
258
 
249
259
  In our first scenario, where we combined our user's name attributes, we defined
@@ -317,6 +327,10 @@ be applied.
317
327
 
318
328
  In addition to data migrations, this allows for easier [testing](#testing).
319
329
 
330
+ The `migrate` method can be used multiple times per-migration to e.g.
331
+ match and migrate on different shapes of data. For a JSON:API app,
332
+ for example, you could migrate on `data: [*]` and `includes: [*]`.
333
+
320
334
  ### Routing constraints
321
335
 
322
336
  When you want to encourage API clients to upgrade, you can utilize a routing `version_constraint`
@@ -527,7 +541,7 @@ end
527
541
  And for a response containing a collection of users:
528
542
 
529
543
  ```ruby
530
- class CombineNamesForUserMigration < RequestMigrations::Migration
544
+ class CombineNamesForUsersMigration < RequestMigrations::Migration
531
545
  description %(transforms a collection of users' first and last names to a combined name attribute)
532
546
 
533
547
  migrate if: -> data { data in [*, { type: 'user' }, *] do |data|
@@ -628,7 +642,7 @@ end
628
642
 
629
643
  Avoid using routing version constraints that remove functionality. They can be a headache
630
644
  during upgrades. Consider only making _additive_ changes. Instead, consider removing or
631
- hiding the documenation for old or deprecated endpoints, to limit any new usage.
645
+ hiding the documentation for old or deprecated endpoints, to limit any new usage.
632
646
 
633
647
  ```ruby
634
648
  Rails.application.routes.draw do
@@ -705,6 +719,13 @@ to get the data we need in order to complete the migration.
705
719
 
706
720
  Have a tip of your own? Open a pull request!
707
721
 
722
+ ## Examples
723
+
724
+ Below are some real-world examples of request migrations:
725
+
726
+ - Migrations: https://github.com/keygen-sh/keygen-api/tree/master/app/migrations
727
+ - Tests: https://github.com/keygen-sh/keygen-api/tree/master/spec/migrations
728
+
708
729
  ## Is it any good?
709
730
 
710
731
  Yes.
data/SECURITY.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # Security Policy
2
2
 
3
- ## Reporting a Vulnerability
3
+ ## Reporting a vulnerability
4
4
 
5
5
  If you find a vulnerability in `request_migrations`, please contact Keygen via
6
- [email](mailto:security@keygen.sh). You will be given public credit for your
7
- disclosure.
6
+ [email](mailto:security@keygen.sh).
7
+
8
+ You will be given public credit for your disclosure.
@@ -2,37 +2,40 @@
2
2
 
3
3
  module RequestMigrations
4
4
  class Configuration
5
- include ActiveSupport::Configurable
6
-
7
5
  ##
8
6
  # logger defines the logger used by request_migrations.
9
7
  #
10
8
  # @return [Logger] the logger.
11
- config_accessor(:logger) { Logger.new("/dev/null") }
9
+ class_attribute :logger
10
+ self.logger = Logger.new("/dev/null")
12
11
 
13
12
  ##
14
13
  # request_version_resolver defines how request_migrations should resolve the
15
14
  # current version of a request.
16
15
  #
17
16
  # @return [Proc] the request version resolver.
18
- config_accessor(:request_version_resolver) { -> req { self.current_version } }
17
+ class_attribute :request_version_resolver
18
+ self.request_version_resolver = -> req { self.current_version }
19
19
 
20
20
  ##
21
21
  # version_format defines the version format.
22
22
  #
23
23
  # @return [Symbol] format
24
- config_accessor(:version_format) { :semver }
24
+ class_attribute :version_format
25
+ self.version_format = :semver
25
26
 
26
27
  ##
27
28
  # current_version defines the latest version.
28
29
  #
29
30
  # @return [String, Integer, Float, nil] the current version.
30
- config_accessor(:current_version) { nil }
31
+ class_attribute :current_version
32
+ self.current_version = nil
31
33
 
32
34
  ##
33
35
  # versions defines past versions and their migrations.
34
36
  #
35
37
  # @return [Hash<String, Array<Symbol, String, Class>>] past versions.
36
- config_accessor(:versions) { {} }
38
+ class_attribute :versions
39
+ self.versions = {}
37
40
  end
38
41
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RequestMigrations
4
- VERSION = "1.1.1"
4
+ VERSION = "1.1.2"
5
5
  end
@@ -9,10 +9,7 @@ module RequestMigrations
9
9
  def self.setup!
10
10
  @@config = RequestMigrations.config
11
11
 
12
- RequestMigrations.reset!
13
- RequestMigrations.configure do |config|
14
- @@config.config.each { |(k, v)| config.config[k] = v }
15
- end
12
+ RequestMigrations.config = @@config.dup
16
13
  end
17
14
 
18
15
  ##
@@ -52,12 +52,6 @@ module RequestMigrations
52
52
  @config = cfg
53
53
  end
54
54
 
55
- ##
56
- # @private
57
- def self.reset!
58
- @config = Configuration.new
59
- end
60
-
61
55
  ##
62
56
  # logger returns the configured logger.
63
57
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: request_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zeke Gabrielse
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-30 00:00:00.000000000 Z
11
+ date: 2025-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -80,7 +80,7 @@ homepage: https://github.com/keygen-sh/request_migrations
80
80
  licenses:
81
81
  - MIT
82
82
  metadata: {}
83
- post_install_message:
83
+ post_install_message:
84
84
  rdoc_options: []
85
85
  require_paths:
86
86
  - lib
@@ -95,8 +95,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  requirements: []
98
- rubygems_version: 3.3.7
99
- signing_key:
98
+ rubygems_version: 3.5.11
99
+ signing_key:
100
100
  specification_version: 4
101
101
  summary: Write request and response migrations for your Ruby on Rails API.
102
102
  test_files: []