Module: Ronin::Script::Buildable
- Includes:
- Testable, UI::Output::Helpers
- Defined in:
- lib/ronin/script/buildable.rb
Overview
Adds building methods to an Ronin::Script.
Instance Method Summary collapse
-
#build { ... } ⇒ Script
protected
Registers a given block to be called when the script is built.
-
#build!(options = {}) { ... } ⇒ Object
Builds the script.
-
#built? ⇒ Boolean
Determines whether the script has been built.
-
#initialize(attributes = {}) ⇒ Object
Initializes the buildable script.
-
#test! ⇒ true
Tests that the script has been built and is properly configured.
Methods included from Testable
#flunk, #test, #test?, #test_equal, #test_in, #test_match, #test_no_match, #test_not_equal, #test_not_in, #test_set
Instance Method Details
#build { ... } ⇒ Script (protected)
Registers a given block to be called when the script is built.
135 136 137 138 |
# File 'lib/ronin/script/buildable.rb', line 135 def build(&block) @build_blocks << block return self end |
#build!(options = {}) { ... } ⇒ Object
Builds the script.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/ronin/script/buildable.rb', line 81 def build!(={}) self.params = print_debug "#{script_type} #{self} parameters: #{self.params.inspect}" print_info "Building #{script_type} #{self} ..." @built = false @build_blocks.each { |block| block.call() } @built = true print_info "#{script_type} #{self} built!" yield if block_given? return self end |
#built? ⇒ Boolean
Determines whether the script has been built.
62 63 64 |
# File 'lib/ronin/script/buildable.rb', line 62 def built? @built == true end |
#initialize(attributes = {}) ⇒ Object
Initializes the buildable script.
45 46 47 48 49 50 |
# File 'lib/ronin/script/buildable.rb', line 45 def initialize(attributes={}) super(attributes) @build_blocks = [] @built = false end |
#test! ⇒ true
Tests that the script has been built and is properly configured.
112 113 114 115 116 117 118 |
# File 'lib/ronin/script/buildable.rb', line 112 def test! unless built? raise(NotBuilt,"cannot verify an unbuilt #{script_type}") end super end |