ronin-core 0.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.github/workflows/ruby.yml +41 -0
  4. data/.gitignore +12 -0
  5. data/.rspec +1 -0
  6. data/.rubocop.yml +160 -0
  7. data/.ruby-version +1 -0
  8. data/.yardopts +1 -0
  9. data/COPYING.txt +165 -0
  10. data/ChangeLog.md +11 -0
  11. data/Gemfile +30 -0
  12. data/README.md +299 -0
  13. data/Rakefile +34 -0
  14. data/examples/ruby_shell.rb +11 -0
  15. data/gemspec.yml +28 -0
  16. data/lib/ronin/core/class_registry.rb +246 -0
  17. data/lib/ronin/core/cli/command.rb +87 -0
  18. data/lib/ronin/core/cli/command_shell/command.rb +110 -0
  19. data/lib/ronin/core/cli/command_shell.rb +345 -0
  20. data/lib/ronin/core/cli/generator/options/author.rb +106 -0
  21. data/lib/ronin/core/cli/generator/options/description.rb +54 -0
  22. data/lib/ronin/core/cli/generator/options/reference.rb +60 -0
  23. data/lib/ronin/core/cli/generator/options/summary.rb +54 -0
  24. data/lib/ronin/core/cli/generator.rb +238 -0
  25. data/lib/ronin/core/cli/logging.rb +59 -0
  26. data/lib/ronin/core/cli/options/param.rb +68 -0
  27. data/lib/ronin/core/cli/options/values/arches.rb +45 -0
  28. data/lib/ronin/core/cli/options/values/oses.rb +32 -0
  29. data/lib/ronin/core/cli/printing/arch.rb +71 -0
  30. data/lib/ronin/core/cli/printing/metadata.rb +113 -0
  31. data/lib/ronin/core/cli/printing/os.rb +54 -0
  32. data/lib/ronin/core/cli/printing/params.rb +69 -0
  33. data/lib/ronin/core/cli/ruby_shell.rb +131 -0
  34. data/lib/ronin/core/cli/shell.rb +186 -0
  35. data/lib/ronin/core/git.rb +73 -0
  36. data/lib/ronin/core/home.rb +86 -0
  37. data/lib/ronin/core/metadata/authors/author.rb +241 -0
  38. data/lib/ronin/core/metadata/authors.rb +120 -0
  39. data/lib/ronin/core/metadata/description.rb +100 -0
  40. data/lib/ronin/core/metadata/id.rb +88 -0
  41. data/lib/ronin/core/metadata/references.rb +87 -0
  42. data/lib/ronin/core/metadata/summary.rb +78 -0
  43. data/lib/ronin/core/metadata/version.rb +74 -0
  44. data/lib/ronin/core/params/exceptions.rb +38 -0
  45. data/lib/ronin/core/params/mixin.rb +317 -0
  46. data/lib/ronin/core/params/param.rb +137 -0
  47. data/lib/ronin/core/params/types/boolean.rb +64 -0
  48. data/lib/ronin/core/params/types/enum.rb +107 -0
  49. data/lib/ronin/core/params/types/float.rb +68 -0
  50. data/lib/ronin/core/params/types/integer.rb +100 -0
  51. data/lib/ronin/core/params/types/numeric.rb +106 -0
  52. data/lib/ronin/core/params/types/regexp.rb +67 -0
  53. data/lib/ronin/core/params/types/string.rb +118 -0
  54. data/lib/ronin/core/params/types/type.rb +54 -0
  55. data/lib/ronin/core/params/types/uri.rb +72 -0
  56. data/lib/ronin/core/params/types.rb +62 -0
  57. data/lib/ronin/core/params.rb +19 -0
  58. data/lib/ronin/core/version.rb +24 -0
  59. data/ronin-core.gemspec +59 -0
  60. data/spec/class_registry_spec.rb +224 -0
  61. data/spec/cli/command_shell/command_spec.rb +113 -0
  62. data/spec/cli/command_shell_spec.rb +1114 -0
  63. data/spec/cli/command_spec.rb +16 -0
  64. data/spec/cli/fixtures/irb_command +8 -0
  65. data/spec/cli/fixtures/template/dir/file1.txt +1 -0
  66. data/spec/cli/fixtures/template/dir/file2.txt +1 -0
  67. data/spec/cli/fixtures/template/file.erb +1 -0
  68. data/spec/cli/fixtures/template/file.txt +1 -0
  69. data/spec/cli/generator/options/author_spec.rb +121 -0
  70. data/spec/cli/generator/options/description_spec.rb +45 -0
  71. data/spec/cli/generator/options/reference_spec.rb +53 -0
  72. data/spec/cli/generator/options/summary_spec.rb +45 -0
  73. data/spec/cli/generator_spec.rb +244 -0
  74. data/spec/cli/logging_spec.rb +95 -0
  75. data/spec/cli/options/param_spec.rb +67 -0
  76. data/spec/cli/options/values/arches_spec.rb +62 -0
  77. data/spec/cli/printing/arch_spec.rb +130 -0
  78. data/spec/cli/printing/metadata_spec.rb +211 -0
  79. data/spec/cli/printing/os_spec.rb +64 -0
  80. data/spec/cli/printing/params_spec.rb +63 -0
  81. data/spec/cli/ruby_shell.rb +99 -0
  82. data/spec/cli/shell_spec.rb +211 -0
  83. data/spec/fixtures/example_class_registry/base_class.rb +9 -0
  84. data/spec/fixtures/example_class_registry/classes/loaded_class.rb +9 -0
  85. data/spec/fixtures/example_class_registry/classes/name_mismatch.rb +9 -0
  86. data/spec/fixtures/example_class_registry/classes/no_module.rb +4 -0
  87. data/spec/fixtures/example_class_registry.rb +8 -0
  88. data/spec/git_spec.rb +58 -0
  89. data/spec/home_spec.rb +64 -0
  90. data/spec/metadata/authors/author_spec.rb +335 -0
  91. data/spec/metadata/authors_spec.rb +126 -0
  92. data/spec/metadata/description_spec.rb +74 -0
  93. data/spec/metadata/id_spec.rb +92 -0
  94. data/spec/metadata/references_spec.rb +100 -0
  95. data/spec/metadata/summary_spec.rb +74 -0
  96. data/spec/metadata/version_spec.rb +72 -0
  97. data/spec/params/mixin_spec.rb +484 -0
  98. data/spec/params/param_spec.rb +164 -0
  99. data/spec/params/types/boolean_spec.rb +56 -0
  100. data/spec/params/types/enum_spec.rb +94 -0
  101. data/spec/params/types/float_spec.rb +107 -0
  102. data/spec/params/types/integer_spec.rb +155 -0
  103. data/spec/params/types/numeric_spec.rb +138 -0
  104. data/spec/params/types/regexp_spec.rb +64 -0
  105. data/spec/params/types/string_spec.rb +174 -0
  106. data/spec/params/types/type_spec.rb +14 -0
  107. data/spec/params/types/uri_spec.rb +62 -0
  108. data/spec/spec_helper.rb +11 -0
  109. metadata +252 -0
@@ -0,0 +1,100 @@
1
+ require 'spec_helper'
2
+ require 'ronin/core/metadata/references'
3
+
4
+ describe Ronin::Core::Metadata::References do
5
+ describe ".references" do
6
+ subject { test_class }
7
+
8
+ context "and when references is not set in the class" do
9
+ module TestMetadataReferences
10
+ class WithNoReferencesSet
11
+ include Ronin::Core::Metadata::References
12
+ end
13
+ end
14
+
15
+ let(:test_class) { TestMetadataReferences::WithNoReferencesSet }
16
+
17
+ it "must default to []" do
18
+ expect(subject.references).to eq([])
19
+ end
20
+ end
21
+
22
+ context "and when references is set in the class" do
23
+ module TestMetadataReferences
24
+ class WithReferencesSet
25
+ include Ronin::Core::Metadata::References
26
+
27
+ references [
28
+ 'https://example.com/link1',
29
+ 'https://example.com/link2'
30
+ ]
31
+ end
32
+ end
33
+
34
+ let(:test_class) { TestMetadataReferences::WithReferencesSet }
35
+
36
+ it "must return the set references" do
37
+ expect(subject.references).to eq(
38
+ [
39
+ 'https://example.com/link1',
40
+ 'https://example.com/link2'
41
+ ]
42
+ )
43
+ end
44
+ end
45
+
46
+ context "but when the references was set in the superclass" do
47
+ module TestMetadataReferences
48
+ class InheritsItsReferences < WithReferencesSet
49
+ include Ronin::Core::Metadata::References
50
+ end
51
+ end
52
+
53
+ let(:test_class) { TestMetadataReferences::InheritsItsReferences }
54
+
55
+ it "must return the references set in the superclass" do
56
+ expect(subject.references).to eq(
57
+ [
58
+ 'https://example.com/link1',
59
+ 'https://example.com/link2'
60
+ ]
61
+ )
62
+ end
63
+
64
+ context "but the references is overridden in the sub-class" do
65
+ module TestMetadataReferences
66
+ class OverridesItsInheritedReferences < WithReferencesSet
67
+ include Ronin::Core::Metadata::References
68
+
69
+ references [
70
+ 'https://example.com/link3'
71
+ ]
72
+ end
73
+ end
74
+
75
+ let(:test_class) do
76
+ TestMetadataReferences::OverridesItsInheritedReferences
77
+ end
78
+
79
+ it "must return the references in the sub-class and the superclass" do
80
+ expect(subject.references).to eq(
81
+ [
82
+ 'https://example.com/link1',
83
+ 'https://example.com/link2',
84
+ 'https://example.com/link3'
85
+ ]
86
+ )
87
+ end
88
+
89
+ it "must not modify the superclass'es references" do
90
+ expect(subject.superclass.references).to eq(
91
+ [
92
+ 'https://example.com/link1',
93
+ 'https://example.com/link2'
94
+ ]
95
+ )
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+ require 'ronin/core/metadata/summary'
3
+
4
+ describe Ronin::Core::Metadata::Summary do
5
+ describe ".summary" do
6
+ subject { test_class }
7
+
8
+ context "and when summary is not set in the class" do
9
+ module TestMetadataSummary
10
+ class WithNoSummarySet
11
+ include Ronin::Core::Metadata::Summary
12
+ end
13
+ end
14
+
15
+ let(:test_class) { TestMetadataSummary::WithNoSummarySet }
16
+
17
+ it "must default to nil" do
18
+ expect(subject.summary).to be(nil)
19
+ end
20
+ end
21
+
22
+ context "and when summary is set in the class" do
23
+ module TestMetadataSummary
24
+ class WithSummarySet
25
+ include Ronin::Core::Metadata::Summary
26
+
27
+ summary 'test'
28
+ end
29
+ end
30
+
31
+ let(:test_class) { TestMetadataSummary::WithSummarySet }
32
+
33
+ it "must return the set summary" do
34
+ expect(subject.summary).to eq("test")
35
+ end
36
+ end
37
+
38
+ context "but when the summary was set in the superclass" do
39
+ module TestMetadataSummary
40
+ class InheritsItsSummary < WithSummarySet
41
+ include Ronin::Core::Metadata::Summary
42
+ end
43
+ end
44
+
45
+ let(:test_class) { TestMetadataSummary::InheritsItsSummary }
46
+
47
+ it "must return the summary set in the superclass" do
48
+ expect(subject.summary).to eq("test")
49
+ end
50
+
51
+ context "but the summary is overridden in the sub-class" do
52
+ module TestMetadataSummary
53
+ class OverridesItsInheritedSummary < WithSummarySet
54
+ include Ronin::Core::Metadata::Summary
55
+
56
+ summary "test2"
57
+ end
58
+ end
59
+
60
+ let(:test_class) do
61
+ TestMetadataSummary::OverridesItsInheritedSummary
62
+ end
63
+
64
+ it "must return the summary set in the sub-class" do
65
+ expect(subject.summary).to eq("test2")
66
+ end
67
+
68
+ it "must not modify the superclass'es summary" do
69
+ expect(subject.superclass.summary).to eq('test')
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+ require 'ronin/core/metadata/version'
3
+
4
+ describe Ronin::Core::Metadata::Version do
5
+ module TestMetadataVersion
6
+ class WithNoVersionSet
7
+ include Ronin::Core::Metadata::Version
8
+ end
9
+
10
+ class WithVersionSet
11
+ include Ronin::Core::Metadata::Version
12
+
13
+ version '0.1'
14
+ end
15
+ end
16
+
17
+ describe ".version" do
18
+ subject { test_class }
19
+
20
+ context "and when version is not set in the class" do
21
+ let(:test_class) { TestMetadataVersion::WithNoVersionSet }
22
+
23
+ it "must default to nil" do
24
+ expect(subject.version).to be(nil)
25
+ end
26
+ end
27
+
28
+ context "and when version is set in the class" do
29
+ let(:test_class) { TestMetadataVersion::WithVersionSet }
30
+
31
+ it "must return the set version" do
32
+ expect(subject.version).to eq("0.1")
33
+ end
34
+ end
35
+
36
+ context "but when the version was set in the superclass" do
37
+ module TestMetadataVersion
38
+ class InheritsItsVersion < WithVersionSet
39
+ include Ronin::Core::Metadata::Version
40
+ end
41
+ end
42
+
43
+ let(:test_class) { TestMetadataVersion::InheritsItsVersion }
44
+
45
+ it "must return nil" do
46
+ expect(subject.version).to be(nil)
47
+ end
48
+
49
+ context "but the version is overrversionden in the sub-class" do
50
+ module TestMetadataVersion
51
+ class OverrversionesItsInheritedVersion < WithVersionSet
52
+ include Ronin::Core::Metadata::Version
53
+
54
+ version '0.2'
55
+ end
56
+ end
57
+
58
+ let(:test_class) do
59
+ TestMetadataVersion::OverrversionesItsInheritedVersion
60
+ end
61
+
62
+ it "must return the version set in the sub-class" do
63
+ expect(subject.version).to eq("0.2")
64
+ end
65
+
66
+ it "must not modify the superclass'es version" do
67
+ expect(subject.superclass.version).to eq('0.1')
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end