ronin-core 0.1.0.beta1 → 0.1.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 +1 -0
- data/.yardopts +1 -1
- data/README.md +2 -1
- data/gemspec.yml +1 -1
- data/lib/ronin/core/class_registry.rb +3 -3
- data/lib/ronin/core/cli/command.rb +1 -1
- data/lib/ronin/core/cli/command_shell/command.rb +1 -1
- data/lib/ronin/core/cli/command_shell.rb +2 -2
- data/lib/ronin/core/cli/generator/options/author.rb +1 -1
- data/lib/ronin/core/cli/generator/options/description.rb +1 -1
- data/lib/ronin/core/cli/generator/options/reference.rb +1 -1
- data/lib/ronin/core/cli/generator/options/summary.rb +1 -1
- data/lib/ronin/core/cli/generator.rb +1 -1
- data/lib/ronin/core/cli/logging.rb +1 -1
- data/lib/ronin/core/cli/options/param.rb +1 -1
- data/lib/ronin/core/cli/options/values/arches.rb +1 -1
- data/lib/ronin/core/cli/options/values/oses.rb +1 -1
- data/lib/ronin/core/cli/printing/arch.rb +1 -1
- data/lib/ronin/core/cli/printing/metadata.rb +2 -2
- data/lib/ronin/core/cli/printing/os.rb +1 -1
- data/lib/ronin/core/cli/printing/params.rb +1 -1
- data/lib/ronin/core/cli/ruby_shell.rb +1 -1
- data/lib/ronin/core/cli/shell.rb +2 -2
- data/lib/ronin/core/git.rb +1 -1
- data/lib/ronin/core/home.rb +1 -1
- data/lib/ronin/core/metadata/authors/author.rb +1 -1
- data/lib/ronin/core/metadata/authors.rb +1 -1
- data/lib/ronin/core/metadata/description.rb +1 -1
- data/lib/ronin/core/metadata/id.rb +1 -1
- data/lib/ronin/core/metadata/references.rb +1 -1
- data/lib/ronin/core/metadata/summary.rb +1 -1
- data/lib/ronin/core/metadata/version.rb +1 -1
- data/lib/ronin/core/params/exceptions.rb +1 -1
- data/lib/ronin/core/params/mixin.rb +2 -2
- data/lib/ronin/core/params/param.rb +2 -2
- data/lib/ronin/core/params/types/boolean.rb +1 -1
- data/lib/ronin/core/params/types/enum.rb +1 -1
- data/lib/ronin/core/params/types/float.rb +1 -1
- data/lib/ronin/core/params/types/integer.rb +1 -1
- data/lib/ronin/core/params/types/numeric.rb +1 -1
- data/lib/ronin/core/params/types/regexp.rb +1 -1
- data/lib/ronin/core/params/types/string.rb +1 -1
- data/lib/ronin/core/params/types/type.rb +1 -1
- data/lib/ronin/core/params/types/uri.rb +1 -1
- data/lib/ronin/core/params/types.rb +1 -1
- data/lib/ronin/core/params.rb +1 -1
- data/lib/ronin/core/version.rb +2 -2
- data/ronin-core.gemspec +2 -1
- metadata +4 -90
- data/spec/class_registry_spec.rb +0 -224
- data/spec/cli/command_shell/command_spec.rb +0 -113
- data/spec/cli/command_shell_spec.rb +0 -1114
- data/spec/cli/command_spec.rb +0 -16
- data/spec/cli/fixtures/irb_command +0 -8
- data/spec/cli/fixtures/template/dir/file1.txt +0 -1
- data/spec/cli/fixtures/template/dir/file2.txt +0 -1
- data/spec/cli/fixtures/template/file.erb +0 -1
- data/spec/cli/fixtures/template/file.txt +0 -1
- data/spec/cli/generator/options/author_spec.rb +0 -121
- data/spec/cli/generator/options/description_spec.rb +0 -45
- data/spec/cli/generator/options/reference_spec.rb +0 -53
- data/spec/cli/generator/options/summary_spec.rb +0 -45
- data/spec/cli/generator_spec.rb +0 -244
- data/spec/cli/logging_spec.rb +0 -95
- data/spec/cli/options/param_spec.rb +0 -67
- data/spec/cli/options/values/arches_spec.rb +0 -62
- data/spec/cli/printing/arch_spec.rb +0 -130
- data/spec/cli/printing/metadata_spec.rb +0 -211
- data/spec/cli/printing/os_spec.rb +0 -64
- data/spec/cli/printing/params_spec.rb +0 -63
- data/spec/cli/ruby_shell.rb +0 -99
- data/spec/cli/shell_spec.rb +0 -211
- data/spec/fixtures/example_class_registry/base_class.rb +0 -9
- data/spec/fixtures/example_class_registry/classes/loaded_class.rb +0 -9
- data/spec/fixtures/example_class_registry/classes/name_mismatch.rb +0 -9
- data/spec/fixtures/example_class_registry/classes/no_module.rb +0 -4
- data/spec/fixtures/example_class_registry.rb +0 -8
- data/spec/git_spec.rb +0 -58
- data/spec/home_spec.rb +0 -64
- data/spec/metadata/authors/author_spec.rb +0 -335
- data/spec/metadata/authors_spec.rb +0 -126
- data/spec/metadata/description_spec.rb +0 -74
- data/spec/metadata/id_spec.rb +0 -92
- data/spec/metadata/references_spec.rb +0 -100
- data/spec/metadata/summary_spec.rb +0 -74
- data/spec/metadata/version_spec.rb +0 -72
- data/spec/params/mixin_spec.rb +0 -484
- data/spec/params/param_spec.rb +0 -164
- data/spec/params/types/boolean_spec.rb +0 -56
- data/spec/params/types/enum_spec.rb +0 -94
- data/spec/params/types/float_spec.rb +0 -107
- data/spec/params/types/integer_spec.rb +0 -155
- data/spec/params/types/numeric_spec.rb +0 -138
- data/spec/params/types/regexp_spec.rb +0 -64
- data/spec/params/types/string_spec.rb +0 -174
- data/spec/params/types/type_spec.rb +0 -14
- data/spec/params/types/uri_spec.rb +0 -62
- data/spec/spec_helper.rb +0 -11
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'ronin/core/params/types/string'
|
|
3
|
-
|
|
4
|
-
describe Ronin::Core::Params::Types::String do
|
|
5
|
-
describe "#initialize" do
|
|
6
|
-
it "must default #allow_empty? to false" do
|
|
7
|
-
expect(subject.allow_empty?).to be(false)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it "must default #allow_blank? to false" do
|
|
11
|
-
expect(subject.allow_blank?).to be(false)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "must default #format to nil" do
|
|
15
|
-
expect(subject.format).to be(nil)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "when given the format: keyword argument" do
|
|
19
|
-
let(:format) { /foo/ }
|
|
20
|
-
|
|
21
|
-
subject { described_class.new(format: format) }
|
|
22
|
-
|
|
23
|
-
it "must set #format" do
|
|
24
|
-
expect(subject.format).to eq(format)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
describe "#allow_empty?" do
|
|
30
|
-
context "when initialized with allow_empty: true" do
|
|
31
|
-
subject { described_class.new(allow_empty: true) }
|
|
32
|
-
|
|
33
|
-
it "must return true" do
|
|
34
|
-
expect(subject.allow_empty?).to be(true)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
context "when initialized with allow_empty: false" do
|
|
39
|
-
subject { described_class.new(allow_empty: false) }
|
|
40
|
-
|
|
41
|
-
it "must return false" do
|
|
42
|
-
expect(subject.allow_empty?).to be(false)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
describe "#allow_blank?" do
|
|
48
|
-
context "when initialized with allow_blank: true" do
|
|
49
|
-
subject { described_class.new(allow_blank: true) }
|
|
50
|
-
|
|
51
|
-
it "must return true" do
|
|
52
|
-
expect(subject.allow_blank?).to be(true)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context "when initialized with allow_blank: false" do
|
|
57
|
-
subject { described_class.new(allow_blank: false) }
|
|
58
|
-
|
|
59
|
-
it "must return false" do
|
|
60
|
-
expect(subject.allow_blank?).to be(false)
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
describe "#coerce" do
|
|
66
|
-
context "when given an Enumerable" do
|
|
67
|
-
let(:value) { ["foo", "bar"] }
|
|
68
|
-
|
|
69
|
-
it do
|
|
70
|
-
expect {
|
|
71
|
-
subject.coerce(value)
|
|
72
|
-
}.to raise_error(Ronin::Core::Params::ValidationError,"cannot convert an Enumerable into a String (#{value.inspect})")
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
context "when given a String" do
|
|
77
|
-
let(:value) { "foo" }
|
|
78
|
-
|
|
79
|
-
it "must return the String" do
|
|
80
|
-
expect(subject.coerce(value)).to eq(value)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
context "but when #format is set" do
|
|
84
|
-
subject { described_class.new(format: /foo/) }
|
|
85
|
-
|
|
86
|
-
context "and the given value matches #format" do
|
|
87
|
-
it "must return the String value" do
|
|
88
|
-
expect(subject.coerce(value)).to eq(value)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
context "but the given value does not match #format" do
|
|
93
|
-
let(:value) { "bar" }
|
|
94
|
-
|
|
95
|
-
it do
|
|
96
|
-
expect {
|
|
97
|
-
subject.coerce(value)
|
|
98
|
-
}.to raise_error(Ronin::Core::Params::ValidationError,"does not match the format (#{value.inspect})")
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
context "but the string is empty" do
|
|
104
|
-
let(:value) { "" }
|
|
105
|
-
|
|
106
|
-
it do
|
|
107
|
-
expect {
|
|
108
|
-
subject.coerce(value)
|
|
109
|
-
}.to raise_error(Ronin::Core::Params::ValidationError,"value cannot be empty")
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
context "and when initialized with allow_empty: true" do
|
|
113
|
-
subject { described_class.new(allow_empty: true) }
|
|
114
|
-
|
|
115
|
-
it "must return the empty String" do
|
|
116
|
-
expect(subject.coerce(value)).to eq(value)
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
context "but the String is all whitespace" do
|
|
122
|
-
let(:value) { " \t\n\r" }
|
|
123
|
-
|
|
124
|
-
it do
|
|
125
|
-
expect {
|
|
126
|
-
subject.coerce(value)
|
|
127
|
-
}.to raise_error(Ronin::Core::Params::ValidationError,"value cannot contain all whitespace (#{value.inspect})")
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
context "and when initialized with allow_blank: true" do
|
|
131
|
-
subject { described_class.new(allow_blank: true) }
|
|
132
|
-
|
|
133
|
-
it "must return the blank String" do
|
|
134
|
-
expect(subject.coerce(value)).to eq(value)
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
context "when given a non-String object" do
|
|
141
|
-
context "and it defines a #to_s method" do
|
|
142
|
-
module TestTypesString
|
|
143
|
-
class ObjectWithToS
|
|
144
|
-
def to_s
|
|
145
|
-
"foo"
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
let(:value) { TestTypesString::ObjectWithToS.new }
|
|
151
|
-
|
|
152
|
-
it "must call #to_s on the value" do
|
|
153
|
-
expect(subject.coerce(value)).to eq(value.to_s)
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
context "but it does not respond to #to_s" do
|
|
158
|
-
module TestTypesString
|
|
159
|
-
class ObjectWithoutToS
|
|
160
|
-
undef to_s
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
let(:value) { TestTypesString::ObjectWithoutToS.new }
|
|
165
|
-
|
|
166
|
-
it do
|
|
167
|
-
expect {
|
|
168
|
-
subject.coerce(value)
|
|
169
|
-
}.to raise_error(Ronin::Core::Params::ValidationError,"value does not define a #to_s method (#{value.inspect})")
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
end
|
|
174
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'ronin/core/params/types/type'
|
|
3
|
-
|
|
4
|
-
describe Ronin::Core::Params::Types::Type do
|
|
5
|
-
describe "#corece" do
|
|
6
|
-
let(:value) { Object.new }
|
|
7
|
-
|
|
8
|
-
it do
|
|
9
|
-
expect {
|
|
10
|
-
subject.coerce(value)
|
|
11
|
-
}.to raise_error(NotImplementedError,"#{described_class}#coerce method was not implemented")
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'ronin/core/params/types/uri'
|
|
3
|
-
|
|
4
|
-
describe Ronin::Core::Params::Types::URI do
|
|
5
|
-
describe "#coerce" do
|
|
6
|
-
context "when given a Regexp value" do
|
|
7
|
-
let(:value) { URI('https://example.com/') }
|
|
8
|
-
|
|
9
|
-
it "must return the Regexp" do
|
|
10
|
-
expect(subject.coerce(value)).to eq(value)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
context "when given a String value" do
|
|
15
|
-
let(:value) { "https://example.com/" }
|
|
16
|
-
|
|
17
|
-
it "must parse the String as a URI" do
|
|
18
|
-
expect(subject.coerce(value)).to eq(URI.parse(value))
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
context "but the String is empty" do
|
|
22
|
-
let(:value) { "" }
|
|
23
|
-
|
|
24
|
-
it do
|
|
25
|
-
expect {
|
|
26
|
-
subject.coerce(value)
|
|
27
|
-
}.to raise_error(Ronin::Core::Params::ValidationError,"value must not be empty")
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context "but the String does not start with a 'scheme:'" do
|
|
32
|
-
let(:value) { "foo" }
|
|
33
|
-
|
|
34
|
-
it do
|
|
35
|
-
expect {
|
|
36
|
-
subject.coerce(value)
|
|
37
|
-
}.to raise_error(Ronin::Core::Params::ValidationError,"value must start with a 'scheme:' (#{value.inspect})")
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
context "but the String cannot be parsed as a valid URI" do
|
|
42
|
-
let(:value) { "https:// \n" }
|
|
43
|
-
|
|
44
|
-
it do
|
|
45
|
-
expect {
|
|
46
|
-
subject.coerce(value)
|
|
47
|
-
}.to raise_error(Ronin::Core::Params::ValidationError,"value is not a valid URI (#{value.inspect})")
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
context "when given a non-URI and non-String value" do
|
|
53
|
-
let(:value) { Object.new }
|
|
54
|
-
|
|
55
|
-
it do
|
|
56
|
-
expect {
|
|
57
|
-
subject.coerce(value)
|
|
58
|
-
}.to raise_error(Ronin::Core::Params::ValidationError,"value must be either a String or a URI (#{value.inspect})")
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|