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
@@ -1,211 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/core/cli/shell'
3
-
4
- describe Ronin::Core::CLI::Shell do
5
- describe ".shell_name" do
6
- subject { shell_class }
7
-
8
- context "and when shell_name is not set in the shell class" do
9
- module TestShell
10
- class ShellWithNoShellName < Ronin::Core::CLI::Shell
11
- end
12
- end
13
-
14
- let(:shell_class) { TestShell::ShellWithNoShellName }
15
-
16
- it "must default to nil" do
17
- expect(subject.shell_name).to be(nil)
18
- end
19
- end
20
-
21
- context "and when shell_name is set in the shell class" do
22
- module TestShell
23
- class ShellWithShellName < Ronin::Core::CLI::Shell
24
- shell_name 'test'
25
- end
26
- end
27
-
28
- let(:shell_class) { TestShell::ShellWithShellName }
29
-
30
- it "must return the set shell_name" do
31
- expect(subject.shell_name).to eq("test")
32
- end
33
- end
34
-
35
- context "but when the shell_name was set in the superclass" do
36
- module TestShell
37
- class ShellThatInheritsItsShellName < ShellWithShellName
38
- end
39
- end
40
-
41
- let(:shell_class) do
42
- TestShell::ShellThatInheritsItsShellName
43
- end
44
-
45
- it "must return the shell_name set in the superclass" do
46
- expect(subject.shell_name).to eq("test")
47
- end
48
-
49
- context "but the shell_name is overridden in the sub-class" do
50
- module TestShell
51
- class ShellThatOverridesItsInheritedShellName < ShellWithShellName
52
- shell_name "test2"
53
- end
54
- end
55
-
56
- let(:shell_class) do
57
- TestShell::ShellThatOverridesItsInheritedShellName
58
- end
59
-
60
- it "must return the shell_name set in the sub-class" do
61
- expect(subject.shell_name).to eq("test2")
62
- end
63
- end
64
- end
65
- end
66
-
67
- describe ".prompt_sigil" do
68
- subject { shell_class }
69
-
70
- context "and when prompt_sigil is not set in the shell class" do
71
- module TestShell
72
- class ShellWithNoPromptSigil < Ronin::Core::CLI::Shell
73
- end
74
- end
75
-
76
- let(:shell_class) { TestShell::ShellWithNoPromptSigil }
77
-
78
- it "must default to '>'" do
79
- expect(subject.prompt_sigil).to eq('>')
80
- end
81
- end
82
-
83
- context "and when prompt_sigil is set in the shell class" do
84
- module TestShell
85
- class ShellWithPromptSigil < Ronin::Core::CLI::Shell
86
- prompt_sigil '$'
87
- end
88
- end
89
-
90
- let(:shell_class) { TestShell::ShellWithPromptSigil }
91
-
92
- it "must return the set prompt_sigil" do
93
- expect(subject.prompt_sigil).to eq("$")
94
- end
95
- end
96
-
97
- context "but when the prompt_sigil was set in the superclass" do
98
- module TestShell
99
- class ShellThatInheritsItsPromptSigil < ShellWithPromptSigil
100
- end
101
- end
102
-
103
- let(:shell_class) do
104
- TestShell::ShellThatInheritsItsPromptSigil
105
- end
106
-
107
- it "must return the prompt_sigil set in the superclass" do
108
- expect(subject.prompt_sigil).to eq("$")
109
- end
110
-
111
- context "but the prompt_sigil is overridden in the sub-class" do
112
- module TestShell
113
- class ShellThatOverridesItsInheritedPromptSigil < ShellWithPromptSigil
114
- prompt_sigil "#"
115
- end
116
- end
117
-
118
- let(:shell_class) do
119
- TestShell::ShellThatOverridesItsInheritedPromptSigil
120
- end
121
-
122
- it "must return the prompt_sigil set in the sub-class" do
123
- expect(subject.prompt_sigil).to eq("#")
124
- end
125
- end
126
- end
127
- end
128
-
129
- module TestShell
130
- class TestShell < Ronin::Core::CLI::Shell
131
- shell_name 'test'
132
- end
133
- end
134
-
135
- let(:shell_class) { TestShell::TestShell }
136
- subject { shell_class.new }
137
-
138
- describe "#initialize" do
139
- context "when no keyword arguments are given" do
140
- it "must default #shell_name to self.class.shell_name" do
141
- expect(subject.shell_name).to eq(shell_class.shell_name)
142
- end
143
-
144
- it "must default #prompt_sigil to self.class.prompt_sigil" do
145
- expect(subject.prompt_sigil).to eq(shell_class.prompt_sigil)
146
- end
147
- end
148
-
149
- context "when the shell_name: keyword argument is given" do
150
- let(:new_shell_name) { 'override' }
151
-
152
- subject { shell_class.new(shell_name: new_shell_name) }
153
-
154
- it "must override #shell_name" do
155
- expect(subject.shell_name).to eq(new_shell_name)
156
- end
157
- end
158
-
159
- context "when the prompt_sigil: keyword argument is given" do
160
- let(:new_prompt_sigil) { '$' }
161
-
162
- subject { shell_class.new(prompt_sigil: new_prompt_sigil) }
163
-
164
- it "must override #prompt_sigil" do
165
- expect(subject.prompt_sigil).to eq(new_prompt_sigil)
166
- end
167
- end
168
- end
169
-
170
- describe "#shell_name" do
171
- it "must return the shell class'es .shell_name" do
172
- expect(subject.shell_name).to eq(shell_class.shell_name)
173
- end
174
- end
175
-
176
- describe "#prompt_sigil" do
177
- it "must return the shell class'es .prompt_sigil" do
178
- expect(subject.prompt_sigil).to eq(shell_class.prompt_sigil)
179
- end
180
- end
181
-
182
- describe "#prompt" do
183
- let(:stdout) { StringIO.new }
184
-
185
- subject { shell_class.new(stdout: stdout) }
186
-
187
- context "when stdout is a TTY" do
188
- before do
189
- allow(subject.stdout).to receive(:tty?).and_return(true)
190
- end
191
-
192
- let(:red) { CommandKit::Colors::ANSI::RED }
193
- let(:bright_red) { CommandKit::Colors::ANSI::BRIGHT_RED }
194
- let(:bold) { CommandKit::Colors::ANSI::BOLD }
195
- let(:reset_intensity) { CommandKit::Colors::ANSI::RESET_INTENSITY }
196
- let(:reset_color) { CommandKit::Colors::ANSI::RESET_COLOR }
197
-
198
- it "must return an ANSI colored prompt" do
199
- expect(subject.prompt).to eq(
200
- "#{red}#{subject.shell_name}#{reset_color}#{bold}#{bright_red}>#{reset_color}#{reset_intensity}"
201
- )
202
- end
203
- end
204
-
205
- context "when stdout is not a TTY" do
206
- it "must return a plain-text prompt" do
207
- expect(subject.prompt).to eq("#{subject.shell_name}>")
208
- end
209
- end
210
- end
211
- end
@@ -1,9 +0,0 @@
1
- module ExampleClassRegistry
2
- class BaseClass
3
-
4
- def self.register(path)
5
- ExampleClassRegistry.register(path,self)
6
- end
7
-
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- require_relative '../base_class'
2
-
3
- module ExampleClassRegistry
4
- class LoadedClass < BaseClass
5
-
6
- register 'loaded_class'
7
-
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- require_relative '../base_class'
2
-
3
- module ExampleClassRegistry
4
- class LoadedModule < BaseClass
5
-
6
- register 'different_name'
7
-
8
- end
9
- end
@@ -1,4 +0,0 @@
1
- module ExampleClassRegistry
2
- class SomeClass
3
- end
4
- end
@@ -1,8 +0,0 @@
1
- require 'ronin/core/class_registry'
2
-
3
- module ExampleClassRegistry
4
-
5
- include Ronin::Core::ClassRegistry
6
- class_dir "#{__dir__}/example_class_registry/classes"
7
-
8
- end
data/spec/git_spec.rb DELETED
@@ -1,58 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/core/git'
3
-
4
- describe Ronin::Core::Git do
5
- describe ".user_name" do
6
- let(:user_name) { 'Foo Bar' }
7
-
8
- it "must execute `git config user.name`" do
9
- expect(subject).to receive(:`).with("git config user.name").and_return("#{user_name}#{$/}")
10
-
11
- expect(subject.user_name).to eq(user_name)
12
- end
13
-
14
- context "when `git config user.name` returns an empty String" do
15
- it "must return nil" do
16
- expect(subject).to receive(:`).with("git config user.name").and_return("")
17
-
18
- expect(subject.user_name).to be(nil)
19
- end
20
- end
21
- end
22
-
23
- describe ".user_email" do
24
- let(:user_email) { 'foo@example.com' }
25
-
26
- it "must execute `git config user.email`" do
27
- expect(subject).to receive(:`).with("git config user.email").and_return("#{user_email}#{$/}")
28
-
29
- expect(subject.user_email).to eq(user_email)
30
- end
31
-
32
- context "when `git config user.email` returns an empty String" do
33
- it "must return nil" do
34
- expect(subject).to receive(:`).with("git config user.email").and_return("")
35
-
36
- expect(subject.user_email).to be(nil)
37
- end
38
- end
39
- end
40
-
41
- describe ".github_user" do
42
- let(:github_user) { 'foo' }
43
-
44
- it "must execute `git config github.user`" do
45
- expect(subject).to receive(:`).with("git config github.user").and_return("#{github_user}#{$/}")
46
-
47
- expect(subject.github_user).to eq(github_user)
48
- end
49
-
50
- context "when `git config github.user` returns an empty String" do
51
- it "must return nil" do
52
- expect(subject).to receive(:`).with("git config github.user").and_return("")
53
-
54
- expect(subject.github_user).to be(nil)
55
- end
56
- end
57
- end
58
- end
data/spec/home_spec.rb DELETED
@@ -1,64 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/core/home'
3
-
4
- describe Ronin::Core::Home do
5
- describe "DIR" do
6
- it "must equal Gem.user_home" do
7
- expect(subject::DIR).to eq(Gem.user_home)
8
- end
9
- end
10
-
11
- describe "CACHE_DIR" do
12
- it "must equal ~/.cache" do
13
- expect(subject::CACHE_DIR).to eq(
14
- File.join(Gem.user_home,'.cache')
15
- )
16
- end
17
- end
18
-
19
- describe ".cache_dir" do
20
- let(:name) { 'foo' }
21
-
22
- it "must join ~/.cache with the given directory name" do
23
- expect(subject.cache_dir(name)).to eq(
24
- File.join(Gem.user_home,'.cache',name)
25
- )
26
- end
27
- end
28
-
29
- describe "CONFIG_DIR" do
30
- it "must equal ~/.config" do
31
- expect(subject::CONFIG_DIR).to eq(
32
- File.join(Gem.user_home,'.config')
33
- )
34
- end
35
- end
36
-
37
- describe ".config_dir" do
38
- let(:name) { 'foo' }
39
-
40
- it "must join ~/.config with the given directory name" do
41
- expect(subject.config_dir(name)).to eq(
42
- File.join(Gem.user_home,'.config',name)
43
- )
44
- end
45
- end
46
-
47
- describe "LOCAL_SHARE" do
48
- it "must equal ~/.local/share" do
49
- expect(subject::LOCAL_SHARE_DIR).to eq(
50
- File.join(Gem.user_home,'.local','share')
51
- )
52
- end
53
- end
54
-
55
- describe ".local_share_dir" do
56
- let(:name) { 'foo' }
57
-
58
- it "must join ~/.local/share with the given directory name" do
59
- expect(subject.local_share_dir(name)).to eq(
60
- File.join(Gem.user_home,'.local','share',name)
61
- )
62
- end
63
- end
64
- end