rcmdr 0.1.0.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.reek.yml +20 -0
- data/.rspec +3 -0
- data/.rubocop.yml +192 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +100 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/rcmdr/command.rb +110 -0
- data/lib/rcmdr/command_help.rb +58 -0
- data/lib/rcmdr/subcommand.rb +41 -0
- data/lib/rcmdr/version.rb +5 -0
- data/lib/rcmdr.rb +8 -0
- data/rcmdr.gemspec +43 -0
- data/sig/rcmdr.rbs +4 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 584f1e1d52d90ceb086abeb81429503eb63d03f0c100cb7d38d3ac9d797cdca7
|
4
|
+
data.tar.gz: 8ec4a49b63121dbba0c415834bedd76e6b5ad6e3e6fe36d747a29a9c0d1bb875
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4f6167976eacf7579f1312c4d9708c90dee93f9123c8ceea63496b4be43a49492f5294f336f45f5c3ca849bb6bc206ef1f697305b8d9808cd2d4fe6c64264566
|
7
|
+
data.tar.gz: a3867e01376c9a7d1b7fcb58ee204de29d81d6a1a8c8c8180b8b8d019f846a5b6289eef773e25778da34716a8e622e3c7a59dc8081edbb32903656a30c1cbf1c
|
data/.reek.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
exclude_paths:
|
2
|
+
- vendor
|
3
|
+
- spec
|
4
|
+
- scratch*.rb
|
5
|
+
- snippets*.rb
|
6
|
+
detectors:
|
7
|
+
# TooManyInstanceVariables:
|
8
|
+
# exclude:
|
9
|
+
# - "Class1"
|
10
|
+
# - "Class2"
|
11
|
+
# private methods do not have to depend on instance state
|
12
|
+
# https://github.com/troessner/reek/blob/master/docs/Utility-Function.md
|
13
|
+
UtilityFunction:
|
14
|
+
public_methods_only: true
|
15
|
+
# Check for variable name that doesn't communicate its intent well enough
|
16
|
+
# https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md
|
17
|
+
UncommunicativeVariableName:
|
18
|
+
accept:
|
19
|
+
- /^_$/
|
20
|
+
- /^e$/
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rspec
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 3.0.1
|
7
|
+
NewCops: enable
|
8
|
+
Exclude:
|
9
|
+
- '.git/**/*'
|
10
|
+
- '.idea/**/*'
|
11
|
+
- 'init/*'
|
12
|
+
- 'Rakefile'
|
13
|
+
# - '*.gemspec'
|
14
|
+
# - 'spec/**/*'
|
15
|
+
- 'vendor/**/*'
|
16
|
+
- 'scratch*.rb'
|
17
|
+
- 'snippets*.rb'
|
18
|
+
|
19
|
+
# Align the elements of a hash literal if they span more than one line.
|
20
|
+
Layout/HashAlignment:
|
21
|
+
EnforcedLastArgumentHashStyle: always_ignore
|
22
|
+
|
23
|
+
# Alignment of parameters in multi-line method definition.
|
24
|
+
# The `with_fixed_indentation` style aligns the following lines with one
|
25
|
+
# level of indentation relative to the start of the line with the method
|
26
|
+
# definition.
|
27
|
+
#
|
28
|
+
# def my_method(a,
|
29
|
+
# b)
|
30
|
+
Layout/ParameterAlignment:
|
31
|
+
EnforcedStyle: with_fixed_indentation
|
32
|
+
|
33
|
+
# Alignment of parameters in multi-line method call.
|
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 call.
|
36
|
+
#
|
37
|
+
# my_method(a,
|
38
|
+
# b)
|
39
|
+
Layout/ArgumentAlignment:
|
40
|
+
EnforcedStyle: with_fixed_indentation
|
41
|
+
|
42
|
+
# a = case n
|
43
|
+
# when 0
|
44
|
+
# x * 2
|
45
|
+
# else
|
46
|
+
# y / 3
|
47
|
+
# end
|
48
|
+
Layout/CaseIndentation:
|
49
|
+
EnforcedStyle: end
|
50
|
+
|
51
|
+
# Enforces a configured order of definitions within a class body
|
52
|
+
Layout/ClassStructure:
|
53
|
+
Enabled: true
|
54
|
+
|
55
|
+
# Align `end` with the matching keyword or starting expression except for
|
56
|
+
# assignments, where it should be aligned with the LHS.
|
57
|
+
Layout/EndAlignment:
|
58
|
+
EnforcedStyleAlignWith: variable
|
59
|
+
AutoCorrect: true
|
60
|
+
|
61
|
+
# The `consistent` style enforces that the first element in an array
|
62
|
+
# literal where the opening bracket and the first element are on
|
63
|
+
# seprate lines is indented the same as an array literal which is not
|
64
|
+
# defined inside a method call.
|
65
|
+
Layout/FirstArrayElementIndentation:
|
66
|
+
EnforcedStyle: consistent
|
67
|
+
|
68
|
+
# The `consistent` style enforces that the first key in a hash
|
69
|
+
# literal where the opening brace and the first key are on
|
70
|
+
# seprate lines is indented the same as a hash literal which is not
|
71
|
+
# defined inside a method call.
|
72
|
+
Layout/FirstHashElementIndentation:
|
73
|
+
EnforcedStyle: consistent
|
74
|
+
|
75
|
+
# Indent multi-line methods instead of aligning with periods
|
76
|
+
Layout/MultilineMethodCallIndentation:
|
77
|
+
EnforcedStyle: indented
|
78
|
+
|
79
|
+
# Allow `debug` in tasks for now
|
80
|
+
Lint/Debugger:
|
81
|
+
Exclude:
|
82
|
+
- 'RakeFile'
|
83
|
+
|
84
|
+
# A calculated magnitude based on number of assignments, branches, and
|
85
|
+
# conditions.
|
86
|
+
# NOTE: This is temporarily disabled until we can eliminate existing Rubocop
|
87
|
+
# complaints
|
88
|
+
Metrics/AbcSize:
|
89
|
+
Enabled: false
|
90
|
+
|
91
|
+
# Avoid long blocks with many lines.
|
92
|
+
Metrics/BlockLength:
|
93
|
+
Exclude:
|
94
|
+
- 'RakeFile'
|
95
|
+
- 'db/seeds.rb'
|
96
|
+
- 'spec/**/*.rb'
|
97
|
+
|
98
|
+
# Avoid classes longer than 100 lines of code.
|
99
|
+
# NOTE: This is temporarily disabled until we can eliminate existing Rubocop
|
100
|
+
# complaints
|
101
|
+
Metrics/ClassLength:
|
102
|
+
Max: 200
|
103
|
+
Exclude:
|
104
|
+
- 'spec/**/*.rb'
|
105
|
+
|
106
|
+
# A complexity metric that is strongly correlated to the number of test cases
|
107
|
+
# needed to validate a method.
|
108
|
+
Metrics/CyclomaticComplexity:
|
109
|
+
Max: 9
|
110
|
+
|
111
|
+
# Limit lines to 80 characters
|
112
|
+
Layout/LineLength:
|
113
|
+
Exclude:
|
114
|
+
- 'RakeFile'
|
115
|
+
- 'spec/**/*.rb'
|
116
|
+
|
117
|
+
# Avoid methods longer than 15 lines of code.
|
118
|
+
Metrics/MethodLength:
|
119
|
+
Max: 20
|
120
|
+
AllowedMethods:
|
121
|
+
- swagger_path
|
122
|
+
- operation
|
123
|
+
|
124
|
+
|
125
|
+
# A complexity metric geared towards measuring complexity for a human reader.
|
126
|
+
Metrics/PerceivedComplexity:
|
127
|
+
Max: 10
|
128
|
+
|
129
|
+
NestedGroups:
|
130
|
+
Max: 4
|
131
|
+
|
132
|
+
# Naming/FileName:
|
133
|
+
# Exclude:
|
134
|
+
# - 'lib/file.rb'
|
135
|
+
|
136
|
+
# Allow `downcase == ` instead of forcing `casecmp`
|
137
|
+
Performance/Casecmp:
|
138
|
+
Enabled: false
|
139
|
+
|
140
|
+
# Require children definitions to be nested or compact in classes and modules
|
141
|
+
Style/ClassAndModuleChildren:
|
142
|
+
Enabled: false
|
143
|
+
|
144
|
+
# Document classes and non-namespace modules.
|
145
|
+
# (Disabled for now, may revisit later)
|
146
|
+
Style/Documentation:
|
147
|
+
Enabled: false
|
148
|
+
|
149
|
+
# Checks the formatting of empty method definitions.
|
150
|
+
Style/EmptyMethod:
|
151
|
+
EnforcedStyle: expanded
|
152
|
+
|
153
|
+
# Add the frozen_string_literal comment to the top of files to help transition
|
154
|
+
# to frozen string literals by default.
|
155
|
+
Style/FrozenStringLiteralComment:
|
156
|
+
EnforcedStyle: always
|
157
|
+
|
158
|
+
# Check for conditionals that can be replaced with guard clauses
|
159
|
+
Style/GuardClause:
|
160
|
+
Enabled: false
|
161
|
+
|
162
|
+
Style/MixinUsage:
|
163
|
+
Exclude:
|
164
|
+
- 'RakeFile'
|
165
|
+
|
166
|
+
# Avoid multi-line method signatures.
|
167
|
+
Style/MultilineMethodSignature:
|
168
|
+
Enabled: true
|
169
|
+
|
170
|
+
# Don't use option hashes when you can use keyword arguments.
|
171
|
+
Style/OptionHash:
|
172
|
+
Enabled: true
|
173
|
+
|
174
|
+
# Use return instead of return nil.
|
175
|
+
Style/ReturnNil:
|
176
|
+
Enabled: true
|
177
|
+
|
178
|
+
# Allow code like `return x, y` as it's occasionally handy.
|
179
|
+
Style/RedundantReturn:
|
180
|
+
AllowMultipleReturnValues: true
|
181
|
+
|
182
|
+
# Prefer symbols instead of strings as hash keys.
|
183
|
+
Style/StringHashKeys:
|
184
|
+
Enabled: true
|
185
|
+
|
186
|
+
# Checks if configured preferred methods are used over non-preferred.
|
187
|
+
Style/StringMethods:
|
188
|
+
Enabled: true
|
189
|
+
|
190
|
+
# Checks for use of parentheses around ternary conditions.
|
191
|
+
Style/TernaryParentheses:
|
192
|
+
EnforcedStyle: require_parentheses_when_complex
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.1
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at web.gma@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in rcmdr.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'rake', '~> 13.0'
|
9
|
+
gem 'rspec', '~> 3.0'
|
10
|
+
gem 'rubocop', '~> 0.81.0'
|
11
|
+
|
12
|
+
gem 'pry-byebug', '~> 3.9'
|
13
|
+
gem 'reek', '~> 6.1', '>= 6.1.1'
|
14
|
+
gem 'simplecov', '~> 0.21.2'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rcmdr (0.1.0.pre.alpha)
|
5
|
+
activesupport (~> 7.0, >= 7.0.4)
|
6
|
+
deco_lite (~> 1.3)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (7.0.4)
|
12
|
+
activesupport (= 7.0.4)
|
13
|
+
activesupport (7.0.4)
|
14
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
+
i18n (>= 1.6, < 2)
|
16
|
+
minitest (>= 5.1)
|
17
|
+
tzinfo (~> 2.0)
|
18
|
+
ast (2.4.2)
|
19
|
+
byebug (11.1.3)
|
20
|
+
coderay (1.1.3)
|
21
|
+
concurrent-ruby (1.1.10)
|
22
|
+
deco_lite (1.3.0)
|
23
|
+
activemodel (~> 7.0, >= 7.0.3.1)
|
24
|
+
activesupport (~> 7.0, >= 7.0.3.1)
|
25
|
+
immutable_struct_ex (~> 0.2.0)
|
26
|
+
mad_flatter (~> 2.0)
|
27
|
+
diff-lcs (1.5.0)
|
28
|
+
docile (1.4.0)
|
29
|
+
i18n (1.12.0)
|
30
|
+
concurrent-ruby (~> 1.0)
|
31
|
+
immutable_struct_ex (0.2.3)
|
32
|
+
jaro_winkler (1.5.4)
|
33
|
+
kwalify (0.7.2)
|
34
|
+
mad_flatter (2.0.0)
|
35
|
+
activesupport (~> 7.0, >= 7.0.3.1)
|
36
|
+
immutable_struct_ex (~> 0.2.0)
|
37
|
+
method_source (1.0.0)
|
38
|
+
minitest (5.16.3)
|
39
|
+
parallel (1.22.1)
|
40
|
+
parser (3.1.2.1)
|
41
|
+
ast (~> 2.4.1)
|
42
|
+
pry (0.14.1)
|
43
|
+
coderay (~> 1.1)
|
44
|
+
method_source (~> 1.0)
|
45
|
+
pry-byebug (3.10.1)
|
46
|
+
byebug (~> 11.0)
|
47
|
+
pry (>= 0.13, < 0.15)
|
48
|
+
rainbow (3.1.1)
|
49
|
+
rake (13.0.6)
|
50
|
+
reek (6.1.1)
|
51
|
+
kwalify (~> 0.7.0)
|
52
|
+
parser (~> 3.1.0)
|
53
|
+
rainbow (>= 2.0, < 4.0)
|
54
|
+
rexml (3.2.5)
|
55
|
+
rspec (3.11.0)
|
56
|
+
rspec-core (~> 3.11.0)
|
57
|
+
rspec-expectations (~> 3.11.0)
|
58
|
+
rspec-mocks (~> 3.11.0)
|
59
|
+
rspec-core (3.11.0)
|
60
|
+
rspec-support (~> 3.11.0)
|
61
|
+
rspec-expectations (3.11.1)
|
62
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
63
|
+
rspec-support (~> 3.11.0)
|
64
|
+
rspec-mocks (3.11.1)
|
65
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
+
rspec-support (~> 3.11.0)
|
67
|
+
rspec-support (3.11.1)
|
68
|
+
rubocop (0.81.0)
|
69
|
+
jaro_winkler (~> 1.5.1)
|
70
|
+
parallel (~> 1.10)
|
71
|
+
parser (>= 2.7.0.1)
|
72
|
+
rainbow (>= 2.2.2, < 4.0)
|
73
|
+
rexml
|
74
|
+
ruby-progressbar (~> 1.7)
|
75
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
76
|
+
ruby-progressbar (1.11.0)
|
77
|
+
simplecov (0.21.2)
|
78
|
+
docile (~> 1.1)
|
79
|
+
simplecov-html (~> 0.11)
|
80
|
+
simplecov_json_formatter (~> 0.1)
|
81
|
+
simplecov-html (0.12.3)
|
82
|
+
simplecov_json_formatter (0.1.4)
|
83
|
+
tzinfo (2.0.5)
|
84
|
+
concurrent-ruby (~> 1.0)
|
85
|
+
unicode-display_width (1.8.0)
|
86
|
+
|
87
|
+
PLATFORMS
|
88
|
+
x86_64-darwin-19
|
89
|
+
|
90
|
+
DEPENDENCIES
|
91
|
+
pry-byebug (~> 3.9)
|
92
|
+
rake (~> 13.0)
|
93
|
+
rcmdr!
|
94
|
+
reek (~> 6.1, >= 6.1.1)
|
95
|
+
rspec (~> 3.0)
|
96
|
+
rubocop (~> 0.81.0)
|
97
|
+
simplecov (~> 0.21.2)
|
98
|
+
|
99
|
+
BUNDLED WITH
|
100
|
+
2.3.22
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 gangelo
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Rcmdr
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rcmdr`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'rcmdr'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install rcmdr
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rcmdr. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rcmdr/blob/main/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the Rcmdr project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rcmdr/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'rcmdr'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'command_help'
|
4
|
+
require_relative 'subcommand'
|
5
|
+
|
6
|
+
module Rcmdr
|
7
|
+
# https://www.toptal.com/ruby/ruby-dsl-metaprogramming-guide
|
8
|
+
module Command
|
9
|
+
class << self
|
10
|
+
def included(base)
|
11
|
+
base.extend ClassMethods
|
12
|
+
base.engine.command_namespace to_command_namespace_symbol base.name
|
13
|
+
base.engine.command_prompt base.engine.command_namespace
|
14
|
+
base.singleton_class.delegate :command_namespace, :command_namespaces, :commands,
|
15
|
+
:command_add, :command_subcommand_add, :command_prompt, :command_parent,
|
16
|
+
:help, to: :engine
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def to_command_namespace_symbol(namespace, join_token: '_')
|
22
|
+
namespace.delete(':').split(/(?=[A-Z])/).join(join_token).downcase
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module ClassMethods
|
27
|
+
def command_subcommand_create(command_parent:)
|
28
|
+
new.tap do |subcommand|
|
29
|
+
subcommand.extend Subcommand
|
30
|
+
subcommand.command_parent command_parent
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def engine
|
35
|
+
@engine ||= Engine.new(owning_command: self)
|
36
|
+
end
|
37
|
+
|
38
|
+
class Engine
|
39
|
+
include CommandHelp
|
40
|
+
|
41
|
+
attr_reader :owning_command
|
42
|
+
|
43
|
+
def initialize(owning_command:)
|
44
|
+
@owning_command = owning_command
|
45
|
+
end
|
46
|
+
|
47
|
+
def command_add(command:, desc:, long_desc: nil, options: {}, commands: [])
|
48
|
+
self.commands[command_namespace] ||= {}
|
49
|
+
self.commands[command_namespace][command] = {
|
50
|
+
desc: desc,
|
51
|
+
long_desc: long_desc,
|
52
|
+
options: options,
|
53
|
+
commands: commands,
|
54
|
+
help: command_help_for(command: command, desc: desc,
|
55
|
+
long_desc: long_desc, options: options, commands: commands)
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def command_subcommand_add(subcommand, command_parent: nil)
|
60
|
+
command_parent ||= @owning_command
|
61
|
+
subcommand = subcommand.command_subcommand_create command_parent: command_parent
|
62
|
+
commands[command_namespace] ||= {}
|
63
|
+
subcommand.command_namespaces.each_with_index do |namespace, index|
|
64
|
+
next if index.zero?
|
65
|
+
|
66
|
+
target = commands.dig(*subcommand.command_namespaces[1..index])
|
67
|
+
target ||= commands.dig(*subcommand.command_namespaces[0..index - 1])
|
68
|
+
target[namespace] ||= {}
|
69
|
+
end
|
70
|
+
commands.dig(*subcommand.command_namespaces[0..])[subcommand.command_namespaces.last] = subcommand
|
71
|
+
end
|
72
|
+
|
73
|
+
def command_namespaces(namespaces = [])
|
74
|
+
command_parent&.command_namespaces(namespaces)
|
75
|
+
|
76
|
+
namespaces << command_namespace
|
77
|
+
namespaces
|
78
|
+
end
|
79
|
+
|
80
|
+
def command_namespace(namespace = nil)
|
81
|
+
return @command_namespace || name if namespace.nil?
|
82
|
+
|
83
|
+
@command_namespace = namespace
|
84
|
+
end
|
85
|
+
|
86
|
+
def command_prompt(value = nil)
|
87
|
+
return @command_prompt || name if value.nil?
|
88
|
+
|
89
|
+
@command_prompt = value
|
90
|
+
end
|
91
|
+
|
92
|
+
def command_parent(parent = nil)
|
93
|
+
return @command_parent if parent.nil?
|
94
|
+
|
95
|
+
@command_parent = parent
|
96
|
+
end
|
97
|
+
|
98
|
+
def commands
|
99
|
+
@commands ||= {}
|
100
|
+
end
|
101
|
+
|
102
|
+
def help
|
103
|
+
commands.each do |_command, command_data|
|
104
|
+
puts "#{command_namespaces.join(' ')} #{command_data[:help]}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rcmdr
|
4
|
+
module CommandHelp
|
5
|
+
private
|
6
|
+
|
7
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
8
|
+
def command_help_for(command:, desc:, namespaces: nil, long_desc: nil, options: {}, commands: [])
|
9
|
+
namespaces ||= command_namespaces
|
10
|
+
help =
|
11
|
+
<<~HELP
|
12
|
+
#{namespaces&.join(' ')} #{command}#{' [OPTIONS]' if options&.any?} - #{desc}
|
13
|
+
#{'OPTIONS:' if options&.any?}
|
14
|
+
#{options_help_for options}
|
15
|
+
#{'OPTION ALIASES:' if any_option_aliases_for?(options)}
|
16
|
+
#{options_aliases_help_for options}
|
17
|
+
#{'---' unless long_desc.blank?}
|
18
|
+
#{long_desc}
|
19
|
+
HELP
|
20
|
+
help.gsub(/\n{2,}/, "\n")
|
21
|
+
end
|
22
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
23
|
+
|
24
|
+
def options_help_for(options)
|
25
|
+
return [] if options.blank?
|
26
|
+
|
27
|
+
options.map do |option, data|
|
28
|
+
type = option_to_a(data[:type])&.join(' | ')
|
29
|
+
type = :boolean if type.blank?
|
30
|
+
"#{option} <#{type}>, default: #{data[:default]}"
|
31
|
+
end.join("\n")
|
32
|
+
end
|
33
|
+
|
34
|
+
def options_aliases_help_for(options)
|
35
|
+
return unless any_option_aliases_for?(options)
|
36
|
+
|
37
|
+
options.filter_map do |option, data|
|
38
|
+
aliases = option_to_a(data[:aliases])&.join(' | ')
|
39
|
+
<<~HELP
|
40
|
+
#{option} aliases: [#{aliases}]
|
41
|
+
HELP
|
42
|
+
end.join("\n")
|
43
|
+
end
|
44
|
+
|
45
|
+
def any_option_aliases_for?(options)
|
46
|
+
return false if options.blank?
|
47
|
+
|
48
|
+
options.keys.any? { |key| options.dig(key, :aliases).any? }
|
49
|
+
end
|
50
|
+
|
51
|
+
def option_to_a(option)
|
52
|
+
return [] if option.blank?
|
53
|
+
return option if option.is_a? Array
|
54
|
+
|
55
|
+
[option]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rcmdr
|
4
|
+
# Subcommands should extend this module once they are instantiated
|
5
|
+
# so that the Subcommand instance has access to all necessary
|
6
|
+
# class methods for this subcommand to work.
|
7
|
+
module Subcommand
|
8
|
+
class << self
|
9
|
+
def extended(mod)
|
10
|
+
mod.singleton_class.delegate :command_namespace, :commands,
|
11
|
+
:command_add, :command_subcommand_add, :command_prompt, :help, to: mod.class
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Subcommand-specific instance methods.
|
16
|
+
#
|
17
|
+
# Define Subcommand-specific method equivalents of the Command class
|
18
|
+
# methods needed to make this Subcommand instance unique.
|
19
|
+
|
20
|
+
# def command_namespace(namespace = nil)
|
21
|
+
# return @command_namespace || name if namespace.nil?
|
22
|
+
|
23
|
+
# @command_namespace = namespace
|
24
|
+
# end
|
25
|
+
|
26
|
+
# Subcommands can be used by any Command, so the :command_parent needs
|
27
|
+
# to be unique to this Subcommand instance.
|
28
|
+
def command_parent(parent = nil)
|
29
|
+
return @command_prompt if parent.nil?
|
30
|
+
|
31
|
+
@command_prompt = parent
|
32
|
+
end
|
33
|
+
|
34
|
+
def command_namespaces(namespaces = [])
|
35
|
+
command_parent&.command_namespaces(namespaces)
|
36
|
+
|
37
|
+
namespaces << command_namespace
|
38
|
+
namespaces
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/rcmdr.rb
ADDED
data/rcmdr.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/rcmdr/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'rcmdr'
|
7
|
+
spec.version = Rcmdr::VERSION
|
8
|
+
spec.authors = ['Gene M. Angelo, Jr.']
|
9
|
+
spec.email = ['public.gma@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'rcmdr, the RESTful command manager/interpreter gem.'
|
12
|
+
spec.description = <<-DESC
|
13
|
+
rcmdr a Ruby gem that uses a RESTful approach to managing and interpreting
|
14
|
+
commands and their requests. A "command" being defined as any action that may
|
15
|
+
be carried out in a manner consistent with the following REST verbs GET, POST,
|
16
|
+
PUT, PATCH, DELETE and OPTIONS.
|
17
|
+
DESC
|
18
|
+
spec.homepage = 'https://github.com/gangelo/rcmdr'
|
19
|
+
spec.license = 'MIT'
|
20
|
+
spec.required_ruby_version = '>= 3.0.1'
|
21
|
+
|
22
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
23
|
+
|
24
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
25
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
26
|
+
spec.metadata['changelog_uri'] = 'https://github.com/gangelo/rcmdr/blob/main/CHANGELOG.md'
|
27
|
+
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
31
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
32
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
33
|
+
end
|
34
|
+
end
|
35
|
+
spec.bindir = 'exe'
|
36
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ['lib']
|
38
|
+
|
39
|
+
spec.add_dependency 'activesupport', '~> 7.0', '>= 7.0.4'
|
40
|
+
spec.add_dependency 'deco_lite', '~> 1.3'
|
41
|
+
|
42
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
43
|
+
end
|
data/sig/rcmdr.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rcmdr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.pre.alpha
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gene M. Angelo, Jr.
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-10-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '7.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 7.0.4
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '7.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 7.0.4
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: deco_lite
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.3'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.3'
|
47
|
+
description: |2
|
48
|
+
rcmdr a Ruby gem that uses a RESTful approach to managing and interpreting
|
49
|
+
commands and their requests. A "command" being defined as any action that may
|
50
|
+
be carried out in a manner consistent with the following REST verbs GET, POST,
|
51
|
+
PUT, PATCH, DELETE and OPTIONS.
|
52
|
+
email:
|
53
|
+
- public.gma@gmail.com
|
54
|
+
executables: []
|
55
|
+
extensions: []
|
56
|
+
extra_rdoc_files: []
|
57
|
+
files:
|
58
|
+
- ".reek.yml"
|
59
|
+
- ".rspec"
|
60
|
+
- ".rubocop.yml"
|
61
|
+
- ".ruby-version"
|
62
|
+
- CHANGELOG.md
|
63
|
+
- CODE_OF_CONDUCT.md
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/rcmdr.rb
|
72
|
+
- lib/rcmdr/command.rb
|
73
|
+
- lib/rcmdr/command_help.rb
|
74
|
+
- lib/rcmdr/subcommand.rb
|
75
|
+
- lib/rcmdr/version.rb
|
76
|
+
- rcmdr.gemspec
|
77
|
+
- sig/rcmdr.rbs
|
78
|
+
homepage: https://github.com/gangelo/rcmdr
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata:
|
82
|
+
homepage_uri: https://github.com/gangelo/rcmdr
|
83
|
+
source_code_uri: https://github.com/gangelo/rcmdr
|
84
|
+
changelog_uri: https://github.com/gangelo/rcmdr/blob/main/CHANGELOG.md
|
85
|
+
rubygems_mfa_required: 'true'
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 3.0.1
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 1.3.1
|
100
|
+
requirements: []
|
101
|
+
rubygems_version: 3.3.22
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: rcmdr, the RESTful command manager/interpreter gem.
|
105
|
+
test_files: []
|