simple_command_dispatcher 1.2.2 → 1.2.5
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 +5 -5
- data/.gitignore +12 -1
- data/.reek.yml +19 -0
- data/.rspec +1 -0
- data/.rubocop.yml +199 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +14 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +99 -0
- data/Jenkinsfile +20 -0
- data/README.md +2 -2
- data/Rakefile +6 -5
- data/bin/console +4 -3
- data/lib/core_extensions/string.rb +9 -7
- data/lib/simple_command_dispatcher/configuration.rb +38 -39
- data/lib/simple_command_dispatcher/configure.rb +18 -14
- data/lib/simple_command_dispatcher/klass_transform.rb +221 -230
- data/lib/simple_command_dispatcher/version.rb +5 -3
- data/lib/simple_command_dispatcher.rb +100 -109
- data/lib/tasks/simple_command_dispatcher_sandbox.rake +168 -178
- data/simple_command_dispatcher.gemspec +30 -26
- metadata +109 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 95c093ccfa0a342868fddd8b78ca422b248e916dabfe9ed0c31118958ace096b
|
4
|
+
data.tar.gz: 132b1063e35a327e1c4103646a0d3381bcce74893c95aac1cd831bbac454878f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5c7fd6af29ce88e18b704eba5fd7928b74d292c703360213dfd32195cac3d36fc6badaafe54bb3eff436d336e493897df4cba6db646ad51aae80e8e3118d0f7
|
7
|
+
data.tar.gz: 754821039179acb50169b44856fbc8973c69c7a6c7977552a6de325eea91f55f51a192ee319044a8f9438d3984dba87535d546d3775dec8c762018a39d212bba
|
data/.gitignore
CHANGED
data/.reek.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
exclude_paths:
|
2
|
+
- vendor
|
3
|
+
- spec
|
4
|
+
- lib/tasks
|
5
|
+
detectors:
|
6
|
+
# TooManyInstanceVariables:
|
7
|
+
# exclude:
|
8
|
+
# - "Class1"
|
9
|
+
# - "Class2"
|
10
|
+
# private methods do not have to depend on instance state
|
11
|
+
# https://github.com/troessner/reek/blob/master/docs/Utility-Function.md
|
12
|
+
UtilityFunction:
|
13
|
+
public_methods_only: true
|
14
|
+
# Check for variable name that doesn't communicate its intent well enough
|
15
|
+
# https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md
|
16
|
+
UncommunicativeVariableName:
|
17
|
+
accept:
|
18
|
+
- /^_$/
|
19
|
+
- /^e$/
|
data/.rspec
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
# The behavior of RuboCop can be controlled via the .rubocop.yml
|
2
|
+
# configuration file. It makes it possible to enable/disable
|
3
|
+
# certain cops (checks) and to alter their behavior if they accept
|
4
|
+
# any parameters. The file can be placed either in your home
|
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
|
14
|
+
|
15
|
+
AllCops:
|
16
|
+
TargetRubyVersion: 2.6.3
|
17
|
+
NewCops: enable
|
18
|
+
Exclude:
|
19
|
+
- '.git/**/*'
|
20
|
+
- '.idea/**/*'
|
21
|
+
- 'init/*'
|
22
|
+
- 'Rakefile'
|
23
|
+
- '*.gemspec'
|
24
|
+
- 'spec/**/*'
|
25
|
+
- 'vendor/**/*'
|
26
|
+
- 'lib/tasks/**/*'
|
27
|
+
- 'scratch.rb'
|
28
|
+
|
29
|
+
# Align the elements of a hash literal if they span more than one line.
|
30
|
+
Layout/HashAlignment:
|
31
|
+
EnforcedLastArgumentHashStyle: always_ignore
|
32
|
+
|
33
|
+
# Alignment of parameters in multi-line method definition.
|
34
|
+
# The `with_fixed_indentation` style aligns the following lines with one
|
35
|
+
# level of indentation relative to the start of the line with the method
|
36
|
+
# definition.
|
37
|
+
#
|
38
|
+
# def my_method(a,
|
39
|
+
# b)
|
40
|
+
Layout/ParameterAlignment:
|
41
|
+
EnforcedStyle: with_fixed_indentation
|
42
|
+
|
43
|
+
# Alignment of parameters in multi-line method call.
|
44
|
+
# The `with_fixed_indentation` style aligns the following lines with one
|
45
|
+
# level of indentation relative to the start of the line with the method call.
|
46
|
+
#
|
47
|
+
# my_method(a,
|
48
|
+
# b)
|
49
|
+
Layout/ArgumentAlignment:
|
50
|
+
EnforcedStyle: with_fixed_indentation
|
51
|
+
|
52
|
+
# a = case n
|
53
|
+
# when 0
|
54
|
+
# x * 2
|
55
|
+
# else
|
56
|
+
# y / 3
|
57
|
+
# end
|
58
|
+
Layout/CaseIndentation:
|
59
|
+
EnforcedStyle: end
|
60
|
+
|
61
|
+
# Enforces a configured order of definitions within a class body
|
62
|
+
Layout/ClassStructure:
|
63
|
+
Enabled: true
|
64
|
+
|
65
|
+
# Align `end` with the matching keyword or starting expression except for
|
66
|
+
# assignments, where it should be aligned with the LHS.
|
67
|
+
Layout/EndAlignment:
|
68
|
+
EnforcedStyleAlignWith: variable
|
69
|
+
AutoCorrect: true
|
70
|
+
|
71
|
+
# The `consistent` style enforces that the first element in an array
|
72
|
+
# literal where the opening bracket and the first element are on
|
73
|
+
# seprate lines is indented the same as an array literal which is not
|
74
|
+
# defined inside a method call.
|
75
|
+
Layout/FirstArrayElementIndentation:
|
76
|
+
EnforcedStyle: consistent
|
77
|
+
|
78
|
+
# The `consistent` style enforces that the first key in a hash
|
79
|
+
# literal where the opening brace and the first key are on
|
80
|
+
# seprate lines is indented the same as a hash literal which is not
|
81
|
+
# defined inside a method call.
|
82
|
+
Layout/FirstHashElementIndentation:
|
83
|
+
EnforcedStyle: consistent
|
84
|
+
|
85
|
+
# Indent multi-line methods instead of aligning with periods
|
86
|
+
Layout/MultilineMethodCallIndentation:
|
87
|
+
EnforcedStyle: indented
|
88
|
+
|
89
|
+
# Allow `debug` in tasks for now
|
90
|
+
Lint/Debugger:
|
91
|
+
Exclude:
|
92
|
+
- 'RakeFile'
|
93
|
+
|
94
|
+
# A calculated magnitude based on number of assignments, branches, and
|
95
|
+
# conditions.
|
96
|
+
# NOTE: This is temporarily disabled until we can eliminate existing Rubocop
|
97
|
+
# complaints
|
98
|
+
Metrics/AbcSize:
|
99
|
+
Enabled: false
|
100
|
+
|
101
|
+
# Avoid long blocks with many lines.
|
102
|
+
Metrics/BlockLength:
|
103
|
+
Exclude:
|
104
|
+
- 'RakeFile'
|
105
|
+
- 'db/seeds.rb'
|
106
|
+
- 'spec/**/*.rb'
|
107
|
+
|
108
|
+
# Avoid classes longer than 100 lines of code.
|
109
|
+
# NOTE: This is temporarily disabled until we can eliminate existing Rubocop
|
110
|
+
# complaints
|
111
|
+
Metrics/ClassLength:
|
112
|
+
Max: 200
|
113
|
+
Exclude:
|
114
|
+
- 'spec/**/*.rb'
|
115
|
+
|
116
|
+
# A complexity metric that is strongly correlated to the number of test cases
|
117
|
+
# needed to validate a method.
|
118
|
+
Metrics/CyclomaticComplexity:
|
119
|
+
Max: 9
|
120
|
+
|
121
|
+
# Limit lines to 80 characters
|
122
|
+
Layout/LineLength:
|
123
|
+
Exclude:
|
124
|
+
- 'RakeFile'
|
125
|
+
- 'spec/**/*.rb'
|
126
|
+
|
127
|
+
# Avoid methods longer than 15 lines of code.
|
128
|
+
Metrics/MethodLength:
|
129
|
+
Max: 20
|
130
|
+
IgnoredMethods:
|
131
|
+
- swagger_path
|
132
|
+
- operation
|
133
|
+
|
134
|
+
|
135
|
+
# A complexity metric geared towards measuring complexity for a human reader.
|
136
|
+
Metrics/PerceivedComplexity:
|
137
|
+
Max: 10
|
138
|
+
|
139
|
+
# Naming/FileName:
|
140
|
+
# Exclude:
|
141
|
+
# - 'lib/file.rb'
|
142
|
+
|
143
|
+
# Allow `downcase == ` instead of forcing `casecmp`
|
144
|
+
Performance/Casecmp:
|
145
|
+
Enabled: false
|
146
|
+
|
147
|
+
# Require children definitions to be nested or compact in classes and modules
|
148
|
+
Style/ClassAndModuleChildren:
|
149
|
+
Enabled: false
|
150
|
+
|
151
|
+
# Document classes and non-namespace modules.
|
152
|
+
# (Disabled for now, may revisit later)
|
153
|
+
Style/Documentation:
|
154
|
+
Enabled: false
|
155
|
+
|
156
|
+
# Checks the formatting of empty method definitions.
|
157
|
+
Style/EmptyMethod:
|
158
|
+
EnforcedStyle: expanded
|
159
|
+
|
160
|
+
# Add the frozen_string_literal comment to the top of files to help transition
|
161
|
+
# to frozen string literals by default.
|
162
|
+
Style/FrozenStringLiteralComment:
|
163
|
+
EnforcedStyle: always
|
164
|
+
|
165
|
+
# Check for conditionals that can be replaced with guard clauses
|
166
|
+
Style/GuardClause:
|
167
|
+
Enabled: false
|
168
|
+
|
169
|
+
Style/MixinUsage:
|
170
|
+
Exclude:
|
171
|
+
- 'RakeFile'
|
172
|
+
|
173
|
+
# Avoid multi-line method signatures.
|
174
|
+
Style/MultilineMethodSignature:
|
175
|
+
Enabled: true
|
176
|
+
|
177
|
+
# Don't use option hashes when you can use keyword arguments.
|
178
|
+
Style/OptionHash:
|
179
|
+
Enabled: true
|
180
|
+
|
181
|
+
# Use return instead of return nil.
|
182
|
+
Style/ReturnNil:
|
183
|
+
Enabled: true
|
184
|
+
|
185
|
+
# Allow code like `return x, y` as it's occasionally handy.
|
186
|
+
Style/RedundantReturn:
|
187
|
+
AllowMultipleReturnValues: true
|
188
|
+
|
189
|
+
# Prefer symbols instead of strings as hash keys.
|
190
|
+
Style/StringHashKeys:
|
191
|
+
Enabled: true
|
192
|
+
|
193
|
+
# Checks if configured preferred methods are used over non-preferred.
|
194
|
+
Style/StringMethods:
|
195
|
+
Enabled: true
|
196
|
+
|
197
|
+
# Checks for use of parentheses around ternary conditions.
|
198
|
+
Style/TernaryParentheses:
|
199
|
+
EnforcedStyle: require_parentheses_when_complex
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3
|
1
|
+
2.6.3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
### Version 1.2.5
|
2
|
+
* Check in Gemfile.lock
|
3
|
+
### Version 1.2.4
|
4
|
+
* Now requires Ruby 2.6.3
|
5
|
+
* Fix broken spec.
|
6
|
+
* Update Ruby gems.
|
7
|
+
* Patch CVEs: activesupport CVE-2020-8165, rake CVE-2020-8130, rdoc CVE-2021-31799, tzinfo CVE-2022-31163, yard CVE-2017-17042 and CVE-2019-1020001.
|
8
|
+
* Fix rubocop violations.
|
9
|
+
### Version 1.2.3
|
10
|
+
* Refactor 'requires' in configure.rb and simple_command_dispatcher.rb
|
11
|
+
* Update gemspec summary and description
|
12
|
+
### Version 1.2.2
|
13
|
+
* Bug fix
|
14
|
+
* Fixed NoMethodError on 'configure' metnod when trying to include configuration block in /config/initializers/simple_command_dispatcher.rb
|
1
15
|
### Version 1.2.1
|
2
16
|
* Configuration class
|
3
17
|
* Added the new Configuration class that exposes the #allow_custom_classes property which takes a Boolean allowing/disallowing the use of custom commands to be used. See the documentation for details and usage.
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
simple_command_dispatcher (1.2.5)
|
5
|
+
activesupport (~> 5.0, >= 5.0.0.1)
|
6
|
+
simple_command (~> 0.2.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (5.2.8.1)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 0.7, < 2)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
ast (2.4.2)
|
17
|
+
byebug (11.1.3)
|
18
|
+
coderay (1.1.3)
|
19
|
+
colorize (0.8.1)
|
20
|
+
concurrent-ruby (1.1.10)
|
21
|
+
diff-lcs (1.5.0)
|
22
|
+
i18n (1.12.0)
|
23
|
+
concurrent-ruby (~> 1.0)
|
24
|
+
json (2.6.2)
|
25
|
+
method_source (1.0.0)
|
26
|
+
minitest (5.16.2)
|
27
|
+
parallel (1.22.1)
|
28
|
+
parser (3.1.2.1)
|
29
|
+
ast (~> 2.4.1)
|
30
|
+
pry (0.13.1)
|
31
|
+
coderay (~> 1.1)
|
32
|
+
method_source (~> 1.0)
|
33
|
+
pry-byebug (3.9.0)
|
34
|
+
byebug (~> 11.0)
|
35
|
+
pry (~> 0.13.0)
|
36
|
+
psych (4.0.4)
|
37
|
+
stringio
|
38
|
+
rainbow (3.1.1)
|
39
|
+
rake (13.0.6)
|
40
|
+
rdoc (6.4.0)
|
41
|
+
psych (>= 4.0.0)
|
42
|
+
regexp_parser (2.5.0)
|
43
|
+
rexml (3.2.5)
|
44
|
+
rspec (3.11.0)
|
45
|
+
rspec-core (~> 3.11.0)
|
46
|
+
rspec-expectations (~> 3.11.0)
|
47
|
+
rspec-mocks (~> 3.11.0)
|
48
|
+
rspec-core (3.11.0)
|
49
|
+
rspec-support (~> 3.11.0)
|
50
|
+
rspec-expectations (3.11.0)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.11.0)
|
53
|
+
rspec-mocks (3.11.1)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.11.0)
|
56
|
+
rspec-support (3.11.0)
|
57
|
+
rubocop (1.35.0)
|
58
|
+
json (~> 2.3)
|
59
|
+
parallel (~> 1.10)
|
60
|
+
parser (>= 3.1.2.1)
|
61
|
+
rainbow (>= 2.2.2, < 4.0)
|
62
|
+
regexp_parser (>= 1.8, < 3.0)
|
63
|
+
rexml (>= 3.2.5, < 4.0)
|
64
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
65
|
+
ruby-progressbar (~> 1.7)
|
66
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
67
|
+
rubocop-ast (1.21.0)
|
68
|
+
parser (>= 3.1.1.0)
|
69
|
+
rubocop-performance (1.14.3)
|
70
|
+
rubocop (>= 1.7.0, < 2.0)
|
71
|
+
rubocop-ast (>= 0.4.0)
|
72
|
+
ruby-progressbar (1.11.0)
|
73
|
+
simple_command (0.2.1)
|
74
|
+
stringio (3.0.2)
|
75
|
+
thread_safe (0.3.6)
|
76
|
+
tzinfo (1.2.10)
|
77
|
+
thread_safe (~> 0.1)
|
78
|
+
unicode-display_width (2.2.0)
|
79
|
+
webrick (1.7.0)
|
80
|
+
yard (0.9.28)
|
81
|
+
webrick (~> 1.7.0)
|
82
|
+
|
83
|
+
PLATFORMS
|
84
|
+
x86_64-darwin-19
|
85
|
+
|
86
|
+
DEPENDENCIES
|
87
|
+
bundler (~> 2.2, >= 2.2.17)
|
88
|
+
colorize (~> 0.8.1)
|
89
|
+
pry-byebug (~> 3.9)
|
90
|
+
rake (~> 13.0, >= 13.0.6)
|
91
|
+
rdoc (~> 6.4)
|
92
|
+
rspec (>= 3.10)
|
93
|
+
rubocop (~> 1.35)
|
94
|
+
rubocop-performance (~> 1.14, >= 1.14.3)
|
95
|
+
simple_command_dispatcher!
|
96
|
+
yard (~> 0.9.28)
|
97
|
+
|
98
|
+
BUNDLED WITH
|
99
|
+
2.3.20
|
data/Jenkinsfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
pipeline {
|
2
|
+
agent { docker { image 'ruby:2.3.1' } }
|
3
|
+
stages {
|
4
|
+
stage('requirements') {
|
5
|
+
steps {
|
6
|
+
sh 'gem install bundler -v 1.16.1'
|
7
|
+
}
|
8
|
+
}
|
9
|
+
stage('build') {
|
10
|
+
steps {
|
11
|
+
sh 'bundle install'
|
12
|
+
}
|
13
|
+
}
|
14
|
+
stage('test') {
|
15
|
+
steps {
|
16
|
+
sh 'bundle exec rspec'
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
[](https://badge.fury.io/gh/gangelo%2Fsimple_command_dispatcher)
|
2
2
|
[](https://badge.fury.io/rb/simple_command_dispatcher)
|
3
3
|
|
4
|
-
](http://www.rubydoc.info/gems/simple_command_dispatcher/)
|
5
5
|
[](http://www.rubydoc.info/gems/simple_command_dispatcher/)
|
6
6
|
|
7
7
|
[](https://github.com/gangelo/simple_command_dispatcher/issues)
|
@@ -9,7 +9,7 @@
|
|
9
9
|
[](#license)
|
10
10
|
|
11
11
|
# Q. simple_command_dispatcher - what is it?
|
12
|
-
# A. It's a Ruby gem
|
12
|
+
# A. It's a Ruby gem!!!
|
13
13
|
|
14
14
|
## Overview
|
15
15
|
__simple_command_dispatcher__ (SCD) allows you to execute __simple_command__ commands (and now _custom commands_ as of version 1.2.1) in a more dynamic way. If you are not familiar with the _simple_command_ gem, check it out [here][simple-command]. SCD was written specifically with the [rails-api][rails-api] in mind; however, you can use SDC wherever you would use simple_command commands.
|
data/Rakefile
CHANGED
@@ -1,18 +1,19 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
3
5
|
require 'yard'
|
4
6
|
|
5
7
|
# Rspec
|
6
8
|
RSpec::Core::RakeTask.new(:spec)
|
7
9
|
task default: :spec
|
8
10
|
|
9
|
-
|
10
11
|
# Yard
|
11
12
|
YARD::Rake::YardocTask.new do |t|
|
12
|
-
t.files = ['lib/**/*.rb']
|
13
|
+
t.files = ['lib/**/*.rb']
|
13
14
|
t.options = ['--no-cache', '--protected', '--private']
|
14
15
|
t.stats_options = ['--list-undoc']
|
15
16
|
end
|
16
17
|
|
17
18
|
# Load our custom rake tasks.
|
18
|
-
Gem.find_files(
|
19
|
+
Gem.find_files('tasks/**/*.rake').each { |path| import path }
|
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'simple_command_dispatcher'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "simple_command_dispatcher"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class String
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
4
|
+
# Returns a copy of string with all spaces removed.
|
5
|
+
#
|
6
|
+
# @return [String] with all spaces trimmed which includes all leading, trailing and embedded spaces.
|
7
|
+
def trim_all
|
8
|
+
gsub(/\s+/, '')
|
9
|
+
end
|
10
|
+
end
|
@@ -1,45 +1,44 @@
|
|
1
|
-
|
2
|
-
module Dispatcher
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module SimpleCommand
|
4
|
+
module Dispatcher
|
5
|
+
# Gem configuration settings class. Use this class to configure this gem.
|
6
|
+
#
|
7
|
+
# To configure this gem in your application, simply add the following code in your application and set the
|
8
|
+
# appropriate configuration settings.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
#
|
12
|
+
# SimpleCommand::Dispatcher.configure do |config|
|
13
|
+
# config.allow_custom_commands = true
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
class Configuration
|
17
|
+
# Gets/sets the *allow_custom_commands* configuration setting (defaults to false).
|
18
|
+
# If this setting is set to *false*, only command classes that prepend the *SimpleCommand* module
|
19
|
+
# will be considered acceptable to run, all other command classes will fail to run. If this
|
20
|
+
# setting is set to *true*, any command class will be considered acceptable to run, regardless of
|
21
|
+
# whether or not the class prepends the *SimpleCommand* module.
|
8
22
|
#
|
9
|
-
#
|
23
|
+
# For information about the simple_command gem, visit {https://rubygems.org/gems/simple_command}
|
10
24
|
#
|
11
|
-
#
|
12
|
-
# config.allow_custom_commands = true
|
13
|
-
# end
|
25
|
+
# @return [Boolean] the value.
|
14
26
|
#
|
15
|
-
|
16
|
-
# Gets/sets the *allow_custom_commands* configuration setting (defaults to false).
|
17
|
-
# If this setting is set to *false*, only command classes that prepend the *SimpleCommand* module
|
18
|
-
# will be considered acceptable to run, all other command classes will fail to run. If this
|
19
|
-
# setting is set to *true*, any command class will be considered acceptable to run, regardless of
|
20
|
-
# whether or not the class prepends the *SimpleCommand* module.
|
21
|
-
#
|
22
|
-
# For information about the simple_command gem, visit {https://rubygems.org/gems/simple_command}
|
23
|
-
#
|
24
|
-
# @return [Boolean] the value.
|
25
|
-
#
|
26
|
-
attr_accessor :allow_custom_commands
|
27
|
+
attr_accessor :allow_custom_commands
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
def initialize
|
30
|
+
# The default is to use any command that exposes a ::call class method.
|
31
|
+
reset
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
34
|
+
# Resets the configuration to use the default values.
|
35
|
+
#
|
36
|
+
# @return [nil] returns nil.
|
37
|
+
#
|
38
|
+
def reset
|
39
|
+
@allow_custom_commands = false
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,18 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'configuration'
|
4
|
+
|
1
5
|
module SimpleCommand
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
+
module Dispatcher
|
7
|
+
class << self
|
8
|
+
attr_writer :configuration
|
9
|
+
end
|
6
10
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
# Returns the application configuration object.
|
12
|
+
#
|
13
|
+
# @return [Configuration] the application Configuration object.
|
14
|
+
def self.configuration
|
15
|
+
@configuration ||= Configuration.new
|
16
|
+
end
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
+
def self.configure
|
19
|
+
yield(configuration)
|
20
|
+
end
|
21
|
+
end
|
18
22
|
end
|