ronin-core 0.1.0.beta1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -0
  3. data/.rubocop.yml +13 -150
  4. data/.yardopts +1 -1
  5. data/ChangeLog.md +9 -1
  6. data/Gemfile +3 -1
  7. data/README.md +2 -1
  8. data/Rakefile +1 -1
  9. data/examples/ruby_shell.rb +5 -0
  10. data/examples/test_shell.rb +41 -0
  11. data/gemspec.yml +1 -1
  12. data/lib/ronin/core/class_registry.rb +18 -13
  13. data/lib/ronin/core/cli/command.rb +12 -12
  14. data/lib/ronin/core/cli/command_shell/command.rb +9 -6
  15. data/lib/ronin/core/cli/command_shell.rb +11 -11
  16. data/lib/ronin/core/cli/generator/options/author.rb +5 -6
  17. data/lib/ronin/core/cli/generator/options/description.rb +3 -3
  18. data/lib/ronin/core/cli/generator/options/reference.rb +3 -3
  19. data/lib/ronin/core/cli/generator/options/summary.rb +3 -3
  20. data/lib/ronin/core/cli/generator.rb +11 -8
  21. data/lib/ronin/core/cli/logging.rb +6 -3
  22. data/lib/ronin/core/cli/options/param.rb +5 -5
  23. data/lib/ronin/core/cli/options/values/arches.rb +3 -3
  24. data/lib/ronin/core/cli/options/values/oses.rb +3 -3
  25. data/lib/ronin/core/cli/printing/arch.rb +3 -3
  26. data/lib/ronin/core/cli/printing/metadata.rb +4 -4
  27. data/lib/ronin/core/cli/printing/os.rb +6 -3
  28. data/lib/ronin/core/cli/printing/params.rb +7 -7
  29. data/lib/ronin/core/cli/ruby_shell.rb +4 -3
  30. data/lib/ronin/core/cli/shell.rb +16 -8
  31. data/lib/ronin/core/git.rb +3 -3
  32. data/lib/ronin/core/home.rb +3 -3
  33. data/lib/ronin/core/metadata/authors/author.rb +6 -3
  34. data/lib/ronin/core/metadata/authors.rb +9 -6
  35. data/lib/ronin/core/metadata/description.rb +9 -6
  36. data/lib/ronin/core/metadata/id.rb +8 -5
  37. data/lib/ronin/core/metadata/references.rb +14 -7
  38. data/lib/ronin/core/metadata/summary.rb +11 -8
  39. data/lib/ronin/core/metadata/version.rb +9 -6
  40. data/lib/ronin/core/params/exceptions.rb +3 -3
  41. data/lib/ronin/core/params/mixin.rb +17 -17
  42. data/lib/ronin/core/params/param.rb +4 -4
  43. data/lib/ronin/core/params/types/boolean.rb +3 -3
  44. data/lib/ronin/core/params/types/enum.rb +8 -4
  45. data/lib/ronin/core/params/types/float.rb +3 -3
  46. data/lib/ronin/core/params/types/integer.rb +3 -3
  47. data/lib/ronin/core/params/types/numeric.rb +4 -4
  48. data/lib/ronin/core/params/types/regexp.rb +3 -3
  49. data/lib/ronin/core/params/types/string.rb +3 -3
  50. data/lib/ronin/core/params/types/type.rb +3 -3
  51. data/lib/ronin/core/params/types/uri.rb +3 -3
  52. data/lib/ronin/core/params/types.rb +7 -4
  53. data/lib/ronin/core/params.rb +3 -3
  54. data/lib/ronin/core/version.rb +4 -4
  55. data/ronin-core.gemspec +7 -4
  56. metadata +5 -90
  57. data/spec/class_registry_spec.rb +0 -224
  58. data/spec/cli/command_shell/command_spec.rb +0 -113
  59. data/spec/cli/command_shell_spec.rb +0 -1114
  60. data/spec/cli/command_spec.rb +0 -16
  61. data/spec/cli/fixtures/irb_command +0 -8
  62. data/spec/cli/fixtures/template/dir/file1.txt +0 -1
  63. data/spec/cli/fixtures/template/dir/file2.txt +0 -1
  64. data/spec/cli/fixtures/template/file.erb +0 -1
  65. data/spec/cli/fixtures/template/file.txt +0 -1
  66. data/spec/cli/generator/options/author_spec.rb +0 -121
  67. data/spec/cli/generator/options/description_spec.rb +0 -45
  68. data/spec/cli/generator/options/reference_spec.rb +0 -53
  69. data/spec/cli/generator/options/summary_spec.rb +0 -45
  70. data/spec/cli/generator_spec.rb +0 -244
  71. data/spec/cli/logging_spec.rb +0 -95
  72. data/spec/cli/options/param_spec.rb +0 -67
  73. data/spec/cli/options/values/arches_spec.rb +0 -62
  74. data/spec/cli/printing/arch_spec.rb +0 -130
  75. data/spec/cli/printing/metadata_spec.rb +0 -211
  76. data/spec/cli/printing/os_spec.rb +0 -64
  77. data/spec/cli/printing/params_spec.rb +0 -63
  78. data/spec/cli/ruby_shell.rb +0 -99
  79. data/spec/cli/shell_spec.rb +0 -211
  80. data/spec/fixtures/example_class_registry/base_class.rb +0 -9
  81. data/spec/fixtures/example_class_registry/classes/loaded_class.rb +0 -9
  82. data/spec/fixtures/example_class_registry/classes/name_mismatch.rb +0 -9
  83. data/spec/fixtures/example_class_registry/classes/no_module.rb +0 -4
  84. data/spec/fixtures/example_class_registry.rb +0 -8
  85. data/spec/git_spec.rb +0 -58
  86. data/spec/home_spec.rb +0 -64
  87. data/spec/metadata/authors/author_spec.rb +0 -335
  88. data/spec/metadata/authors_spec.rb +0 -126
  89. data/spec/metadata/description_spec.rb +0 -74
  90. data/spec/metadata/id_spec.rb +0 -92
  91. data/spec/metadata/references_spec.rb +0 -100
  92. data/spec/metadata/summary_spec.rb +0 -74
  93. data/spec/metadata/version_spec.rb +0 -72
  94. data/spec/params/mixin_spec.rb +0 -484
  95. data/spec/params/param_spec.rb +0 -164
  96. data/spec/params/types/boolean_spec.rb +0 -56
  97. data/spec/params/types/enum_spec.rb +0 -94
  98. data/spec/params/types/float_spec.rb +0 -107
  99. data/spec/params/types/integer_spec.rb +0 -155
  100. data/spec/params/types/numeric_spec.rb +0 -138
  101. data/spec/params/types/regexp_spec.rb +0 -64
  102. data/spec/params/types/string_spec.rb +0 -174
  103. data/spec/params/types/type_spec.rb +0 -14
  104. data/spec/params/types/uri_spec.rb +0 -62
  105. 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
data/spec/spec_helper.rb DELETED
@@ -1,11 +0,0 @@
1
- require 'rspec'
2
- require 'simplecov'
3
- SimpleCov.start
4
-
5
- ENV.delete('XDG_CACHE_HOME')
6
- ENV.delete('XDG_CONFIG_HOME')
7
- ENV.delete('XDG_DATA_HOME')
8
-
9
- require 'ronin/core/version'
10
-
11
- include Ronin