rest_framework 1.2.0 → 2.0.0.beta1

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.
@@ -22,11 +22,14 @@ module RESTFramework
22
22
  UNKNOWN
23
23
  end
24
24
 
25
- def self.stamp_version
26
- # Only stamp the version if it's not unknown.
27
- if RESTFramework::VERSION != UNKNOWN
28
- File.write(VERSION_FILEPATH, RESTFramework::VERSION)
25
+ def self.stamp_version(version = nil)
26
+ # Stamp the given version into the VERSION file, deriving it from git when none is provided.
27
+ # Returns the stamped version so callers don't rely on the (require-time) `VERSION` constant.
28
+ version ||= self.get_version
29
+ if version != UNKNOWN
30
+ File.write(VERSION_FILEPATH, version)
29
31
  end
32
+ version
30
33
  end
31
34
 
32
35
  def self.unstamp_version
@@ -34,5 +37,5 @@ module RESTFramework
34
37
  end
35
38
  end
36
39
 
37
- VERSION = Version.get_version
40
+ VERSION = Version.get_version(skip_git: true)
38
41
  end
@@ -1,26 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RESTFramework
4
- BUILTIN_FORM_ACTIONS = [ :new, :edit ].freeze
5
- BUILTIN_ACTIONS = {
6
- index: :get,
7
- new: :get,
8
- create: :post,
9
- }.freeze
10
- BUILTIN_MEMBER_ACTIONS = {
11
- show: :get,
12
- edit: :get,
13
- update: [ :put, :patch ].freeze,
14
- destroy: :delete,
15
- }.freeze
16
- RRF_BUILTIN_ACTIONS = {
17
- options: :options,
18
- }.freeze
19
- RRF_BUILTIN_BULK_ACTIONS = {
20
- update_all: [ :put, :patch ].freeze,
21
- destroy_all: :delete,
22
- }.freeze
23
-
24
4
  # Storage for extra routes and associated metadata.
25
5
  EXTRA_ACTION_ROUTES = Set.new
26
6
  ROUTE_METADATA = {}
@@ -47,6 +27,7 @@ module RESTFramework
47
27
  # Bootstrap Icons
48
28
  "bootstrap-icons.min.css" => {
49
29
  url: "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css",
30
+ sri: "sha384-XGjxtQfXaH2tnPFa9x+ruJTuLE3Aa6LhHSWRr1XeTyhezb4abCG4ccI5AkVDxqC+",
50
31
  inline_fonts: true,
51
32
  },
52
33
 
@@ -74,19 +55,23 @@ module RESTFramework
74
55
  extra_tag_attrs: { class: "rrf-light-mode" },
75
56
  },
76
57
 
77
- # NeatJSON
58
+ # NeatJSON. The package publishes no minified build; jsdelivr's `neatjson.min.js` is synthesized
59
+ # on the fly (so its bytes/SRI aren't stable), so we pin the published `neatjson.js` instead.
78
60
  "neatjson.min.js" => {
79
- url: "https://cdn.jsdelivr.net/npm/neatjson@0.10.6/javascript/neatjson.min.js",
61
+ url: "https://cdn.jsdelivr.net/npm/neatjson@0.10.6/javascript/neatjson.js",
62
+ sri: "sha384-7yRMvyGBuBnnlsgFwUDx7wY7Y/kXt7Irg5xppXVAI0yp3R0870lWaXNP/JE2rbFA",
80
63
  exclude_from_docs: true,
81
64
  },
82
65
 
83
66
  # Trix
84
67
  "trix.min.css" => {
85
68
  url: "https://unpkg.com/trix@2.0.8/dist/trix.css",
69
+ sri: "sha384-Cgg84c/W0Q5VrTzc4ITmV88Ocx4Pn1YlTXPvSTJjX6+lxJRLYrZ4chaighxlqOY1",
86
70
  exclude_from_docs: true,
87
71
  },
88
72
  "trix.min.js" => {
89
73
  url: "https://unpkg.com/trix@2.0.8/dist/trix.umd.min.js",
74
+ sri: "sha384-Ki3zDe3whjAHK/GOksrYLGCU8m0SkmiJQ4Kqm3jQlM3YCl2hFBf17s9bzjVYmXWX",
90
75
  exclude_from_docs: true,
91
76
  },
92
77
  }.map { |name, cfg|
@@ -149,19 +134,6 @@ module RESTFramework
149
134
  # Permits use of `render(api: obj)` syntax over `render_api(obj)`; `true` by default.
150
135
  attr_accessor :register_api_renderer
151
136
 
152
- # Run `rrf_finalize` on controllers automatically using a `TracePoint` hook. This is `true` by
153
- # default, and can be disabled for performance, and must be global because we have to determine
154
- # this before any controller-specific configuration is set. If this is set to `false`, then you
155
- # must manually call `rrf_finalize` after any configuration on each controller that needs to
156
- # participate in:
157
- # - Model delegation, for the helper methods to be defined dynamically.
158
- # - Websockets, for `::Channel` class to be defined dynamically.
159
- # - Controller configuration freezing.
160
- attr_accessor :auto_finalize
161
-
162
- # Freeze configuration attributes during finalization to prevent accidental mutation.
163
- attr_accessor :freeze_config
164
-
165
137
  # Specify reverse association tables that are typically very large, and therefore should not be
166
138
  # added to fields by default.
167
139
  attr_accessor :large_reverse_association_tables
@@ -188,8 +160,6 @@ module RESTFramework
188
160
 
189
161
  def initialize
190
162
  self.register_api_renderer = true
191
- self.auto_finalize = true
192
- self.freeze_config = true
193
163
 
194
164
  self.show_backtrace = Rails.env.development?
195
165
 
@@ -221,7 +191,6 @@ end
221
191
  require_relative "rest_framework/engine"
222
192
  require_relative "rest_framework/errors"
223
193
  require_relative "rest_framework/filters"
224
- require_relative "rest_framework/mixins"
225
194
  require_relative "rest_framework/paginators"
226
195
  require_relative "rest_framework/routers"
227
196
  require_relative "rest_framework/serializers"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory N. Schmit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-22 00:00:00.000000000 Z
11
+ date: 2026-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -55,6 +55,7 @@ files:
55
55
  - app/views/rest_framework/routes_and_forms/routes/_route.html.erb
56
56
  - lib/rest_framework.rb
57
57
  - lib/rest_framework/controller.rb
58
+ - lib/rest_framework/controller/actions.rb
58
59
  - lib/rest_framework/controller/bulk.rb
59
60
  - lib/rest_framework/controller/crud.rb
60
61
  - lib/rest_framework/controller/openapi.rb
@@ -66,10 +67,6 @@ files:
66
67
  - lib/rest_framework/filters/query_filter.rb
67
68
  - lib/rest_framework/filters/ransack_filter.rb
68
69
  - lib/rest_framework/filters/search_filter.rb
69
- - lib/rest_framework/mixins.rb
70
- - lib/rest_framework/mixins/base_controller_mixin.rb
71
- - lib/rest_framework/mixins/bulk_model_controller_mixin.rb
72
- - lib/rest_framework/mixins/model_controller_mixin.rb
73
70
  - lib/rest_framework/paginators.rb
74
71
  - lib/rest_framework/paginators/base_paginator.rb
75
72
  - lib/rest_framework/paginators/page_number_paginator.rb
@@ -101,9 +98,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
98
  version: 2.7.5
102
99
  required_rubygems_version: !ruby/object:Gem::Requirement
103
100
  requirements:
104
- - - ">="
101
+ - - ">"
105
102
  - !ruby/object:Gem::Version
106
- version: '0'
103
+ version: 1.3.1
107
104
  requirements: []
108
105
  rubygems_version: 3.4.10
109
106
  signing_key:
@@ -1,12 +0,0 @@
1
- module RESTFramework::Mixins::BaseControllerMixin
2
- def self.included(base)
3
- RESTFramework.deprecator.warn(
4
- "BaseControllerMixin is deprecated; use RESTFramework::Controller instead.",
5
- )
6
-
7
- base.include(RESTFramework::Controller)
8
- end
9
- end
10
-
11
- # Alias for convenience.
12
- RESTFramework::BaseControllerMixin = RESTFramework::Mixins::BaseControllerMixin
@@ -1,55 +0,0 @@
1
- module RESTFramework::Mixins::BulkCreateModelMixin
2
- def self.included(base)
3
- RESTFramework.deprecator.warn(<<~TXT).squish
4
- BulkCreateModelMixin is deprecated; set the `bulk = true` class attribute instead.
5
- TXT
6
-
7
- base.bulk = true
8
- end
9
- end
10
-
11
- # Mixin for updating records in bulk.
12
- module RESTFramework::Mixins::BulkUpdateModelMixin
13
- def self.included(base)
14
- RESTFramework.deprecator.warn(<<~TXT).squish
15
- BulkUpdateModelMixin is deprecated; set the `bulk = true`, and `excluded_actions` class
16
- attributes instead.
17
- TXT
18
-
19
- base.bulk = true
20
- base.excluded_actions = (base.excluded_actions - [ :update_all ]).freeze
21
- end
22
- end
23
-
24
- # Mixin for destroying records in bulk.
25
- module RESTFramework::Mixins::BulkDestroyModelMixin
26
- def self.included(base)
27
- RESTFramework.deprecator.warn(<<~TXT).squish
28
- BulkDestroyModelMixin is deprecated; set the `bulk = true`, and `excluded_actions` class
29
- attributes instead.
30
- TXT
31
-
32
- base.bulk = true
33
- base.excluded_actions = (base.excluded_actions - [ :destroy_all ]).freeze
34
- end
35
- end
36
-
37
- # Mixin that includes all the CRUD bulk mixins.
38
- module RESTFramework::Mixins::BulkModelControllerMixin
39
- def self.included(base)
40
- RESTFramework.deprecator.warn(<<~TXT).squish
41
- BulkModelControllerMixin is deprecated; use RESTFramework::Controller and set the `model` and
42
- `bulk = true` class attributes instead.
43
- TXT
44
-
45
- base.include(RESTFramework::Controller)
46
- base.model = RESTFramework::Utils.get_model(base)
47
- base.bulk = true
48
- end
49
- end
50
-
51
- # Aliases for convenience.
52
- RESTFramework::BulkCreateModelMixin = RESTFramework::Mixins::BulkCreateModelMixin
53
- RESTFramework::BulkUpdateModelMixin = RESTFramework::Mixins::BulkUpdateModelMixin
54
- RESTFramework::BulkDestroyModelMixin = RESTFramework::Mixins::BulkDestroyModelMixin
55
- RESTFramework::BulkModelControllerMixin = RESTFramework::Mixins::BulkModelControllerMixin
@@ -1,110 +0,0 @@
1
- module RESTFramework::Mixins::BaseModelControllerMixin
2
- def self.included(base)
3
- RESTFramework.deprecator.warn(<<~TXT).squish
4
- BaseModelControllerMixin is deprecated; use RESTFramework::Controller and set the `model` and
5
- `excluded_actions` class attributes instead.
6
- TXT
7
-
8
- base.include(RESTFramework::Controller)
9
- base.model = RESTFramework::Utils.get_model(base)
10
- base.excluded_actions = [
11
- :index, :show, :create, :update, :destroy, :update_all, :destroy_all
12
- ].freeze
13
- end
14
- end
15
-
16
- module RESTFramework::Mixins::ListModelMixin
17
- def self.included(base)
18
- RESTFramework.deprecator.warn(
19
- "ListModelMixin is deprecated; set the `excluded_actions` class attribute instead.",
20
- )
21
-
22
- if base.excluded_actions
23
- base.excluded_actions = (base.excluded_actions - [ :index ]).freeze
24
- end
25
- end
26
- end
27
-
28
- module RESTFramework::Mixins::ShowModelMixin
29
- def self.included(base)
30
- RESTFramework.deprecator.warn(
31
- "ShowModelMixin is deprecated; set the `excluded_actions` class attribute instead.",
32
- )
33
-
34
- if base.excluded_actions
35
- base.excluded_actions = (base.excluded_actions - [ :show ]).freeze
36
- end
37
- end
38
- end
39
-
40
- module RESTFramework::Mixins::CreateModelMixin
41
- def self.included(base)
42
- RESTFramework.deprecator.warn(
43
- "CreateModelMixin is deprecated; set the `excluded_actions` class attribute instead.",
44
- )
45
-
46
- if base.excluded_actions
47
- base.excluded_actions = (base.excluded_actions - [ :create ]).freeze
48
- end
49
- end
50
- end
51
-
52
- module RESTFramework::Mixins::UpdateModelMixin
53
- def self.included(base)
54
- RESTFramework.deprecator.warn(
55
- "UpdateModelMixin is deprecated; set the `excluded_actions` class attribute instead.",
56
- )
57
-
58
- if base.excluded_actions
59
- base.excluded_actions = (base.excluded_actions - [ :update ]).freeze
60
- end
61
- end
62
- end
63
-
64
- module RESTFramework::Mixins::DestroyModelMixin
65
- def self.included(base)
66
- RESTFramework.deprecator.warn(
67
- "DestroyModelMixin is deprecated; set the `excluded_actions` class attribute instead.",
68
- )
69
-
70
- if base.excluded_actions
71
- base.excluded_actions = (base.excluded_actions - [ :destroy ]).freeze
72
- end
73
- end
74
- end
75
-
76
- module RESTFramework::Mixins::ReadOnlyModelControllerMixin
77
- def self.included(base)
78
- RESTFramework.deprecator.warn(<<~TXT).squish
79
- ReadOnlyModelControllerMixin is deprecated; use RESTFramework::Controller and set the `model`
80
- and `excluded_actions` class attributes instead.
81
- TXT
82
-
83
- base.include(RESTFramework::Controller)
84
- base.model = RESTFramework::Utils.get_model(base)
85
- base.excluded_actions = [ :create, :update, :destroy, :update_all, :destroy_all ].freeze
86
- end
87
- end
88
-
89
- module RESTFramework::Mixins::ModelControllerMixin
90
- def self.included(base)
91
- RESTFramework.deprecator.warn(<<~TXT).squish
92
- ModelControllerMixin is deprecated; use RESTFramework::Controller and set the `model` class
93
- attribute instead.
94
- TXT
95
-
96
- base.include(RESTFramework::Controller)
97
- base.model = RESTFramework::Utils.get_model(base)
98
- base.excluded_actions = nil
99
- end
100
- end
101
-
102
- # Aliases for convenience.
103
- RESTFramework::BaseModelControllerMixin = RESTFramework::Mixins::BaseModelControllerMixin
104
- RESTFramework::ListModelMixin = RESTFramework::Mixins::ListModelMixin
105
- RESTFramework::ShowModelMixin = RESTFramework::Mixins::ShowModelMixin
106
- RESTFramework::CreateModelMixin = RESTFramework::Mixins::CreateModelMixin
107
- RESTFramework::UpdateModelMixin = RESTFramework::Mixins::UpdateModelMixin
108
- RESTFramework::DestroyModelMixin = RESTFramework::Mixins::DestroyModelMixin
109
- RESTFramework::ReadOnlyModelControllerMixin = RESTFramework::Mixins::ReadOnlyModelControllerMixin
110
- RESTFramework::ModelControllerMixin = RESTFramework::Mixins::ModelControllerMixin
@@ -1,7 +0,0 @@
1
- module RESTFramework::Mixins
2
- end
3
-
4
- require_relative "mixins/base_controller_mixin"
5
-
6
- require_relative "mixins/bulk_model_controller_mixin"
7
- require_relative "mixins/model_controller_mixin"