simple_command_dispatcher 3.0.4 → 4.0.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 +4 -4
- data/.github/workflows/ruby.yml +47 -25
- data/.gitignore +3 -0
- data/.rubocop.yml +36 -41
- data/.ruby-version +1 -1
- data/CHANGELOG.md +148 -59
- data/Gemfile +3 -6
- data/Gemfile.lock +76 -69
- data/Jenkinsfile +2 -2
- data/README.md +371 -217
- data/Rakefile +0 -8
- data/lib/core_ext/kernel.rb +22 -0
- data/lib/simple_command_dispatcher/configuration.rb +37 -35
- data/lib/simple_command_dispatcher/errors/invalid_class_constant_error.rb +16 -0
- data/lib/simple_command_dispatcher/errors/required_class_method_missing_error.rb +15 -0
- data/lib/simple_command_dispatcher/errors.rb +4 -0
- data/lib/simple_command_dispatcher/helpers/camelize.rb +46 -0
- data/lib/simple_command_dispatcher/helpers/trim_all.rb +16 -0
- data/lib/simple_command_dispatcher/services/command_namespace_service.rb +60 -0
- data/lib/simple_command_dispatcher/services/command_service.rb +152 -0
- data/lib/simple_command_dispatcher/version.rb +2 -4
- data/lib/simple_command_dispatcher.rb +69 -121
- data/simple_command_dispatcher.gemspec +3 -3
- metadata +12 -31
- data/lib/core_extensions/string.rb +0 -10
- data/lib/simple_command_dispatcher/configure.rb +0 -22
- data/lib/simple_command_dispatcher/klass_transform.rb +0 -251
- data/lib/tasks/simple_command_dispatcher_sandbox.rake +0 -222
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0144dd27d6c3f36427f08f5c44d12960a2a3d3807b08cad71ea1599ea13e8c32
|
4
|
+
data.tar.gz: 7c8505c9dda676c57695c1860972b5bbe3ad693b14e3c69e0468fda3292b7a62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afaa936a89c964a9463652cdfc46c50e0c040ce6f57cf2c4b30ffe08f500ebc00ebf7947162c65894301e008776d8c10508353a684e1d6dc060c3dfdc4ef15ed
|
7
|
+
data.tar.gz: d9497737a1f54a2b43d2dbd54809c8af707da645ba7ef2aace3dc9706a31db051bbe002df484a79525d940c97be3a00bc609f6879434205ef46bf7763b74874c
|
data/.github/workflows/ruby.yml
CHANGED
@@ -1,40 +1,62 @@
|
|
1
|
-
# This workflow uses actions that are not certified by GitHub.
|
2
|
-
# They are provided by a third-party and are governed by
|
3
|
-
# separate terms of service, privacy policy, and support
|
4
|
-
# documentation.
|
5
|
-
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake.
|
6
|
-
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
-
|
8
1
|
name: Ruby
|
9
2
|
|
10
3
|
on:
|
11
4
|
push:
|
12
|
-
branches: [
|
5
|
+
branches: ["main"]
|
13
6
|
pull_request:
|
14
|
-
branches: [
|
7
|
+
branches: ["main"]
|
15
8
|
|
16
9
|
permissions:
|
17
10
|
contents: read
|
18
11
|
|
19
12
|
jobs:
|
20
13
|
test:
|
21
|
-
|
22
|
-
runs-on: ubuntu-latest
|
14
|
+
runs-on: ${{ matrix.os }}
|
23
15
|
strategy:
|
24
16
|
matrix:
|
25
|
-
#
|
26
|
-
|
27
|
-
|
17
|
+
# See https://github.com/actions/runner-images
|
18
|
+
os:
|
19
|
+
[
|
20
|
+
ubuntu-22.04,
|
21
|
+
ubuntu-latest,
|
22
|
+
macos-13,
|
23
|
+
macos-14,
|
24
|
+
macos-15,
|
25
|
+
windows-2022,
|
26
|
+
windows-latest,
|
27
|
+
]
|
28
|
+
# Use `rbenv install --list` to determine what stable ruby versions to test against.
|
29
|
+
ruby: ["3.3", "3.4"]
|
28
30
|
|
29
31
|
steps:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
32
|
+
- uses: actions/checkout@v3
|
33
|
+
|
34
|
+
- name: Set timezone on Linux
|
35
|
+
if: contains(matrix.os, 'ubuntu')
|
36
|
+
run: sudo timedatectl set-timezone 'America/New_York'
|
37
|
+
|
38
|
+
- name: Set timezone on macOS
|
39
|
+
if: contains(matrix.os, 'macos')
|
40
|
+
run: sudo systemsetup -settimezone America/New_York
|
41
|
+
|
42
|
+
- name: Set timezone on Windows
|
43
|
+
if: contains(matrix.os, 'windows')
|
44
|
+
run: tzutil /s "Eastern Standard Time"
|
45
|
+
|
46
|
+
- name: Set up Ruby
|
47
|
+
uses: ruby/setup-ruby@v1
|
48
|
+
with:
|
49
|
+
ruby-version: ${{ matrix.ruby }}
|
50
|
+
bundler-cache: true
|
51
|
+
|
52
|
+
- name: Update RubyGems
|
53
|
+
run: gem update --system
|
54
|
+
|
55
|
+
- name: Disable bundler frozen setting
|
56
|
+
run: bundle config set frozen false
|
57
|
+
|
58
|
+
- name: Install dependencies
|
59
|
+
run: bundle install
|
60
|
+
|
61
|
+
- name: Run tests
|
62
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,31 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# directory or in some project directory.
|
6
|
-
#
|
7
|
-
# RuboCop will start looking for the configuration file in the directory
|
8
|
-
# where the inspected file is and continue its way up to the root directory.
|
9
|
-
#
|
10
|
-
# See https://docs.rubocop.org/rubocop/configuration
|
11
|
-
require:
|
12
|
-
# - rubocop-performance
|
13
|
-
# - rubocop-rspec
|
1
|
+
plugins:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rspec
|
4
|
+
- rubocop-rake
|
14
5
|
|
15
6
|
AllCops:
|
16
|
-
|
17
|
-
TargetRubyVersion: 3.0.1
|
7
|
+
TargetRubyVersion: 3.4
|
18
8
|
NewCops: enable
|
19
9
|
Exclude:
|
20
|
-
-
|
21
|
-
-
|
22
|
-
-
|
23
|
-
-
|
24
|
-
-
|
25
|
-
-
|
26
|
-
-
|
27
|
-
-
|
28
|
-
-
|
10
|
+
- "*.gemspec"
|
11
|
+
- ".git/**/*"
|
12
|
+
- ".idea/**/*"
|
13
|
+
- "Rakefile"
|
14
|
+
- "init/*"
|
15
|
+
# - "lib/tasks/*"
|
16
|
+
- "scratch*.rb"
|
17
|
+
- "snippets*.rb"
|
18
|
+
- "vendor/**/*"
|
19
|
+
- "spec/**/*"
|
29
20
|
|
30
21
|
# Align the elements of a hash literal if they span more than one line.
|
31
22
|
Layout/HashAlignment:
|
@@ -90,7 +81,7 @@ Layout/MultilineMethodCallIndentation:
|
|
90
81
|
# Allow `debug` in tasks for now
|
91
82
|
Lint/Debugger:
|
92
83
|
Exclude:
|
93
|
-
-
|
84
|
+
- "RakeFile"
|
94
85
|
|
95
86
|
# A calculated magnitude based on number of assignments, branches, and
|
96
87
|
# conditions.
|
@@ -102,9 +93,9 @@ Metrics/AbcSize:
|
|
102
93
|
# Avoid long blocks with many lines.
|
103
94
|
Metrics/BlockLength:
|
104
95
|
Exclude:
|
105
|
-
-
|
106
|
-
-
|
107
|
-
-
|
96
|
+
- "RakeFile"
|
97
|
+
- "db/seeds.rb"
|
98
|
+
- "spec/**/*.rb"
|
108
99
|
|
109
100
|
# Avoid classes longer than 100 lines of code.
|
110
101
|
# NOTE: This is temporarily disabled until we can eliminate existing Rubocop
|
@@ -112,7 +103,7 @@ Metrics/BlockLength:
|
|
112
103
|
Metrics/ClassLength:
|
113
104
|
Max: 200
|
114
105
|
Exclude:
|
115
|
-
-
|
106
|
+
- "spec/**/*.rb"
|
116
107
|
|
117
108
|
# A complexity metric that is strongly correlated to the number of test cases
|
118
109
|
# needed to validate a method.
|
@@ -122,26 +113,20 @@ Metrics/CyclomaticComplexity:
|
|
122
113
|
# Limit lines to 80 characters
|
123
114
|
Layout/LineLength:
|
124
115
|
Exclude:
|
125
|
-
-
|
126
|
-
-
|
116
|
+
- "RakeFile"
|
117
|
+
- "spec/**/*.rb"
|
127
118
|
|
128
119
|
# Avoid methods longer than 15 lines of code.
|
129
120
|
Metrics/MethodLength:
|
130
121
|
Max: 20
|
131
|
-
|
122
|
+
AllowedMethods:
|
123
|
+
- swagger_path
|
124
|
+
- operation
|
132
125
|
|
133
126
|
# A complexity metric geared towards measuring complexity for a human reader.
|
134
127
|
Metrics/PerceivedComplexity:
|
135
128
|
Max: 10
|
136
129
|
|
137
|
-
# Naming/FileName:
|
138
|
-
# Exclude:
|
139
|
-
# - 'lib/file.rb'
|
140
|
-
|
141
|
-
# Allow `downcase == ` instead of forcing `casecmp`
|
142
|
-
#Performance/Casecmp:
|
143
|
-
# Enabled: false
|
144
|
-
|
145
130
|
# Require children definitions to be nested or compact in classes and modules
|
146
131
|
Style/ClassAndModuleChildren:
|
147
132
|
Enabled: false
|
@@ -166,7 +151,7 @@ Style/GuardClause:
|
|
166
151
|
|
167
152
|
Style/MixinUsage:
|
168
153
|
Exclude:
|
169
|
-
-
|
154
|
+
- "RakeFile"
|
170
155
|
|
171
156
|
# Avoid multi-line method signatures.
|
172
157
|
Style/MultilineMethodSignature:
|
@@ -195,3 +180,13 @@ Style/StringMethods:
|
|
195
180
|
# Checks for use of parentheses around ternary conditions.
|
196
181
|
Style/TernaryParentheses:
|
197
182
|
EnforcedStyle: require_parentheses_when_complex
|
183
|
+
|
184
|
+
# RSpec cops configuration
|
185
|
+
RSpec/MultipleExpectations:
|
186
|
+
Enabled: false
|
187
|
+
|
188
|
+
RSpec/MultipleMemoizedHelpers:
|
189
|
+
Max: 6
|
190
|
+
|
191
|
+
RSpec/NestedGroups:
|
192
|
+
Max: 4
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.4.1
|
data/CHANGELOG.md
CHANGED
@@ -1,59 +1,148 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
## Version
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
## Version 0.
|
58
|
-
|
59
|
-
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## Version 4.0.0 - 2025-07-12
|
4
|
+
|
5
|
+
- **Documentation Overhaul**:
|
6
|
+
|
7
|
+
- Completely rewrote README.md with modern examples and comprehensive Rails integration guides
|
8
|
+
- Fixed documentation accuracy issues across all modules and classes
|
9
|
+
- Corrected method signatures and parameter types in YARD documentation
|
10
|
+
- Updated all examples to use keyword arguments and match current implementation
|
11
|
+
- Added comprehensive documentation for helper methods and error classes
|
12
|
+
- Added migration guide from v3.x to v4.x with breaking change explanations
|
13
|
+
- Included advanced usage patterns (route-based dispatch, batch execution, dynamic versioning)
|
14
|
+
|
15
|
+
- **Test Coverage Enhancements**:
|
16
|
+
|
17
|
+
- Added comprehensive test suite for `CommandNamespaceService` (previously untested)
|
18
|
+
- Replaced placeholder tests with full implementations for `Camelize` and `TrimAll` helpers
|
19
|
+
- Added thorough test coverage for `Kernel#eigenclass` extension
|
20
|
+
- Created direct unit tests for custom error classes with edge case testing
|
21
|
+
- Improved overall test coverage with real-world scenarios and Unicode support
|
22
|
+
- Added extensive edge case testing for input validation and error conditions
|
23
|
+
|
24
|
+
- **Helper Method Improvements**:
|
25
|
+
|
26
|
+
- Enhanced `Camelize` helper to better handle RESTful route conversion to Ruby constants
|
27
|
+
- Improved `TrimAll` helper with Unicode whitespace support using `\p{Space}` regex
|
28
|
+
- Added robust error handling and edge case management for various input types
|
29
|
+
- Optimized performance for route-to-constant transformations using Rails' proven methods
|
30
|
+
- Better handling of mixed separators (hyphens, dots, spaces, colons)
|
31
|
+
|
32
|
+
- **Code Quality & Tooling**:
|
33
|
+
|
34
|
+
- Fixed RuboCop configuration errors (typo in `plugins`, removed deprecated `RSpec/NotToNot`)
|
35
|
+
- Added proper `RSpec/NestedGroups` configuration
|
36
|
+
- All RuboCop checks now pass with zero offenses
|
37
|
+
- Improved code organization and consistency
|
38
|
+
|
39
|
+
- **Breaking Changes**:
|
40
|
+
- Minimum ruby version changed from 3.0.1 to 3.3
|
41
|
+
- Removed dependency on `simple_command` gem for lighter footprint
|
42
|
+
- Removed `allow_custom_commands` configuration option (all commands are now "custom")
|
43
|
+
- `SimpleCommandDispatcher.call` method signature changed to accept keyword arguments: `command:`, `command_namespace:`, and `request_params:`
|
44
|
+
- Changed gem namespace from `SimpleCommand::Dispatcher` to `SimpleCommandDispatcher`
|
45
|
+
- Removed `options:` parameter and all camelization options (camelization is now automatic)
|
46
|
+
- Fixed duplicate `Errors` namespacing on error classes under `SimpleCommandDispatcher::Errors`
|
47
|
+
|
48
|
+
## Version 3.0.3 - 2024-08-03
|
49
|
+
|
50
|
+
- Update Ruby gems.
|
51
|
+
- Patch CVE related to `rexml` gem.
|
52
|
+
|
53
|
+
## Version 3.0.3 - 2024-02-18
|
54
|
+
|
55
|
+
- Update Ruby gems.
|
56
|
+
|
57
|
+
## Version 3.0.2 - 2024-01-31
|
58
|
+
|
59
|
+
- Update Ruby gems.
|
60
|
+
|
61
|
+
## Version 3.0.1 - 2024-01-07
|
62
|
+
|
63
|
+
- Relax Ruby version requirement to `>= 3.0.1`, `< 4.0`.
|
64
|
+
- Update Ruby gems.
|
65
|
+
|
66
|
+
## Version 3.0.0 - 2023-12-27
|
67
|
+
|
68
|
+
- Now requires Ruby `>= 3.0`.
|
69
|
+
- Now requires `simple_command` `~> 1.0`, `>= 1.0.1`.
|
70
|
+
- Note: Attempting to remove this dependency for users not using `simple_command`.
|
71
|
+
- Update Ruby gems.
|
72
|
+
|
73
|
+
## Version 2.0.1 - 2023-12-02
|
74
|
+
|
75
|
+
- Update Ruby gems.
|
76
|
+
|
77
|
+
## Version 2.0.0 - 2023-11-01
|
78
|
+
|
79
|
+
- `simple_command_dispatcher` now depends on Ruby `>= 2.7.0`.
|
80
|
+
- Update Ruby gems.
|
81
|
+
|
82
|
+
## Version 1.2.8 - 2023-08-30
|
83
|
+
|
84
|
+
- Update Ruby gems.
|
85
|
+
|
86
|
+
## Version 1.2.7
|
87
|
+
|
88
|
+
- Update Ruby gems.
|
89
|
+
- Miscellaneous refactors.
|
90
|
+
|
91
|
+
## Version 1.2.6
|
92
|
+
|
93
|
+
- Update Ruby gems to patch CVE.
|
94
|
+
|
95
|
+
## Version 1.2.5
|
96
|
+
|
97
|
+
- Check in `Gemfile.lock`.
|
98
|
+
|
99
|
+
## Version 1.2.4
|
100
|
+
|
101
|
+
- Now requires Ruby `2.6.3`.
|
102
|
+
- Fix broken spec.
|
103
|
+
- Update Ruby gems.
|
104
|
+
- Patch CVEs:
|
105
|
+
- `activesupport` (CVE-2020-8165)
|
106
|
+
- `rake` (CVE-2020-8130)
|
107
|
+
- `rdoc` (CVE-2021-31799)
|
108
|
+
- `tzinfo` (CVE-2022-31163)
|
109
|
+
- `yard` (CVE-2017-17042, CVE-2019-1020001).
|
110
|
+
- Fix RuboCop violations.
|
111
|
+
|
112
|
+
## Version 1.2.3
|
113
|
+
|
114
|
+
- Refactor `requires` in `configure.rb` and `simple_command_dispatcher.rb`.
|
115
|
+
- Update gemspec summary and description.
|
116
|
+
|
117
|
+
## Version 1.2.2
|
118
|
+
|
119
|
+
- **Bug Fix**:
|
120
|
+
- Fixed `NoMethodError` in `configure` method when trying to include configuration block in `/config/initializers/simple_command_dispatcher.rb`.
|
121
|
+
|
122
|
+
## Version 1.2.1
|
123
|
+
|
124
|
+
- **Configuration Class**:
|
125
|
+
- Added the new `Configuration` class exposing the `#allow_custom_classes` property.
|
126
|
+
- Allows/disallows the use of custom commands. See documentation for details and usage.
|
127
|
+
- **Custom Commands**:
|
128
|
+
- Allow users to use custom commands (i.e., classes that do not prepend the `SimpleCommand` module).
|
129
|
+
- Commands must respond to the `::call` public class method.
|
130
|
+
- Note: `Configuration#allow_custom_commands` must be set to `true` to use custom commands.
|
131
|
+
- **Documentation Updates**:
|
132
|
+
- Added documentation for the new `Configuration` class and miscellaneous other code additions/changes.
|
133
|
+
|
134
|
+
## Version 1.1.1
|
135
|
+
|
136
|
+
- **Documentation Updates**:
|
137
|
+
- Added example code in `README.md` to clarify command namespacing and how to autoload command classes.
|
138
|
+
- Helps avoid `NameError` exceptions when `SimpleCommandDispatcher.call(...)` is invoked due to uninitialized command constants.
|
139
|
+
|
140
|
+
## [YANKED VERSIONS]
|
141
|
+
|
142
|
+
- **Version 1.1.0** - 2016-11-01
|
143
|
+
- **Version 1.0.0** - 2016-11-01
|
144
|
+
- **Version 0.2.0** - 2016-11-01
|
145
|
+
- **Version 0.1.3** - 2016-11-01
|
146
|
+
- **Version 0.1.2** - 2016-10-29
|
147
|
+
- **Version 0.1.1** - 2016-10-29
|
148
|
+
- **Version 0.1.0** - 2016-10-29
|
data/Gemfile
CHANGED
@@ -11,16 +11,13 @@ gem 'rake', '>= 13.0', '< 14.0'
|
|
11
11
|
|
12
12
|
group :development do
|
13
13
|
gem 'pry-byebug', '>= 3.9', '< 4.0'
|
14
|
-
gem 'rdoc', '>= 6.4', '< 7.0'
|
15
14
|
gem 'rubocop', '>= 1.62', '< 2.0'
|
16
15
|
gem 'rubocop-performance', '>= 1.20', '< 2.0'
|
17
|
-
gem 'rubocop-
|
16
|
+
gem 'rubocop-rake', '>= 0.6', '< 1.0'
|
17
|
+
gem 'rubocop-rspec', '~> 3.0', '>= 3.0.3'
|
18
18
|
end
|
19
19
|
|
20
20
|
group :test do
|
21
21
|
gem 'rspec', '>= 3.10', '< 4.0'
|
22
|
-
|
23
|
-
|
24
|
-
group :documentation do
|
25
|
-
gem 'yard', '>= 0.9.28', '< 1.0'
|
22
|
+
gem 'simplecov', '>= 0.22.0', '< 1.0'
|
26
23
|
end
|