Module: Ronin::Script::Buildable

Includes:
Testable, UI::Output::Helpers
Defined in:
lib/ronin/script/buildable.rb

Overview

Adds building methods to an Ronin::Script.

Since:

  • 1.1.0

Instance Method Summary collapse

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.

Yields:

  • [] The given block will be called when the script is being built.

Returns:

Since:

  • 1.1.0



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.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options to also use as parameters.

Yields:

  • [] The given block will be called after the script has been built.

See Also:

Since:

  • 1.1.0



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!(options={})
  self.params = options
  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.

Returns:

  • (Boolean)

    Specifies whether the script is built.

Since:

  • 1.1.0



62
63
64
# File 'lib/ronin/script/buildable.rb', line 62

def built?
  @built == true
end

#initialize(attributes = {}) ⇒ Object

Initializes the buildable script.

Parameters:

  • attributes (Hash) (defaults to: {})

    Additional attributes for the script.

Since:

  • 1.1.0



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.

Returns:

  • (true)

    The script has been tested.

Raises:

  • (NotBuilt)

    The script has not been built, and cannot be verified.

See Also:

Since:

  • 1.1.0



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