rails-rfc6570 2.5.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +49 -15
- data/README.md +12 -18
- data/lib/rails/rfc6570/formatter.rb +2 -2
- data/lib/rails/rfc6570/version.rb +3 -3
- data/lib/rails/rfc6570.rb +3 -6
- data/rails-rfc6570.gemspec +7 -4
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/log/test.log +96 -2964
- data/spec/rails/rfc6570/visitor_spec.rb +2 -2
- data/spec/rails/rfc6570_spec.rb +2 -2
- metadata +9 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7e8a03b1cefe0054439f9582d9d8befbba54e09c4d01ccc170f8e4be3d49295
|
4
|
+
data.tar.gz: f45beb2b71490f95993245b3c34b9ff56724dd889486353ac763d1f373cc6346
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d52809f1e00ac16f94dd1254601955b722456c23d4cd0c4eb0e322e1e618842ac2c7336acbc7b73f1c35a17cc80d62659dc3d2a94f39fea99f0d15bf8faf5c9
|
7
|
+
data.tar.gz: f82e393910a7a48f9606de6a79439f35a267be250dd2d3c6eb2dd2efdf087393e7d1ddc87ed31b8ea4947b588b92f732ef1a748a88a4e33093279e553cf832dd
|
data/CHANGELOG.md
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Changelog](http://keepachangelog.com/).
|
5
5
|
|
6
|
-
|
7
6
|
## Unreleased
|
7
|
+
|
8
8
|
---
|
9
9
|
|
10
10
|
### New
|
@@ -15,63 +15,97 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch
|
|
15
15
|
|
16
16
|
### Breaks
|
17
17
|
|
18
|
+
## 3.0.0 - (2023-09-04)
|
19
|
+
|
20
|
+
---
|
21
|
+
|
22
|
+
### New
|
23
|
+
|
24
|
+
- Add Ruby 3.1 and 3.2 to test matrix
|
25
|
+
|
26
|
+
### Changes
|
27
|
+
|
28
|
+
- Drop Ruby < 2.7 from test matrix
|
29
|
+
- Drop Rails < 6.1 from test matrix
|
30
|
+
|
31
|
+
### Breaks
|
32
|
+
|
33
|
+
- Require Ruby 2.7+
|
34
|
+
|
35
|
+
## 2.6.0 - (2021-12-16)
|
36
|
+
|
37
|
+
---
|
38
|
+
|
39
|
+
### New
|
40
|
+
|
41
|
+
- Support for Rails 7
|
18
42
|
|
19
43
|
## 2.5.0 - (2020-12-13)
|
44
|
+
|
20
45
|
---
|
21
46
|
|
22
47
|
### New
|
23
|
-
* Add support for Rails 6.1
|
24
48
|
|
49
|
+
- Add support for Rails 6.1
|
25
50
|
|
26
51
|
## 2.4.0
|
52
|
+
|
27
53
|
---
|
28
54
|
|
29
|
-
|
55
|
+
- Add support for Rails 6.0
|
30
56
|
|
31
57
|
## 2.3.0
|
58
|
+
|
32
59
|
---
|
33
60
|
|
34
|
-
|
35
|
-
|
61
|
+
- Newly written visitor and formatter to improve performance (#3)
|
62
|
+
- Nested groups are expanded into a list of groups
|
36
63
|
|
37
64
|
## 2.2.0
|
65
|
+
|
38
66
|
---
|
39
67
|
|
40
|
-
|
68
|
+
- Add support to Rails 5.2 to gemspec
|
41
69
|
|
42
70
|
## 2.1.0
|
71
|
+
|
43
72
|
---
|
44
73
|
|
45
|
-
|
74
|
+
- Add emulation for Rails' routing behavior with original script name
|
46
75
|
|
47
76
|
## 2.0.0
|
77
|
+
|
48
78
|
---
|
49
79
|
|
50
|
-
|
51
|
-
|
80
|
+
- Add support for Rails 5.1
|
81
|
+
- Drop support for Rails < 4.2
|
52
82
|
|
53
83
|
## 1.1.1
|
84
|
+
|
54
85
|
---
|
55
86
|
|
56
|
-
|
87
|
+
- Fix full URL generation to not use `root_url` helper to avoid depending on that and to improve compatibility with e.g. rails engines.
|
57
88
|
|
58
89
|
## 1.1.0
|
90
|
+
|
59
91
|
---
|
60
92
|
|
61
|
-
|
93
|
+
- Added support for Rails 5.0
|
62
94
|
|
63
95
|
## 1.0.0
|
96
|
+
|
64
97
|
---
|
65
98
|
|
66
|
-
|
99
|
+
- No changes just bumping version to a production release
|
67
100
|
|
68
101
|
## 0.3.0
|
102
|
+
|
69
103
|
---
|
70
104
|
|
71
|
-
|
105
|
+
- Added Rails 4.2 support
|
72
106
|
|
73
107
|
## 0.2.0
|
74
|
-
---
|
75
108
|
|
76
|
-
|
109
|
+
---
|
77
110
|
|
111
|
+
- Added `_path_rfc6570` and `_url_rfc6570` helpers (#2)
|
data/README.md
CHANGED
@@ -1,28 +1,22 @@
|
|
1
1
|
# Rails::RFC6570
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://img.shields.io/github/actions/workflow/status/jgraichen/rails-rfc6570/test.yml?logo=github)](https://github.com/jgraichen/rails-rfc6570/actions/workflows/test.yml)
|
4
4
|
|
5
|
-
Pragmatic access to your Rails routes as RFC6570 URI templates. Tested with Rails
|
5
|
+
Pragmatic access to your Rails routes as RFC6570 URI templates. Tested with Rails 6.1, 7.0 and Ruby 2.7, 3.0, 3.1, 3.2.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install rails-rfc6570
|
11
|
+
```ruby
|
12
|
+
gem 'rails-rfc6570', '~> 3.0'
|
13
|
+
```
|
20
14
|
|
21
15
|
## Usage
|
22
16
|
|
23
17
|
**Rails::RFC6570** gives you direct access to your Rails routes as RFC6570 URI templates using the [addressable](https://github.com/sporkmonger/addressable) gem. It further patches `Addressable::Template` with a `#as_json` and `#to_s` so that you can simply pass the template objects or even partial expanded templates to your render call, decorator or serializer.
|
24
18
|
|
25
|
-
|
19
|
+
The following examples print a JSON index resource just like `https://api.github.com`:
|
26
20
|
|
27
21
|
```ruby
|
28
22
|
class ApplicationController < ActionController::API
|
@@ -34,9 +28,9 @@ end
|
|
34
28
|
|
35
29
|
**Pro Tip**: Append `_url` to the route names: `rfc6570_routes.transform_keys {|k| "#{k}_url" }`.
|
36
30
|
|
37
|
-
By default the `format` placeholder is ignored and the HTTP host will be included in the URI template.
|
31
|
+
By default, the `format` placeholder is ignored and the HTTP host will be included in the URI template.
|
38
32
|
|
39
|
-
Additionally you can specify a list of query parameters in your controllers:
|
33
|
+
Additionally, you can specify a list of query parameters in your controllers:
|
40
34
|
|
41
35
|
```ruby
|
42
36
|
class UserController < ApplicationController
|
@@ -67,9 +61,9 @@ the root action will return something similar to the following JSON:
|
|
67
61
|
|
68
62
|
```json
|
69
63
|
{
|
70
|
-
"users": "http://localhost:3000/users{?query,email,active}",
|
71
|
-
"user": "http://localhost:3000/users/{id}",
|
72
|
-
"root": "http://localhost:3000/"
|
64
|
+
"users": "http://localhost:3000/users{?query,email,active}",
|
65
|
+
"user": "http://localhost:3000/users/{id}",
|
66
|
+
"root": "http://localhost:3000/"
|
73
67
|
}
|
74
68
|
```
|
75
69
|
|
@@ -114,7 +108,7 @@ end
|
|
114
108
|
|
115
109
|
## Contributing
|
116
110
|
|
117
|
-
1. Fork it
|
111
|
+
1. [Fork it](http://github.com/jgraichen/rails-routes/fork)
|
118
112
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
119
113
|
3. Add specs
|
120
114
|
4. Commit your changes (`git commit -am 'Add some feature'`)
|
@@ -10,7 +10,7 @@ module Rails
|
|
10
10
|
@parts = Visitor.new(factory: method(:symbol)).accept(route.path.spec)
|
11
11
|
end
|
12
12
|
|
13
|
-
def evaluate(ignore: %w[format],
|
13
|
+
def evaluate(ctx:, ignore: %w[format], **kwargs)
|
14
14
|
parts = @parts.reject do |part|
|
15
15
|
part.is_a?(Subst) && ignore.include?(part.name)
|
16
16
|
end
|
@@ -21,7 +21,7 @@ module Rails
|
|
21
21
|
|
22
22
|
if controller.present? && action.present?
|
23
23
|
params = ::Rails::RFC6570.params_for(controller, action)
|
24
|
-
parts <<
|
24
|
+
parts << ("{?#{params.join(',')}}") if params&.any?
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -3,12 +3,12 @@
|
|
3
3
|
module Rails
|
4
4
|
module RFC6570
|
5
5
|
module VERSION
|
6
|
-
MAJOR =
|
7
|
-
MINOR =
|
6
|
+
MAJOR = 3
|
7
|
+
MINOR = 0
|
8
8
|
PATCH = 0
|
9
9
|
STAGE = nil
|
10
10
|
|
11
|
-
STRING = [MAJOR, MINOR, PATCH, STAGE].
|
11
|
+
STRING = [MAJOR, MINOR, PATCH, STAGE].compact.join('.').freeze
|
12
12
|
|
13
13
|
def self.to_s
|
14
14
|
STRING
|
data/lib/rails/rfc6570.rb
CHANGED
@@ -13,9 +13,6 @@ module Rails
|
|
13
13
|
initializer 'rails-rfc6570', group: :all do |_app|
|
14
14
|
require 'rails/rfc6570/patches'
|
15
15
|
|
16
|
-
MAJOR = Rails::VERSION::MAJOR
|
17
|
-
MINOR = Rails::VERSION::MINOR
|
18
|
-
|
19
16
|
::ActionDispatch::Routing::RouteSet.include \
|
20
17
|
Rails::RFC6570::Extensions::RouteSet
|
21
18
|
|
@@ -42,7 +39,7 @@ module Rails
|
|
42
39
|
|
43
40
|
module NamedRouteCollection
|
44
41
|
def to_rfc6570(opts = {})
|
45
|
-
|
42
|
+
routes.to_h {|n, r| [n, r.to_rfc6570(opts)] }
|
46
43
|
end
|
47
44
|
|
48
45
|
def define_rfc6570_helpers(name, route, mod, set)
|
@@ -64,7 +61,7 @@ module Rails
|
|
64
61
|
self,
|
65
62
|
route,
|
66
63
|
**opts,
|
67
|
-
path_only: false
|
64
|
+
path_only: false,
|
68
65
|
)
|
69
66
|
end
|
70
67
|
|
@@ -73,7 +70,7 @@ module Rails
|
|
73
70
|
self,
|
74
71
|
route,
|
75
72
|
**opts,
|
76
|
-
path_only: true
|
73
|
+
path_only: true,
|
77
74
|
)
|
78
75
|
end
|
79
76
|
end
|
data/rails-rfc6570.gemspec
CHANGED
@@ -14,16 +14,19 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = 'https://github.com/jgraichen/rails-rfc6570'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
|
+
spec.metadata = {
|
18
|
+
'rubygems_mfa_required' => 'true',
|
19
|
+
}
|
20
|
+
|
17
21
|
spec.files = Dir['**/*'].grep(%r{^(
|
18
22
|
(bin|lib|test|spec|features)/|
|
19
23
|
(.*\.gemspec|.*LICENSE.*|.*README.*|.*CHANGELOG.*)
|
20
24
|
)}x)
|
21
25
|
spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
|
22
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
26
|
spec.require_paths = ['lib']
|
24
27
|
|
25
|
-
spec.
|
26
|
-
spec.add_runtime_dependency 'addressable', '~> 2.3'
|
28
|
+
spec.required_ruby_version = '>= 2.7'
|
27
29
|
|
28
|
-
spec.
|
30
|
+
spec.add_runtime_dependency 'actionpack', '>= 4.2', '< 7.1'
|
31
|
+
spec.add_runtime_dependency 'addressable', '~> 2.3'
|
29
32
|
end
|
data/spec/dummy/config/boot.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Set up gems listed in the Gemfile.
|
2
2
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
|
3
3
|
|
4
|
-
require 'bundler/setup' if File.
|
4
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
5
5
|
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
|