ronin 1.0.0 → 1.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. data/.yardopts +0 -1
  2. data/ChangeLog.md +67 -3
  3. data/Gemfile +20 -12
  4. data/README.md +3 -5
  5. data/gemspec.yml +5 -5
  6. data/lib/ronin/address.rb +8 -3
  7. data/lib/ronin/arch.rb +39 -14
  8. data/lib/ronin/author.rb +2 -0
  9. data/lib/ronin/auto_load.rb +67 -0
  10. data/lib/ronin/campaign.rb +15 -2
  11. data/lib/ronin/class_methods.rb +7 -1
  12. data/lib/ronin/config.rb +5 -0
  13. data/lib/ronin/credential.rb +14 -3
  14. data/lib/ronin/database/database.rb +38 -12
  15. data/lib/ronin/database/migrations.rb +3 -1
  16. data/lib/ronin/database/migrations/add_created_at_column_to_targets_table.rb +48 -0
  17. data/lib/ronin/database/migrations/add_updated_at_column_to_campaigns_table.rb +47 -0
  18. data/lib/ronin/database/migrations/create_licenses_table.rb +1 -1
  19. data/lib/ronin/database/migrations/create_passwords_table.rb +1 -1
  20. data/lib/ronin/database/migrations/{create_cached_files_table.rb → create_script_paths_table.rb} +4 -4
  21. data/lib/ronin/database/migrations/migration.rb +3 -6
  22. data/lib/ronin/database/migrations/migrations.rb +3 -3
  23. data/lib/ronin/email_address.rb +20 -3
  24. data/lib/ronin/environment.rb +0 -3
  25. data/lib/ronin/host_name.rb +20 -6
  26. data/lib/ronin/host_name_ip_address.rb +2 -3
  27. data/lib/ronin/installation.rb +92 -23
  28. data/lib/ronin/ip_address.rb +31 -8
  29. data/lib/ronin/ip_address_mac_address.rb +2 -3
  30. data/lib/ronin/license.rb +1 -1
  31. data/lib/ronin/mac_address.rb +6 -4
  32. data/lib/ronin/model/class_methods.rb +4 -0
  33. data/lib/ronin/model/has_authors/class_methods.rb +4 -0
  34. data/lib/ronin/model/has_authors/has_authors.rb +4 -0
  35. data/lib/ronin/model/has_description/class_methods.rb +2 -0
  36. data/lib/ronin/model/has_description/has_description.rb +2 -0
  37. data/lib/ronin/model/has_license/class_methods.rb +2 -0
  38. data/lib/ronin/model/has_license/has_license.rb +4 -0
  39. data/lib/ronin/model/has_name/class_methods.rb +2 -0
  40. data/lib/ronin/model/has_name/has_name.rb +4 -0
  41. data/lib/ronin/model/has_title/class_methods.rb +2 -0
  42. data/lib/ronin/model/has_title/has_title.rb +2 -0
  43. data/lib/ronin/model/has_unique_name/class_methods.rb +2 -0
  44. data/lib/ronin/model/has_unique_name/has_unique_name.rb +7 -1
  45. data/lib/ronin/model/has_version/class_methods.rb +4 -0
  46. data/lib/ronin/model/has_version/has_version.rb +2 -0
  47. data/lib/ronin/model/model.rb +2 -0
  48. data/lib/ronin/model/types.rb +1 -7
  49. data/lib/ronin/model/types/description.rb +2 -0
  50. data/lib/ronin/network/mixins/esmtp.rb +40 -25
  51. data/lib/ronin/network/mixins/http.rb +336 -73
  52. data/lib/ronin/network/mixins/imap.rb +38 -25
  53. data/lib/ronin/network/mixins/pop3.rb +34 -21
  54. data/lib/ronin/network/mixins/smtp.rb +40 -25
  55. data/lib/ronin/network/mixins/tcp.rb +66 -41
  56. data/lib/ronin/network/mixins/telnet.rb +43 -30
  57. data/lib/ronin/network/mixins/udp.rb +59 -40
  58. data/lib/ronin/open_port.rb +12 -5
  59. data/lib/ronin/organization.rb +1 -2
  60. data/lib/ronin/os.rb +10 -3
  61. data/lib/ronin/os_guess.rb +2 -3
  62. data/lib/ronin/password.rb +11 -3
  63. data/lib/ronin/port.rb +7 -2
  64. data/lib/ronin/{engine/exceptions/deploy_failed.rb → repositories.rb} +4 -6
  65. data/lib/ronin/repository.rb +110 -37
  66. data/lib/ronin/ronin.rb +4 -3
  67. data/lib/ronin/{engine.rb → script.rb} +2 -1
  68. data/lib/ronin/{engine → script}/buildable.rb +43 -29
  69. data/lib/ronin/script/class_methods.rb +84 -0
  70. data/lib/ronin/{engine → script}/deployable.rb +61 -40
  71. data/lib/ronin/{engine → script}/exceptions.rb +4 -3
  72. data/lib/ronin/script/exceptions/deploy_failed.rb +27 -0
  73. data/lib/ronin/{engine/exceptions/not_built.rb → script/exceptions/exception.rb} +2 -2
  74. data/lib/ronin/{engine/exceptions/verification_failed.rb → script/exceptions/not_built.rb} +4 -2
  75. data/lib/ronin/script/exceptions/test_failed.rb +27 -0
  76. data/lib/ronin/script/instance_methods.rb +217 -0
  77. data/lib/ronin/script/path.rb +277 -0
  78. data/lib/ronin/{engine/engine.rb → script/script.rb} +52 -15
  79. data/lib/ronin/{engine/verifiable.rb → script/testable.rb} +97 -68
  80. data/lib/ronin/service.rb +1 -2
  81. data/lib/ronin/service_credential.rb +1 -2
  82. data/lib/ronin/software.rb +3 -2
  83. data/lib/ronin/spec/database.rb +0 -4
  84. data/lib/ronin/target.rb +11 -3
  85. data/lib/ronin/tcp_port.rb +3 -2
  86. data/lib/ronin/udp_port.rb +2 -0
  87. data/lib/ronin/ui/cli/cli.rb +6 -0
  88. data/lib/ronin/ui/cli/command.rb +48 -12
  89. data/lib/ronin/ui/cli/commands/campaigns.rb +3 -3
  90. data/lib/ronin/ui/cli/commands/console.rb +2 -1
  91. data/lib/ronin/ui/cli/commands/creds.rb +3 -3
  92. data/lib/ronin/ui/cli/commands/database.rb +1 -17
  93. data/lib/ronin/ui/cli/commands/emails.rb +3 -3
  94. data/lib/ronin/ui/cli/commands/hosts.rb +3 -7
  95. data/lib/ronin/ui/cli/commands/ips.rb +3 -7
  96. data/lib/ronin/ui/cli/commands/repos.rb +5 -17
  97. data/lib/ronin/ui/cli/commands/urls.rb +3 -3
  98. data/lib/ronin/ui/cli/model_command.rb +82 -97
  99. data/lib/ronin/ui/cli/resources_command.rb +89 -0
  100. data/lib/ronin/ui/cli/script_command.rb +115 -0
  101. data/lib/ronin/ui/console.rb +17 -3
  102. data/lib/ronin/ui/output/helpers.rb +18 -0
  103. data/lib/ronin/ui/output/output.rb +20 -1
  104. data/lib/ronin/ui/output/terminal/color.rb +10 -0
  105. data/lib/ronin/ui/output/terminal/raw.rb +10 -0
  106. data/lib/ronin/ui/shell.rb +2 -0
  107. data/lib/ronin/url.rb +47 -12
  108. data/lib/ronin/url_query_param.rb +4 -0
  109. data/lib/ronin/url_scheme.rb +3 -3
  110. data/lib/ronin/user_name.rb +2 -0
  111. data/lib/ronin/version.rb +1 -1
  112. data/lib/ronin/web_credential.rb +6 -3
  113. data/spec/arch_spec.rb +3 -3
  114. data/spec/classes/my_script.rb +21 -0
  115. data/spec/helpers/repos/{test1 → installed}/ronin.yml +1 -1
  116. data/spec/helpers/repos/{hello/cache → installed/scripts}/.keep +0 -0
  117. data/spec/helpers/repos/local/lib/init.rb +1 -0
  118. data/spec/helpers/repos/{hello → local}/lib/stuff/another_test.rb +0 -0
  119. data/spec/helpers/repos/{hello → local}/lib/stuff/test.rb +0 -0
  120. data/spec/helpers/repos/{random → local}/ronin.yml +1 -1
  121. data/spec/helpers/repos/{random/cache → local/scripts}/.keep +0 -0
  122. data/spec/helpers/repos/{hello → remote}/ronin.yml +1 -1
  123. data/spec/helpers/repos/remote/scripts/.keep +0 -0
  124. data/spec/helpers/repos/{test2 → scripts}/ronin.yml +0 -0
  125. data/spec/helpers/repos/scripts/scripts/cached/cached.rb +10 -0
  126. data/spec/helpers/repos/scripts/scripts/cached/missing.rb +10 -0
  127. data/spec/helpers/repos/scripts/scripts/cached/modified.rb +10 -0
  128. data/spec/helpers/repos/scripts/scripts/cached/unmodified.rb +10 -0
  129. data/spec/helpers/repos/scripts/scripts/failures/exceptions.rb +11 -0
  130. data/spec/helpers/repos/{test2/cache/cacheable_model → scripts/scripts/failures}/load_errors.rb +3 -1
  131. data/spec/helpers/repos/{test2/cache/cacheable_model → scripts/scripts/failures}/name_errors.rb +1 -0
  132. data/spec/helpers/repos/scripts/scripts/failures/no_method_errors.rb +10 -0
  133. data/spec/helpers/repos/scripts/scripts/failures/syntax_errors.rb +11 -0
  134. data/spec/helpers/repos/scripts/scripts/failures/validation_errors.rb +11 -0
  135. data/spec/helpers/repos/scripts/scripts/my_scripts/test.rb +16 -0
  136. data/spec/model/spec_helper.rb +0 -2
  137. data/spec/repository_spec.rb +61 -81
  138. data/spec/ronin_spec.rb +2 -2
  139. data/spec/{engine → script}/buildable_spec.rb +9 -9
  140. data/spec/script/classes/buildable_class.rb +15 -0
  141. data/spec/script/classes/deployable_class.rb +13 -0
  142. data/spec/{engine/classes/engine_class.rb → script/classes/script_class.rb} +3 -3
  143. data/spec/{engine/classes/verifiable_class.rb → script/classes/testable_class.rb} +5 -5
  144. data/spec/{engine → script}/deployable_spec.rb +10 -10
  145. data/spec/{cached_file_spec.rb → script/path_spec.rb} +33 -72
  146. data/spec/script/script_spec.rb +130 -0
  147. data/spec/script/testable_spec.rb +117 -0
  148. data/spec/spec_helper.rb +15 -13
  149. metadata +114 -139
  150. data/lib/ronin/cached_file.rb +0 -247
  151. data/lib/ronin/engine/class_methods.rb +0 -135
  152. data/lib/ronin/engine/instance_methods.rb +0 -97
  153. data/lib/ronin/model/cacheable.rb +0 -21
  154. data/lib/ronin/model/cacheable/cacheable.rb +0 -273
  155. data/lib/ronin/model/cacheable/class_methods.rb +0 -60
  156. data/lib/ronin/ui/cli/engine_command.rb +0 -106
  157. data/spec/engine/classes/buildable_class.rb +0 -15
  158. data/spec/engine/classes/deployable_class.rb +0 -13
  159. data/spec/engine/engine_spec.rb +0 -55
  160. data/spec/engine/verifiable_spec.rb +0 -117
  161. data/spec/helpers/repos/hello/lib/init.rb +0 -1
  162. data/spec/helpers/repos/test1/cache/cacheable_model/one.rb +0 -15
  163. data/spec/helpers/repos/test2/cache/cacheable_model/exceptions.rb +0 -7
  164. data/spec/helpers/repos/test2/cache/cacheable_model/no_method_errors.rb +0 -9
  165. data/spec/helpers/repos/test2/cache/cacheable_model/syntax_errors.rb +0 -7
  166. data/spec/helpers/repos/test2/cache/cacheable_model/two.rb +0 -15
  167. data/spec/helpers/repos/test2/cache/cacheable_model/validation_errors.rb +0 -9
  168. data/spec/model/cacheable_spec.rb +0 -96
  169. data/spec/model/models/cacheable_model.rb +0 -13
@@ -1,21 +0,0 @@
1
- #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
3
- #
4
- # This file is part of Ronin.
5
- #
6
- # Ronin is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # Ronin is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
- #
19
-
20
- require 'ronin/model/cacheable/class_methods'
21
- require 'ronin/model/cacheable/cacheable'
@@ -1,273 +0,0 @@
1
- #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
3
- #
4
- # This file is part of Ronin.
5
- #
6
- # Ronin is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # Ronin is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
- #
19
-
20
- require 'ronin/model/cacheable/class_methods'
21
- require 'ronin/model/model'
22
- require 'ronin/cached_file'
23
-
24
- require 'object_loader'
25
- require 'set'
26
-
27
- module Ronin
28
- module Model
29
- #
30
- # The {Cacheable} module allows an instance of a {Model} to be cached
31
- # into the local {Database}, to be loaded later on. This is made
32
- # possible by creating a relationship between the model and the
33
- # {CachedFile} model.
34
- #
35
- # Once cached, {Cacheable} models can be quickly queried within the
36
- # {Database}, and a fresh copy of the object can be loaded from the
37
- # file it was originally cached from.
38
- #
39
- # # Making a Model cacheable
40
- #
41
- # In order to make a Model cacheable, one must include the {Cacheable}.
42
- #
43
- # class MyModel
44
- #
45
- # include Ronin::Model::Cacheable
46
- #
47
- # # Primary key of the model
48
- # property :id, Serial
49
- #
50
- # # Title of the model
51
- # property :title, String
52
- #
53
- # # ...
54
- #
55
- # end
56
- #
57
- # # Creating cacheable files
58
- #
59
- # Once a model is made {Cacheable}, it can load instances defined within
60
- # a file:
61
- #
62
- # require 'ronin/my_model'
63
- #
64
- # my_model do
65
- #
66
- # cache do
67
- # self.title = 'My model in a file'
68
- # end
69
- #
70
- # def some_method
71
- # puts 'Even methods can be loaded from the file'
72
- # end
73
- #
74
- # end
75
- #
76
- # The above example shows a typical cacheable file for `MyModel`. The
77
- # file defines the ruby code to evaluate within a new instance of
78
- # `MyModel` within a `my_model` block. Since the contents of the
79
- # `my_model` block is simply evaluated within new instances, once can
80
- # set instance variables or define new methods.
81
- #
82
- # Any cacheable data is set within a `cache` block, so the cacheable
83
- # data is only set before caching.
84
- #
85
- # # Loading cacheable files
86
- #
87
- # Instances can be loaded from cacheable files using the `load_from`
88
- # class method of a cacheable Model.
89
- #
90
- # my_model = MyModel.load_from('path/to/file.rb')
91
- # # => #<MyModel:0x710e0428cde0 @id=nil @title="My model in a file'>
92
- #
93
- # my_model.some_method
94
- # # Even methods can be loaded from the file
95
- # # => nil
96
- #
97
- module Cacheable
98
- @models = Set[]
99
-
100
- def self.included(base)
101
- base.send :include, ObjectLoader, Model
102
- base.send :extend, ClassMethods
103
-
104
- base.module_eval do
105
- # The class-name of the cached object
106
- property :type, DataMapper::Property::Discriminator
107
-
108
- # The cached file of the object
109
- belongs_to :cached_file,
110
- :required => false,
111
- :model => 'Ronin::CachedFile'
112
- end
113
-
114
- CachedFile.has 1, base.relationship_name,
115
- :model => base.name
116
-
117
- @models << base
118
- end
119
-
120
- #
121
- # The models that are cacheable.
122
- #
123
- # @return [Set<Cacheable>]
124
- # Cacheable models.
125
- #
126
- # @since 1.0.0
127
- #
128
- def Cacheable.models
129
- @models
130
- end
131
-
132
- #
133
- # Loads the first cacheable object from a file.
134
- #
135
- # @param [String] path
136
- # The file to load the cacheable object from.
137
- #
138
- # @return [Cacheable]
139
- # The cacheable object.
140
- #
141
- # @raise [RuntimeError]
142
- # There were no cacheable objects defined in the file.
143
- #
144
- # @since 1.0.0
145
- #
146
- def Cacheable.load_from(path)
147
- path = File.expand_path(path)
148
- obj = ObjectLoader.load_objects(path).find do |obj|
149
- obj.class < Cacheable
150
- end
151
-
152
- unless obj
153
- raise(RuntimeError,"No cacheable object defined in #{path.dump}")
154
- end
155
-
156
- obj.instance_variable_set('@original_loaded',true)
157
- obj.cached_file = CachedFile.new(
158
- :path => path,
159
- :timestamp => File.mtime(path),
160
- :model_name => obj.class.to_s
161
- )
162
-
163
- return obj
164
- end
165
-
166
- #
167
- # Initializes the cacheable object.
168
- #
169
- def initialize(*arguments,&block)
170
- @original_loaded = false
171
- @cache_prepared = false
172
-
173
- super(*arguments,&block)
174
- end
175
-
176
- #
177
- # The file the object was cached from.
178
- #
179
- # @return [Pathname]
180
- # The path property from the `cached_file` resource.
181
- #
182
- def cache_path
183
- self.cached_file.path if self.cached_file
184
- end
185
-
186
- #
187
- # Determines if the original code, from the cache file, has been
188
- # loaded into the object.
189
- #
190
- # @return [Boolean]
191
- # Specifies whether the original code has been loaded into the
192
- # object.
193
- #
194
- def original_loaded?
195
- @original_loaded == true
196
- end
197
-
198
- #
199
- # Loads the code from the cached file for the object, and instance
200
- # evaluates it into the object.
201
- #
202
- # @return [Boolean]
203
- # Indicates the original code was successfully loaded.
204
- #
205
- def load_original!
206
- if (cached? && !(original_loaded?))
207
- block = self.class.load_context_block(self.cache_path)
208
-
209
- @original_loaded = true
210
- instance_eval(&block) if block
211
- return true
212
- end
213
-
214
- return false
215
- end
216
-
217
- #
218
- # @return [Boolean]
219
- # Specifies whether the object has been prepared to be cached,
220
- #
221
- def prepared_for_cache?
222
- @cache_prepared == true
223
- end
224
-
225
- #
226
- # Indicates whether the object has been cached.
227
- #
228
- # @return [Boolean]
229
- # Specifies whether the object has been previously cached.
230
- #
231
- def cached?
232
- (saved? && self.cached_file)
233
- end
234
-
235
- protected
236
-
237
- #
238
- # Will call the given block only once, in order to prepare the
239
- # object for caching.
240
- #
241
- # @yield []
242
- # The block will be ran inside the object when the object is to be
243
- # prepared for caching.
244
- #
245
- # @return [Boolean]
246
- # Specifies whether the object was successfully prepared for
247
- # caching.
248
- #
249
- def cache
250
- if (block_given? && !(cached? || prepared_for_cache?))
251
- @cache_prepared = true
252
-
253
- yield
254
- return true
255
- end
256
-
257
- return false
258
- end
259
-
260
- #
261
- # Will load the context from the cached file and attempt to call the
262
- # method again.
263
- #
264
- def method_missing(name,*arguments,&block)
265
- if load_original!
266
- return self.send(name,*arguments,&block)
267
- else
268
- return super(name,*arguments,&block)
269
- end
270
- end
271
- end
272
- end
273
- end
@@ -1,60 +0,0 @@
1
- #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
3
- #
4
- # This file is part of Ronin.
5
- #
6
- # Ronin is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # Ronin is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
- #
19
-
20
- module Ronin
21
- module Model
22
- module Cacheable
23
- module ClassMethods
24
- #
25
- # Loads all objects with the matching attributes.
26
- #
27
- # @param [Hash] attributes
28
- # Attributes to search for.
29
- #
30
- # @since 1.0.0
31
- #
32
- def load_all(attributes={})
33
- resources = all(attributes)
34
- resources.each { |resource| resource.load_original! }
35
-
36
- return resources
37
- end
38
-
39
- #
40
- # Loads the first object with matching attributes.
41
- #
42
- # @param [Hash] attributes
43
- # Attributes to search for.
44
- #
45
- # @return [Cacheable]
46
- # The loaded cached objects.
47
- #
48
- # @since 1.0.0
49
- #
50
- def load_first(attributes={})
51
- if (resource = first(attributes))
52
- resource.load_original!
53
- end
54
-
55
- return resource
56
- end
57
- end
58
- end
59
- end
60
- end
@@ -1,106 +0,0 @@
1
- #
2
- # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
3
- #
4
- # This file is part of Ronin.
5
- #
6
- # Ronin is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # Ronin is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
- #
19
-
20
- require 'ronin/ui/cli/model_command'
21
- require 'ronin/engine'
22
-
23
- module Ronin
24
- module UI
25
- module CLI
26
- #
27
- # A base-command for querying and loading {Engine}s.
28
- #
29
- class EngineCommand < ModelCommand
30
-
31
- class_option :file, :type => :string, :aliases => '-f'
32
-
33
- query_option :name, :type => :string,
34
- :aliases => '-n',
35
- :method => :named
36
-
37
- query_option :describing, :type => :string, :aliases => '-d'
38
-
39
- query_option :version, :type => :string,
40
- :aliases => '-V',
41
- :method => :revision
42
-
43
- query_option :license, :type => :string,
44
- :aliases => '-L',
45
- :method => :licensed_under
46
-
47
- #
48
- # The class to load engines from.
49
- #
50
- # @return [Engine]
51
- # The engine class.
52
- #
53
- # @since 1.0.0
54
- #
55
- def self.engine_class
56
- model
57
- end
58
-
59
- protected
60
-
61
- #
62
- # Defines the class to load engines from.
63
- #
64
- # @param [Engine] engine
65
- # The engine class.
66
- #
67
- # @return [Engine]
68
- # The new engine class.
69
- #
70
- # @raise [ArgumentError]
71
- # The given engine class does not include {Ronin::Engine}.
72
- #
73
- # @since 1.0.0
74
- #
75
- def self.engine_class=(engine)
76
- unless engine.included_modules.include?(Engine)
77
- raise(ArgumentError,"#{engine} does not include Ronin::Engine")
78
- end
79
-
80
- self.model = engine
81
- end
82
-
83
- #
84
- # Loads an engine using the commands options.
85
- #
86
- # @return [Engine, nil]
87
- # The newly loaded engine.
88
- #
89
- # @raise [RuntimeError]
90
- # The engine class did not define the query method for one of the
91
- # query options.
92
- #
93
- # @since 1.0.0
94
- #
95
- def load_engine
96
- if options[:file]
97
- self.class.engine_class.load_from(options[:file])
98
- else
99
- new_query.load_first
100
- end
101
- end
102
-
103
- end
104
- end
105
- end
106
- end