ronin 0.2.2 → 0.2.3
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.
- data/History.txt +53 -0
- data/Manifest.txt +26 -18
- data/README.txt +12 -19
- data/Rakefile +9 -9
- data/TODO.txt +5 -5
- data/lib/ronin/cacheable.rb +246 -0
- data/lib/ronin/database/database.rb +21 -3
- data/lib/ronin/database/exceptions/invalid_config.rb +1 -1
- data/lib/ronin/environment.rb +5 -2
- data/lib/ronin/extensions.rb +2 -0
- data/lib/ronin/{models.rb → extensions/array.rb} +19 -6
- data/lib/ronin/extensions/ip_addr.rb +127 -0
- data/lib/ronin/{objectify/exceptions/object_context_not_found.rb → extensions/kernel.rb} +14 -3
- data/lib/ronin/extensions/uri/query_params.rb +4 -2
- data/lib/ronin/formatting/extensions/binary/integer.rb +6 -0
- data/lib/ronin/formatting/extensions/binary/string.rb +14 -12
- data/lib/ronin/formatting/extensions/text/string.rb +37 -19
- data/lib/ronin/has_license.rb +4 -2
- data/lib/ronin/model.rb +0 -1
- data/lib/ronin/network/extensions/http/net.rb +30 -3
- data/lib/ronin/network/extensions/telnet/net.rb +0 -18
- data/lib/ronin/network/http/exceptions/unknown_request.rb +1 -1
- data/lib/ronin/platform/exceptions/extension_not_found.rb +1 -1
- data/lib/ronin/platform/exceptions/overlay_cached.rb +1 -1
- data/lib/ronin/platform/exceptions/overlay_not_found.rb +1 -1
- data/lib/ronin/platform/extension.rb +18 -3
- data/lib/ronin/platform/extension_cache.rb +7 -1
- data/lib/ronin/platform/object_cache.rb +13 -12
- data/lib/ronin/platform/overlay.rb +14 -6
- data/lib/ronin/platform/overlay_cache.rb +11 -5
- data/lib/ronin/product.rb +20 -3
- data/lib/ronin/ronin.rb +0 -15
- data/lib/ronin/rpc/exceptions/response_missing.rb +1 -1
- data/lib/ronin/sessions/esmtp.rb +1 -10
- data/lib/ronin/{objectify.rb → sessions/exceptions.rb} +3 -3
- data/lib/ronin/{objectify/exceptions/unknown_object_context.rb → sessions/exceptions/variable_missing.rb} +4 -4
- data/lib/ronin/sessions/http.rb +3 -10
- data/lib/ronin/sessions/imap.rb +1 -10
- data/lib/ronin/sessions/pop3.rb +1 -9
- data/lib/ronin/sessions/session.rb +11 -21
- data/lib/ronin/sessions/smtp.rb +1 -10
- data/lib/ronin/sessions/tcp.rb +10 -13
- data/lib/ronin/sessions/telnet.rb +2 -17
- data/lib/ronin/sessions/udp.rb +6 -11
- data/lib/ronin/static/finders.rb +24 -0
- data/lib/ronin/ui/command_line/command_line.rb +41 -21
- data/lib/ronin/ui/command_line/commands/help.rb +7 -3
- data/lib/ronin/ui/command_line/commands/ls.rb +1 -1
- data/lib/ronin/ui/command_line/commands/rm.rb +1 -1
- data/lib/ronin/ui/command_line/exceptions/unknown_command.rb +1 -1
- data/lib/ronin/ui/diagnostics.rb +12 -5
- data/lib/ronin/ui/hexdump/extensions/file.rb +3 -1
- data/lib/ronin/ui/hexdump/hexdump.rb +1 -1
- data/lib/ronin/ui/verbose.rb +14 -0
- data/lib/ronin/version.rb +1 -1
- data/spec/cacheable_spec.rb +150 -0
- data/spec/classes/cacheable_model.rb +15 -0
- data/spec/classes/licensed_model.rb +12 -0
- data/spec/code/classes/thing.rb +13 -0
- data/spec/code/reference_spec.rb +1 -14
- data/spec/extensions/array_spec.rb +34 -0
- data/spec/extensions/ip_addr_spec.rb +44 -0
- data/spec/extensions/kernel_spec.rb +19 -0
- data/spec/extensions/uri/query_params_spec.rb +8 -0
- data/spec/formatting/binary/string_spec.rb +1 -1
- data/spec/formatting/digest/string_spec.rb +84 -0
- data/spec/formatting/http/string_spec.rb +84 -0
- data/spec/formatting/text/string_spec.rb +51 -0
- data/spec/has_license_spec.rb +29 -0
- data/spec/helpers/cacheable.rb +7 -0
- data/spec/helpers/contexts/ronin_cacheable_model.rb +13 -0
- data/spec/helpers/database.rb +5 -0
- data/spec/platform/helpers/overlays/hello/lib/init.rb +1 -0
- data/spec/platform/helpers/overlays/hello/lib/stuff/another_test.rb +6 -0
- data/spec/platform/helpers/overlays/hello/lib/stuff/test.rb +4 -0
- data/spec/platform/overlay_cache_spec.rb +1 -1
- data/spec/platform/overlay_spec.rb +28 -0
- data/spec/product_spec.rb +7 -0
- data/spec/sessions/classes/test_session.rb +11 -0
- data/spec/sessions/classes/uses_test_session.rb +10 -0
- data/spec/sessions/session_spec.rb +13 -44
- data/spec/spec_helper.rb +0 -5
- data/spec/static/{helpers → classes}/static_class.rb +0 -0
- data/spec/static/helpers/static.rb +0 -1
- data/spec/static/static_spec.rb +1 -0
- metadata +44 -35
- data/lib/ronin/objectify/exceptions.rb +0 -25
- data/lib/ronin/objectify/objectify.rb +0 -240
- data/lib/ronin/target.rb +0 -44
- data/lib/ronin/ui/command_line/param_parser.rb +0 -93
- data/spec/formatting/digest_spec.rb +0 -54
- data/spec/formatting/http_spec.rb +0 -53
- data/spec/formatting/text_spec.rb +0 -40
- data/spec/helpers.rb +0 -0
- data/spec/objectify/objectify_spec.rb +0 -31
- data/spec/target_spec.rb +0 -16
- data/spec/ui/command_line/helpers/example_command.rb +0 -21
- data/spec/ui/command_line/param_parser_spec.rb +0 -49
data/spec/spec_helper.rb
CHANGED
|
File without changes
|
data/spec/static/static_spec.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ronin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Postmodern
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-05-06 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -23,64 +23,64 @@ dependencies:
|
|
|
23
23
|
version: 1.2.0
|
|
24
24
|
version:
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
|
-
name:
|
|
26
|
+
name: extlib
|
|
27
27
|
type: :runtime
|
|
28
28
|
version_requirement:
|
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.9.
|
|
33
|
+
version: 0.9.12
|
|
34
34
|
version:
|
|
35
35
|
- !ruby/object:Gem::Dependency
|
|
36
|
-
name:
|
|
36
|
+
name: dm-core
|
|
37
37
|
type: :runtime
|
|
38
38
|
version_requirement:
|
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
40
|
requirements:
|
|
41
41
|
- - ">="
|
|
42
42
|
- !ruby/object:Gem::Version
|
|
43
|
-
version: 0.9.
|
|
43
|
+
version: 0.9.11
|
|
44
44
|
version:
|
|
45
45
|
- !ruby/object:Gem::Dependency
|
|
46
|
-
name:
|
|
46
|
+
name: data_objects
|
|
47
47
|
type: :runtime
|
|
48
48
|
version_requirement:
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: 0.9.
|
|
53
|
+
version: 0.9.11
|
|
54
54
|
version:
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: do_sqlite3
|
|
57
57
|
type: :runtime
|
|
58
58
|
version_requirement:
|
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
|
60
60
|
requirements:
|
|
61
61
|
- - ">="
|
|
62
62
|
- !ruby/object:Gem::Version
|
|
63
|
-
version: 0.9.
|
|
63
|
+
version: 0.9.11
|
|
64
64
|
version:
|
|
65
65
|
- !ruby/object:Gem::Dependency
|
|
66
|
-
name: dm-
|
|
66
|
+
name: dm-types
|
|
67
67
|
type: :runtime
|
|
68
68
|
version_requirement:
|
|
69
69
|
version_requirements: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements:
|
|
71
71
|
- - ">="
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
|
-
version: 0.9.
|
|
73
|
+
version: 0.9.11
|
|
74
74
|
version:
|
|
75
75
|
- !ruby/object:Gem::Dependency
|
|
76
|
-
name: dm-
|
|
76
|
+
name: dm-serializer
|
|
77
77
|
type: :runtime
|
|
78
78
|
version_requirement:
|
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
|
80
80
|
requirements:
|
|
81
81
|
- - ">="
|
|
82
82
|
- !ruby/object:Gem::Version
|
|
83
|
-
version: 0.9.
|
|
83
|
+
version: 0.9.11
|
|
84
84
|
version:
|
|
85
85
|
- !ruby/object:Gem::Dependency
|
|
86
86
|
name: dm-validations
|
|
@@ -90,7 +90,7 @@ dependencies:
|
|
|
90
90
|
requirements:
|
|
91
91
|
- - ">="
|
|
92
92
|
- !ruby/object:Gem::Version
|
|
93
|
-
version: 0.9.
|
|
93
|
+
version: 0.9.11
|
|
94
94
|
version:
|
|
95
95
|
- !ruby/object:Gem::Dependency
|
|
96
96
|
name: dm-predefined
|
|
@@ -110,7 +110,7 @@ dependencies:
|
|
|
110
110
|
requirements:
|
|
111
111
|
- - ">="
|
|
112
112
|
- !ruby/object:Gem::Version
|
|
113
|
-
version: 0.1.
|
|
113
|
+
version: 0.1.1
|
|
114
114
|
version:
|
|
115
115
|
- !ruby/object:Gem::Dependency
|
|
116
116
|
name: parameters
|
|
@@ -120,7 +120,7 @@ dependencies:
|
|
|
120
120
|
requirements:
|
|
121
121
|
- - ">="
|
|
122
122
|
- !ruby/object:Gem::Version
|
|
123
|
-
version: 0.1.
|
|
123
|
+
version: 0.1.5
|
|
124
124
|
version:
|
|
125
125
|
- !ruby/object:Gem::Dependency
|
|
126
126
|
name: contextify
|
|
@@ -160,7 +160,7 @@ dependencies:
|
|
|
160
160
|
requirements:
|
|
161
161
|
- - ">="
|
|
162
162
|
- !ruby/object:Gem::Version
|
|
163
|
-
version: 1.
|
|
163
|
+
version: 1.12.2
|
|
164
164
|
version:
|
|
165
165
|
description: Ronin is a Ruby platform designed for information security and data exploration tasks. Ronin allows for the rapid development and distribution of code over many of the common Source-Code-Management (SCM) systems.
|
|
166
166
|
email:
|
|
@@ -207,12 +207,15 @@ files:
|
|
|
207
207
|
- lib/ronin/extensions.rb
|
|
208
208
|
- lib/ronin/extensions/meta.rb
|
|
209
209
|
- lib/ronin/extensions/meta/object.rb
|
|
210
|
+
- lib/ronin/extensions/kernel.rb
|
|
211
|
+
- lib/ronin/extensions/array.rb
|
|
210
212
|
- lib/ronin/extensions/hash.rb
|
|
211
213
|
- lib/ronin/extensions/uri.rb
|
|
212
214
|
- lib/ronin/extensions/uri/query_params.rb
|
|
213
215
|
- lib/ronin/extensions/uri/http.rb
|
|
214
216
|
- lib/ronin/extensions/string.rb
|
|
215
217
|
- lib/ronin/extensions/file.rb
|
|
218
|
+
- lib/ronin/extensions/ip_addr.rb
|
|
216
219
|
- lib/ronin/formatting.rb
|
|
217
220
|
- lib/ronin/formatting/digest.rb
|
|
218
221
|
- lib/ronin/formatting/binary.rb
|
|
@@ -276,6 +279,8 @@ files:
|
|
|
276
279
|
- lib/ronin/rpc/console.rb
|
|
277
280
|
- lib/ronin/rpc/shell.rb
|
|
278
281
|
- lib/ronin/sessions.rb
|
|
282
|
+
- lib/ronin/sessions/exceptions.rb
|
|
283
|
+
- lib/ronin/sessions/exceptions/variable_missing.rb
|
|
279
284
|
- lib/ronin/sessions/session.rb
|
|
280
285
|
- lib/ronin/sessions/tcp.rb
|
|
281
286
|
- lib/ronin/sessions/udp.rb
|
|
@@ -295,14 +300,8 @@ files:
|
|
|
295
300
|
- lib/ronin/has_license.rb
|
|
296
301
|
- lib/ronin/arch.rb
|
|
297
302
|
- lib/ronin/os.rb
|
|
298
|
-
- lib/ronin/target.rb
|
|
299
303
|
- lib/ronin/product.rb
|
|
300
|
-
- lib/ronin/
|
|
301
|
-
- lib/ronin/objectify/exceptions.rb
|
|
302
|
-
- lib/ronin/objectify/exceptions/object_context_not_found.rb
|
|
303
|
-
- lib/ronin/objectify/exceptions/unknown_object_context.rb
|
|
304
|
-
- lib/ronin/objectify/objectify.rb
|
|
305
|
-
- lib/ronin/models.rb
|
|
304
|
+
- lib/ronin/cacheable.rb
|
|
306
305
|
- lib/ronin/environment.rb
|
|
307
306
|
- lib/ronin/platform.rb
|
|
308
307
|
- lib/ronin/platform/tasks/spec.rb
|
|
@@ -333,7 +332,6 @@ files:
|
|
|
333
332
|
- lib/ronin/ui/command_line/exceptions/unknown_command.rb
|
|
334
333
|
- lib/ronin/ui/command_line/command.rb
|
|
335
334
|
- lib/ronin/ui/command_line/options.rb
|
|
336
|
-
- lib/ronin/ui/command_line/param_parser.rb
|
|
337
335
|
- lib/ronin/ui/command_line/commands/console.rb
|
|
338
336
|
- lib/ronin/ui/command_line/commands/add.rb
|
|
339
337
|
- lib/ronin/ui/command_line/commands/install.rb
|
|
@@ -346,21 +344,27 @@ files:
|
|
|
346
344
|
- lib/ronin/ronin.rb
|
|
347
345
|
- lib/ronin/version.rb
|
|
348
346
|
- tasks/spec.rb
|
|
349
|
-
- spec/helpers.rb
|
|
350
347
|
- spec/spec_helper.rb
|
|
348
|
+
- spec/classes/licensed_model.rb
|
|
349
|
+
- spec/classes/cacheable_model.rb
|
|
350
|
+
- spec/helpers/database.rb
|
|
351
|
+
- spec/helpers/cacheable.rb
|
|
352
|
+
- spec/helpers/contexts/ronin_cacheable_model.rb
|
|
353
|
+
- spec/static/classes/static_class.rb
|
|
351
354
|
- spec/static/helpers/static1/one.txt
|
|
352
355
|
- spec/static/helpers/static1/dir/two.txt
|
|
353
356
|
- spec/static/helpers/static2/dir/two.txt
|
|
354
357
|
- spec/static/helpers/static.rb
|
|
355
|
-
- spec/static/helpers/static_class.rb
|
|
356
358
|
- spec/static/finders_spec.rb
|
|
357
359
|
- spec/static/static_spec.rb
|
|
358
360
|
- spec/arch_spec.rb
|
|
359
361
|
- spec/author_spec.rb
|
|
360
362
|
- spec/translators/translator_spec.rb
|
|
361
|
-
- spec/
|
|
363
|
+
- spec/extensions/kernel_spec.rb
|
|
364
|
+
- spec/extensions/array_spec.rb
|
|
362
365
|
- spec/extensions/hash_spec.rb
|
|
363
366
|
- spec/extensions/string_spec.rb
|
|
367
|
+
- spec/extensions/ip_addr_spec.rb
|
|
364
368
|
- spec/extensions/uri/http_spec.rb
|
|
365
369
|
- spec/extensions/uri/query_params_spec.rb
|
|
366
370
|
- spec/formatting/binary/helpers/hexdumps.rb
|
|
@@ -386,16 +390,20 @@ files:
|
|
|
386
390
|
- spec/formatting/binary/helpers/hexdumps/od_repeated.txt
|
|
387
391
|
- spec/formatting/binary/integer_spec.rb
|
|
388
392
|
- spec/formatting/binary/string_spec.rb
|
|
389
|
-
- spec/formatting/
|
|
390
|
-
- spec/formatting/
|
|
391
|
-
- spec/formatting/
|
|
393
|
+
- spec/formatting/digest/string_spec.rb
|
|
394
|
+
- spec/formatting/http/string_spec.rb
|
|
395
|
+
- spec/formatting/text/string_spec.rb
|
|
396
|
+
- spec/code/classes/thing.rb
|
|
392
397
|
- spec/code/reference_spec.rb
|
|
393
398
|
- spec/code/symbol_table_spec.rb
|
|
394
399
|
- spec/license_spec.rb
|
|
400
|
+
- spec/has_license_spec.rb
|
|
395
401
|
- spec/path_spec.rb
|
|
396
402
|
- spec/os_spec.rb
|
|
397
403
|
- spec/product_spec.rb
|
|
398
|
-
- spec/
|
|
404
|
+
- spec/cacheable_spec.rb
|
|
405
|
+
- spec/sessions/classes/test_session.rb
|
|
406
|
+
- spec/sessions/classes/uses_test_session.rb
|
|
399
407
|
- spec/sessions/session_spec.rb
|
|
400
408
|
- spec/platform/helpers/overlays.rb
|
|
401
409
|
- spec/platform/helpers/overlays.yaml.erb
|
|
@@ -404,6 +412,9 @@ files:
|
|
|
404
412
|
- spec/platform/helpers/overlays/test2/ronin.xml
|
|
405
413
|
- spec/platform/helpers/overlays/test2/test/extension.rb
|
|
406
414
|
- spec/platform/helpers/overlays/hello/ronin.xml
|
|
415
|
+
- spec/platform/helpers/overlays/hello/lib/init.rb
|
|
416
|
+
- spec/platform/helpers/overlays/hello/lib/stuff/test.rb
|
|
417
|
+
- spec/platform/helpers/overlays/hello/lib/stuff/another_test.rb
|
|
407
418
|
- spec/platform/helpers/overlays/hello/hello/extension.rb
|
|
408
419
|
- spec/platform/helpers/overlays/random/ronin.xml
|
|
409
420
|
- spec/platform/helpers/overlays/random/random/extension.rb
|
|
@@ -414,8 +425,6 @@ files:
|
|
|
414
425
|
- spec/platform/platform_spec.rb
|
|
415
426
|
- spec/platform/ronin_spec.rb
|
|
416
427
|
- spec/ui/verbose_spec.rb
|
|
417
|
-
- spec/ui/command_line/helpers/example_command.rb
|
|
418
|
-
- spec/ui/command_line/param_parser_spec.rb
|
|
419
428
|
- spec/ronin_spec.rb
|
|
420
429
|
- static/ronin/platform/overlay.xsl
|
|
421
430
|
has_rdoc: true
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
#--
|
|
3
|
-
# Ronin - A Ruby platform designed for information security and data
|
|
4
|
-
# exploration tasks.
|
|
5
|
-
#
|
|
6
|
-
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
7
|
-
#
|
|
8
|
-
# This program is free software; you can redistribute it and/or modify
|
|
9
|
-
# it under the terms of the GNU General Public License as published by
|
|
10
|
-
# the Free Software Foundation; either version 2 of the License, or
|
|
11
|
-
# (at your option) any later version.
|
|
12
|
-
#
|
|
13
|
-
# This program is distributed in the hope that it will be useful,
|
|
14
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
# GNU General Public License for more details.
|
|
17
|
-
#
|
|
18
|
-
# You should have received a copy of the GNU General Public License
|
|
19
|
-
# along with this program; if not, write to the Free Software
|
|
20
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
-
#++
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
require 'ronin/exceptions/unknown_object_context'
|
|
25
|
-
require 'ronin/exceptions/object_context_not_found'
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
#--
|
|
3
|
-
# Ronin - A Ruby platform designed for information security and data
|
|
4
|
-
# exploration tasks.
|
|
5
|
-
#
|
|
6
|
-
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
7
|
-
#
|
|
8
|
-
# This program is free software; you can redistribute it and/or modify
|
|
9
|
-
# it under the terms of the GNU General Public License as published by
|
|
10
|
-
# the Free Software Foundation; either version 2 of the License, or
|
|
11
|
-
# (at your option) any later version.
|
|
12
|
-
#
|
|
13
|
-
# This program is distributed in the hope that it will be useful,
|
|
14
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
# GNU General Public License for more details.
|
|
17
|
-
#
|
|
18
|
-
# You should have received a copy of the GNU General Public License
|
|
19
|
-
# along with this program; if not, write to the Free Software
|
|
20
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
-
#++
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
require 'ronin/objectify/exceptions/unknown_object_context'
|
|
25
|
-
require 'ronin/objectify/exceptions/object_context_not_found'
|
|
26
|
-
require 'ronin/extensions/meta'
|
|
27
|
-
require 'ronin/model'
|
|
28
|
-
|
|
29
|
-
require 'contextify'
|
|
30
|
-
require 'parameters'
|
|
31
|
-
|
|
32
|
-
module Ronin
|
|
33
|
-
module Objectify
|
|
34
|
-
include DataMapper::Types
|
|
35
|
-
|
|
36
|
-
def self.included(base)
|
|
37
|
-
base.module_eval do
|
|
38
|
-
include Contextify
|
|
39
|
-
include Parameters
|
|
40
|
-
include Ronin::Model
|
|
41
|
-
|
|
42
|
-
# Path to the object context
|
|
43
|
-
property :object_path, String
|
|
44
|
-
|
|
45
|
-
# Modification timestamp of the object context
|
|
46
|
-
property :object_timestamp, EpochTime
|
|
47
|
-
|
|
48
|
-
metaclass_def(:objectify) do |name|
|
|
49
|
-
name = name.to_s
|
|
50
|
-
|
|
51
|
-
self.contextify name
|
|
52
|
-
|
|
53
|
-
Objectify.object_contexts[name] = self
|
|
54
|
-
|
|
55
|
-
meta_def(:load_object) do |path,*attributes|
|
|
56
|
-
Objectify.load_object(self.context_name,path,*attributes)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
meta_def(:cache) do |path,*args|
|
|
60
|
-
load_object(path,*args).cache
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
meta_def(:mirror) do |path,*args|
|
|
64
|
-
path = File.expand_path(path)
|
|
65
|
-
existing_obj = first(:object_path => path)
|
|
66
|
-
|
|
67
|
-
if existing_obj
|
|
68
|
-
return existing_obj.mirror
|
|
69
|
-
else
|
|
70
|
-
return cache(path,*args)
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
meta_def(:search) do |*attribs|
|
|
75
|
-
all(*attribs).map { |obj| obj.load_object }
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# define Ronin-level object loader method
|
|
79
|
-
Ronin.module_eval %{
|
|
80
|
-
def ronin_load_#{name}(path,*args,&block)
|
|
81
|
-
new_obj = #{self}.load_object(path,*args)
|
|
82
|
-
|
|
83
|
-
block.call(new_obj) if block
|
|
84
|
-
return new_obj
|
|
85
|
-
end
|
|
86
|
-
}
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
#
|
|
92
|
-
# Returns the Hash of all defined object-contexts.
|
|
93
|
-
#
|
|
94
|
-
def Objectify.object_contexts
|
|
95
|
-
@@ronin_object_contexts ||= {}
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
#
|
|
99
|
-
# Returns +true+ if there is an object-context defined with the
|
|
100
|
-
# specified _name_, returns +false+ otherwise.
|
|
101
|
-
#
|
|
102
|
-
def Objectify.is_object_context?(name)
|
|
103
|
-
Objectify.object_contexts.has_key?(name.to_sym)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
#
|
|
107
|
-
# Loads the object context of the specified _name_ and from the
|
|
108
|
-
# specified _path_ with the given _attributes_. If no object contexts
|
|
109
|
-
# were defined with the specified _name_, an UnknownObjectContext
|
|
110
|
-
# exception will be raised.
|
|
111
|
-
#
|
|
112
|
-
# Objectify.load_object(:note,'/path/to/my_notes.rb')
|
|
113
|
-
# # => #<Note:...>
|
|
114
|
-
#
|
|
115
|
-
def Objectify.load_object(name,path,*attributes,&block)
|
|
116
|
-
name = name.to_s
|
|
117
|
-
|
|
118
|
-
unless Objectify.is_object_context?(name)
|
|
119
|
-
raise(UnknownObjectContext,"unknown object context #{name.dump}",caller)
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
path = File.expand_path(path)
|
|
123
|
-
|
|
124
|
-
unless File.file?(path)
|
|
125
|
-
raise(ObjectContextNotFound,"object context #{path.dump} does not exist",caller)
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
new_obj = Contextify.load_context(name,path,*attributes)
|
|
129
|
-
new_obj.object_path = path
|
|
130
|
-
|
|
131
|
-
block.call(new_obj) if block
|
|
132
|
-
return new_obj
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
#
|
|
136
|
-
# Loads all object contexts from the specified _path_ returning an
|
|
137
|
-
# +Array+ of loaded object contexts. If a _block_ is given, it will
|
|
138
|
-
# be passed each loaded object context.
|
|
139
|
-
#
|
|
140
|
-
# Objectify.load_contexts('/path/to/misc_contexts.rb') # => [...]
|
|
141
|
-
#
|
|
142
|
-
def Objectify.load_objects(path,&block)
|
|
143
|
-
path = File.expand_path(path)
|
|
144
|
-
|
|
145
|
-
unless File.file?(path)
|
|
146
|
-
raise(ObjectContextNotFound,"object context #{path.dump} does not exist",caller)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
return Contextify.load_contexts(path) do |new_obj|
|
|
150
|
-
new_obj.object_path = path
|
|
151
|
-
|
|
152
|
-
block.call(new_obj) if block
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
#
|
|
157
|
-
# Cache all objects loaded from the specified _path_.
|
|
158
|
-
#
|
|
159
|
-
def Objectify.cache_objects(path)
|
|
160
|
-
Objectify.load_objects(path).each do |obj|
|
|
161
|
-
obj.cache
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
return nil
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
#
|
|
168
|
-
# Loads a new object from the file pointed to by the +object_path+
|
|
169
|
-
# property.
|
|
170
|
-
#
|
|
171
|
-
def load_object
|
|
172
|
-
primary_keys = {}
|
|
173
|
-
|
|
174
|
-
key_properties.each do |prop|
|
|
175
|
-
primary_keys[prop.name] = attribute_get(prop.name)
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
new_obj = self.class.load_object(self.object_path,primary_keys)
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
#
|
|
182
|
-
# Returns +true+ if the file pointed to by the +object_path+
|
|
183
|
-
# property is missing, returns +false+ otherwise.
|
|
184
|
-
#
|
|
185
|
-
def missing?
|
|
186
|
-
if self.object_path
|
|
187
|
-
return !(File.file?(self.object_path))
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
return false
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
#
|
|
194
|
-
# Returns +true+ if the +object_timestamp+ property is older than
|
|
195
|
-
# the modification time on the file pointed to by the +object_path+
|
|
196
|
-
# property, returns +false+ otherwise.
|
|
197
|
-
#
|
|
198
|
-
def stale?
|
|
199
|
-
if self.object_timestamp
|
|
200
|
-
return File.mtime(self.object_path) > self.object_timestamp
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
return false
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
#
|
|
207
|
-
# Sets the +object_timestamp+ property to the modification time of the
|
|
208
|
-
# file pointed to by the +object_path+ property and saves the object.
|
|
209
|
-
#
|
|
210
|
-
def cache
|
|
211
|
-
if self.object_path
|
|
212
|
-
self.object_timestamp = File.mtime(self.object_path)
|
|
213
|
-
return save
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
return false
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
#
|
|
220
|
-
# If the file pointed to by the +object_path+ property is missing, the
|
|
221
|
-
# object will be destroyed. If the object has not been changed and
|
|
222
|
-
# is stale?, a newly loaded object from the file pointed to by the
|
|
223
|
-
# +object_path+ property will be cached.
|
|
224
|
-
#
|
|
225
|
-
def mirror
|
|
226
|
-
if self.object_path
|
|
227
|
-
unless File.file?(self.object_path)
|
|
228
|
-
return destroy
|
|
229
|
-
else
|
|
230
|
-
if (!(dirty?) && stale?)
|
|
231
|
-
destroy
|
|
232
|
-
return load_object.cache
|
|
233
|
-
end
|
|
234
|
-
end
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
return false
|
|
238
|
-
end
|
|
239
|
-
end
|
|
240
|
-
end
|