ronin-core 0.1.0.beta1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -0
  3. data/.yardopts +1 -1
  4. data/README.md +2 -1
  5. data/gemspec.yml +1 -1
  6. data/lib/ronin/core/class_registry.rb +3 -3
  7. data/lib/ronin/core/cli/command.rb +1 -1
  8. data/lib/ronin/core/cli/command_shell/command.rb +1 -1
  9. data/lib/ronin/core/cli/command_shell.rb +2 -2
  10. data/lib/ronin/core/cli/generator/options/author.rb +1 -1
  11. data/lib/ronin/core/cli/generator/options/description.rb +1 -1
  12. data/lib/ronin/core/cli/generator/options/reference.rb +1 -1
  13. data/lib/ronin/core/cli/generator/options/summary.rb +1 -1
  14. data/lib/ronin/core/cli/generator.rb +1 -1
  15. data/lib/ronin/core/cli/logging.rb +1 -1
  16. data/lib/ronin/core/cli/options/param.rb +1 -1
  17. data/lib/ronin/core/cli/options/values/arches.rb +1 -1
  18. data/lib/ronin/core/cli/options/values/oses.rb +1 -1
  19. data/lib/ronin/core/cli/printing/arch.rb +1 -1
  20. data/lib/ronin/core/cli/printing/metadata.rb +2 -2
  21. data/lib/ronin/core/cli/printing/os.rb +1 -1
  22. data/lib/ronin/core/cli/printing/params.rb +1 -1
  23. data/lib/ronin/core/cli/ruby_shell.rb +1 -1
  24. data/lib/ronin/core/cli/shell.rb +2 -2
  25. data/lib/ronin/core/git.rb +1 -1
  26. data/lib/ronin/core/home.rb +1 -1
  27. data/lib/ronin/core/metadata/authors/author.rb +1 -1
  28. data/lib/ronin/core/metadata/authors.rb +1 -1
  29. data/lib/ronin/core/metadata/description.rb +1 -1
  30. data/lib/ronin/core/metadata/id.rb +1 -1
  31. data/lib/ronin/core/metadata/references.rb +1 -1
  32. data/lib/ronin/core/metadata/summary.rb +1 -1
  33. data/lib/ronin/core/metadata/version.rb +1 -1
  34. data/lib/ronin/core/params/exceptions.rb +1 -1
  35. data/lib/ronin/core/params/mixin.rb +2 -2
  36. data/lib/ronin/core/params/param.rb +2 -2
  37. data/lib/ronin/core/params/types/boolean.rb +1 -1
  38. data/lib/ronin/core/params/types/enum.rb +1 -1
  39. data/lib/ronin/core/params/types/float.rb +1 -1
  40. data/lib/ronin/core/params/types/integer.rb +1 -1
  41. data/lib/ronin/core/params/types/numeric.rb +1 -1
  42. data/lib/ronin/core/params/types/regexp.rb +1 -1
  43. data/lib/ronin/core/params/types/string.rb +1 -1
  44. data/lib/ronin/core/params/types/type.rb +1 -1
  45. data/lib/ronin/core/params/types/uri.rb +1 -1
  46. data/lib/ronin/core/params/types.rb +1 -1
  47. data/lib/ronin/core/params.rb +1 -1
  48. data/lib/ronin/core/version.rb +2 -2
  49. data/ronin-core.gemspec +2 -1
  50. metadata +4 -90
  51. data/spec/class_registry_spec.rb +0 -224
  52. data/spec/cli/command_shell/command_spec.rb +0 -113
  53. data/spec/cli/command_shell_spec.rb +0 -1114
  54. data/spec/cli/command_spec.rb +0 -16
  55. data/spec/cli/fixtures/irb_command +0 -8
  56. data/spec/cli/fixtures/template/dir/file1.txt +0 -1
  57. data/spec/cli/fixtures/template/dir/file2.txt +0 -1
  58. data/spec/cli/fixtures/template/file.erb +0 -1
  59. data/spec/cli/fixtures/template/file.txt +0 -1
  60. data/spec/cli/generator/options/author_spec.rb +0 -121
  61. data/spec/cli/generator/options/description_spec.rb +0 -45
  62. data/spec/cli/generator/options/reference_spec.rb +0 -53
  63. data/spec/cli/generator/options/summary_spec.rb +0 -45
  64. data/spec/cli/generator_spec.rb +0 -244
  65. data/spec/cli/logging_spec.rb +0 -95
  66. data/spec/cli/options/param_spec.rb +0 -67
  67. data/spec/cli/options/values/arches_spec.rb +0 -62
  68. data/spec/cli/printing/arch_spec.rb +0 -130
  69. data/spec/cli/printing/metadata_spec.rb +0 -211
  70. data/spec/cli/printing/os_spec.rb +0 -64
  71. data/spec/cli/printing/params_spec.rb +0 -63
  72. data/spec/cli/ruby_shell.rb +0 -99
  73. data/spec/cli/shell_spec.rb +0 -211
  74. data/spec/fixtures/example_class_registry/base_class.rb +0 -9
  75. data/spec/fixtures/example_class_registry/classes/loaded_class.rb +0 -9
  76. data/spec/fixtures/example_class_registry/classes/name_mismatch.rb +0 -9
  77. data/spec/fixtures/example_class_registry/classes/no_module.rb +0 -4
  78. data/spec/fixtures/example_class_registry.rb +0 -8
  79. data/spec/git_spec.rb +0 -58
  80. data/spec/home_spec.rb +0 -64
  81. data/spec/metadata/authors/author_spec.rb +0 -335
  82. data/spec/metadata/authors_spec.rb +0 -126
  83. data/spec/metadata/description_spec.rb +0 -74
  84. data/spec/metadata/id_spec.rb +0 -92
  85. data/spec/metadata/references_spec.rb +0 -100
  86. data/spec/metadata/summary_spec.rb +0 -74
  87. data/spec/metadata/version_spec.rb +0 -72
  88. data/spec/params/mixin_spec.rb +0 -484
  89. data/spec/params/param_spec.rb +0 -164
  90. data/spec/params/types/boolean_spec.rb +0 -56
  91. data/spec/params/types/enum_spec.rb +0 -94
  92. data/spec/params/types/float_spec.rb +0 -107
  93. data/spec/params/types/integer_spec.rb +0 -155
  94. data/spec/params/types/numeric_spec.rb +0 -138
  95. data/spec/params/types/regexp_spec.rb +0 -64
  96. data/spec/params/types/string_spec.rb +0 -174
  97. data/spec/params/types/type_spec.rb +0 -14
  98. data/spec/params/types/uri_spec.rb +0 -62
  99. data/spec/spec_helper.rb +0 -11
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronin-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-01 00:00:00.000000000 Z
11
+ date: 2023-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reline
@@ -135,60 +135,11 @@ files:
135
135
  - lib/ronin/core/params/types/uri.rb
136
136
  - lib/ronin/core/version.rb
137
137
  - ronin-core.gemspec
138
- - spec/class_registry_spec.rb
139
- - spec/cli/command_shell/command_spec.rb
140
- - spec/cli/command_shell_spec.rb
141
- - spec/cli/command_spec.rb
142
- - spec/cli/fixtures/irb_command
143
- - spec/cli/fixtures/template/dir/file1.txt
144
- - spec/cli/fixtures/template/dir/file2.txt
145
- - spec/cli/fixtures/template/file.erb
146
- - spec/cli/fixtures/template/file.txt
147
- - spec/cli/generator/options/author_spec.rb
148
- - spec/cli/generator/options/description_spec.rb
149
- - spec/cli/generator/options/reference_spec.rb
150
- - spec/cli/generator/options/summary_spec.rb
151
- - spec/cli/generator_spec.rb
152
- - spec/cli/logging_spec.rb
153
- - spec/cli/options/param_spec.rb
154
- - spec/cli/options/values/arches_spec.rb
155
- - spec/cli/printing/arch_spec.rb
156
- - spec/cli/printing/metadata_spec.rb
157
- - spec/cli/printing/os_spec.rb
158
- - spec/cli/printing/params_spec.rb
159
- - spec/cli/ruby_shell.rb
160
- - spec/cli/shell_spec.rb
161
- - spec/fixtures/example_class_registry.rb
162
- - spec/fixtures/example_class_registry/base_class.rb
163
- - spec/fixtures/example_class_registry/classes/loaded_class.rb
164
- - spec/fixtures/example_class_registry/classes/name_mismatch.rb
165
- - spec/fixtures/example_class_registry/classes/no_module.rb
166
- - spec/git_spec.rb
167
- - spec/home_spec.rb
168
- - spec/metadata/authors/author_spec.rb
169
- - spec/metadata/authors_spec.rb
170
- - spec/metadata/description_spec.rb
171
- - spec/metadata/id_spec.rb
172
- - spec/metadata/references_spec.rb
173
- - spec/metadata/summary_spec.rb
174
- - spec/metadata/version_spec.rb
175
- - spec/params/mixin_spec.rb
176
- - spec/params/param_spec.rb
177
- - spec/params/types/boolean_spec.rb
178
- - spec/params/types/enum_spec.rb
179
- - spec/params/types/float_spec.rb
180
- - spec/params/types/integer_spec.rb
181
- - spec/params/types/numeric_spec.rb
182
- - spec/params/types/regexp_spec.rb
183
- - spec/params/types/string_spec.rb
184
- - spec/params/types/type_spec.rb
185
- - spec/params/types/uri_spec.rb
186
- - spec/spec_helper.rb
187
138
  homepage: https://ronin-rb.dev/
188
139
  licenses:
189
140
  - LGPL-3.0
190
141
  metadata:
191
- documentation_uri: https://rubydoc.info/gems/ronin-core
142
+ documentation_uri: https://ronin-rb.dev/docs/ronin-core
192
143
  source_code_uri: https://github.com/ronin-rb/ronin-core
193
144
  bug_tracker_uri: https://github.com/ronin-rb/ronin-core/issues
194
145
  changelog_uri: https://github.com/ronin-rb/ronin-core/blob/main/ChangeLog.md
@@ -212,41 +163,4 @@ rubygems_version: 3.3.26
212
163
  signing_key:
213
164
  specification_version: 4
214
165
  summary: A core library for all ronin libraries.
215
- test_files:
216
- - spec/class_registry_spec.rb
217
- - spec/cli/command_shell/command_spec.rb
218
- - spec/cli/command_shell_spec.rb
219
- - spec/cli/command_spec.rb
220
- - spec/cli/generator/options/author_spec.rb
221
- - spec/cli/generator/options/description_spec.rb
222
- - spec/cli/generator/options/reference_spec.rb
223
- - spec/cli/generator/options/summary_spec.rb
224
- - spec/cli/generator_spec.rb
225
- - spec/cli/logging_spec.rb
226
- - spec/cli/options/param_spec.rb
227
- - spec/cli/options/values/arches_spec.rb
228
- - spec/cli/printing/arch_spec.rb
229
- - spec/cli/printing/metadata_spec.rb
230
- - spec/cli/printing/os_spec.rb
231
- - spec/cli/printing/params_spec.rb
232
- - spec/cli/shell_spec.rb
233
- - spec/git_spec.rb
234
- - spec/home_spec.rb
235
- - spec/metadata/authors/author_spec.rb
236
- - spec/metadata/authors_spec.rb
237
- - spec/metadata/description_spec.rb
238
- - spec/metadata/id_spec.rb
239
- - spec/metadata/references_spec.rb
240
- - spec/metadata/summary_spec.rb
241
- - spec/metadata/version_spec.rb
242
- - spec/params/mixin_spec.rb
243
- - spec/params/param_spec.rb
244
- - spec/params/types/boolean_spec.rb
245
- - spec/params/types/enum_spec.rb
246
- - spec/params/types/float_spec.rb
247
- - spec/params/types/integer_spec.rb
248
- - spec/params/types/numeric_spec.rb
249
- - spec/params/types/regexp_spec.rb
250
- - spec/params/types/string_spec.rb
251
- - spec/params/types/type_spec.rb
252
- - spec/params/types/uri_spec.rb
166
+ test_files: []
@@ -1,224 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/core/class_registry'
3
-
4
- require 'fixtures/example_class_registry'
5
-
6
- describe Ronin::Core::ClassRegistry do
7
- let(:fixtures_dir) { File.join(__dir__,'fixtures') }
8
-
9
- describe ".class_dir" do
10
- context "when a class_dir has been defined" do
11
- module TestClassRegistry
12
- module WithAModulesDir
13
- include Ronin::Core::ClassRegistry
14
-
15
- class_dir "#{__dir__}/test/dir"
16
- end
17
- end
18
-
19
- subject { TestClassRegistry::WithAModulesDir }
20
-
21
- it "must return the previously set .class_dir" do
22
- expect(subject.class_dir).to eq("#{__dir__}/test/dir")
23
- end
24
- end
25
-
26
- context "but when no class_dir has been defined" do
27
- module TestClassRegistry
28
- module WithNoModuleLoadPath
29
- include Ronin::Core::ClassRegistry
30
- end
31
- end
32
-
33
- subject { TestClassRegistry::WithNoModuleLoadPath }
34
-
35
- it do
36
- expect {
37
- subject.class_dir
38
- }.to raise_error(NotImplementedError,"#{subject} did not define a class_dir")
39
- end
40
- end
41
- end
42
-
43
- subject { ExampleClassRegistry }
44
-
45
- describe ".list_files" do
46
- it "must return an Array of module names" do
47
- expect(subject.list_files).to eq(
48
- %w[
49
- loaded_class
50
- name_mismatch
51
- no_module
52
- ]
53
- )
54
- end
55
- end
56
-
57
- describe ".registry" do
58
- it "must default to {}" do
59
- expect(subject.registry).to eq({})
60
- end
61
- end
62
-
63
- describe ".path_for" do
64
- context "when the module name exists within the .class_dir" do
65
- let(:id) { 'loaded_class' }
66
-
67
- it "must return the path to the .rb file for the module" do
68
- expect(subject.path_for(id)).to eq(
69
- File.join(subject.class_dir,"#{id}.rb")
70
- )
71
- end
72
- end
73
-
74
- context "when the module name does not have a file within .class_dir" do
75
- let(:id) { "does_not_exist" }
76
-
77
- it "must return nil" do
78
- expect(subject.path_for(id)).to be(nil)
79
- end
80
- end
81
- end
82
-
83
- describe ".register" do
84
- module TestClassRegistry
85
- module ExampleNamespace
86
- class Foo
87
- end
88
- end
89
- end
90
-
91
- let(:id) { 'foo' }
92
- let(:klass) { TestClassRegistry::ExampleNamespace::Foo }
93
-
94
- before { subject.register(id,klass) }
95
-
96
- it "must add the class id and class to #registry" do
97
- expect(subject.registry[id]).to be(klass)
98
- end
99
-
100
- after { subject.registry.clear }
101
- end
102
-
103
- describe ".load_class_from_file" do
104
- let(:id) { 'loaded_class' }
105
- let(:file) { File.join(subject.class_dir,"#{id}.rb") }
106
- let(:klass) { ExampleClassRegistry::LoadedClass }
107
-
108
- it "must require the file" do
109
- subject.load_class_from_file(file)
110
-
111
- expect($LOADED_FEATURES).to include(file)
112
- end
113
-
114
- it "must return the registered module" do
115
- expect(subject.load_class_from_file(file)).to be(klass)
116
- end
117
-
118
- it "must register the module with the same id as the file" do
119
- subject.load_class_from_file(file)
120
-
121
- expect(subject.registry[id]).to be(klass)
122
- end
123
-
124
- context "when given a relative path" do
125
- let(:relative_path) { File.join(subject.class_dir,'foo','..',"#{id}.rb") }
126
- let(:absolute_path) { File.expand_path(relative_path) }
127
-
128
- it "must expand the path first" do
129
- expect(subject).to receive(:require).with(absolute_path) do
130
- load(absolute_path)
131
- end
132
-
133
- subject.load_class_from_file(relative_path)
134
- end
135
- end
136
-
137
- context "when the file does not exist" do
138
- let(:file) { "path/does/not/exist.rb" }
139
- let(:absolute_path) { File.expand_path(file) }
140
-
141
- it do
142
- expect {
143
- subject.load_class_from_file(file)
144
- }.to raise_error(described_class::ClassNotFound,"no such file or directory: #{absolute_path.inspect}")
145
- end
146
- end
147
-
148
- context "when the file does not register a module" do
149
- let(:id) { 'no_module' }
150
- let(:file) { File.join(subject.class_dir,"#{id}.rb") }
151
-
152
- it do
153
- expect {
154
- subject.load_class_from_file(file)
155
- }.to raise_error(described_class::ClassNotFound,"file did not register a class: #{file.inspect}")
156
- end
157
- end
158
-
159
- after do
160
- subject.registry.clear
161
- $LOADED_FEATURES.delete(file)
162
- end
163
- end
164
-
165
- describe ".load_class" do
166
- let(:id) { 'loaded_class' }
167
- let(:klass) { ExampleClassRegistry::LoadedClass }
168
- let(:path) { File.join(subject.class_dir,"#{id}.rb") }
169
-
170
- it "must require the file within the .class_dir" do
171
- subject.load_class(id)
172
-
173
- expect($LOADED_FEATURES).to include(path)
174
- end
175
-
176
- it "must return the registered module" do
177
- expect(subject.load_class(id)).to be(klass)
178
- end
179
-
180
- it "must register the module with the same id as the file" do
181
- subject.load_class(id)
182
-
183
- expect(subject.registry[id]).to be(klass)
184
- end
185
-
186
- context "when the file does not exist" do
187
- let(:id) { 'does_not_exist' }
188
-
189
- it do
190
- expect {
191
- subject.load_class(id)
192
- }.to raise_error(described_class::ClassNotFound,"could not find file for #{id.inspect}")
193
- end
194
- end
195
-
196
- context "when the file does not register a module" do
197
- let(:id) { 'no_module' }
198
-
199
- it do
200
- expect {
201
- subject.load_class(id)
202
- }.to raise_error(described_class::ClassNotFound,"file did not register a class: #{path.inspect}")
203
- end
204
- end
205
-
206
- context "when the file registers a module of a different name" do
207
- let(:id) { 'name_mismatch' }
208
- let(:unexpected_id) { 'different_name' }
209
-
210
- it do
211
- expect {
212
- subject.load_class(id)
213
- }.to raise_error(described_class::ClassNotFound,"file registered a class with a different id (#{unexpected_id.inspect}): #{path.inspect}")
214
- end
215
-
216
-
217
- end
218
-
219
- after do
220
- subject.registry.clear
221
- $LOADED_FEATURES.delete(path)
222
- end
223
- end
224
- end
@@ -1,113 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/core/cli/command_shell/command'
3
-
4
- describe Ronin::Core::CLI::CommandShell::Command do
5
- let(:name) { :foo }
6
- let(:usage) { 'ARG1 [ARG2]' }
7
- let(:completions) { %w[arg1 arg2] }
8
- let(:summary) { 'Foo bar baz' }
9
- let(:help) do
10
- [
11
- "Foo bar baz",
12
- "blah blah blah",
13
- "",
14
- " foo /bar",
15
- ""
16
- ].join($/)
17
- end
18
-
19
- subject do
20
- described_class.new(name, usage: usage,
21
- completions: completions,
22
- summary: summary,
23
- help: help)
24
- end
25
-
26
- describe "#initialize" do
27
- subject { described_class.new(name, summary: summary) }
28
-
29
- it "must set #name" do
30
- expect(subject.name).to eq(name)
31
- end
32
-
33
- it "must default #method_name to name" do
34
- expect(subject.method_name).to eq(name)
35
- end
36
-
37
- it "must default #usage to nil" do
38
- expect(subject.usage).to be(nil)
39
- end
40
-
41
- it "must default #completions to nil" do
42
- expect(subject.completions).to be(nil)
43
- end
44
-
45
- it "must default #help to #summary" do
46
- expect(subject.help).to eq(subject.summary)
47
- end
48
-
49
- context "when the method_name: keyword is given" do
50
- let(:method_name) { 'foo2' }
51
-
52
- subject do
53
- described_class.new(name, method_name: method_name,
54
- summary: summary)
55
- end
56
-
57
- it "must override #method_name" do
58
- expect(subject.method_name).to eq(method_name)
59
- end
60
- end
61
-
62
- context "when the usage: keyword is given" do
63
- subject do
64
- described_class.new(name, usage: usage,
65
- summary: summary)
66
- end
67
-
68
- it "must set #usage" do
69
- expect(subject.usage).to eq(usage)
70
- end
71
- end
72
-
73
- context "when the completions: keyword is given" do
74
- subject do
75
- described_class.new(name, usage: usage,
76
- summary: summary,
77
- completions: completions)
78
- end
79
-
80
- it "must set #completions" do
81
- expect(subject.completions).to eq(completions)
82
- end
83
- end
84
-
85
- context "when the help: keyword is given" do
86
- subject do
87
- described_class.new(name, usage: usage,
88
- summary: summary,
89
- help: help)
90
- end
91
-
92
- it "must set #help" do
93
- expect(subject.help).to eq(help)
94
- end
95
- end
96
- end
97
-
98
- describe "#to_s" do
99
- context "when #usage is set" do
100
- it "must return the #name and #usage string" do
101
- expect(subject.to_s).to eq("#{name} #{usage}")
102
- end
103
- end
104
-
105
- context "when #usage is not set" do
106
- subject { described_class.new(name, summary: summary) }
107
-
108
- it "must return the #name as a String" do
109
- expect(subject.to_s).to eq(name.to_s)
110
- end
111
- end
112
- end
113
- end