Class: Ncrack::XML
- Inherits:
-
Object
- Object
- Ncrack::XML
- Defined in:
- lib/ncrack/xml.rb,
lib/ncrack/xml/port.rb,
lib/ncrack/xml/address.rb,
lib/ncrack/xml/service.rb,
lib/ncrack/xml/credentials.rb
Overview
Defined Under Namespace
Classes: Address, Credentials, Port, Service
Instance Attribute Summary collapse
-
#doc ⇒ Nokogiri::XML::Node
readonly
private
The parsed XML document.
-
#path ⇒ String?
readonly
The path to the XML file.
Class Method Summary collapse
-
.open(path) {|xml| ... } ⇒ XML
Opens an parses an XML file.
-
.parse(xml) {|xml| ... } ⇒ XML
Parses the given XML String.
Instance Method Summary collapse
-
#args ⇒ String
Additional command-line arguments passed to
ncrack
. -
#debugging ⇒ Integer
The debugging level.
-
#each_service {|service| ... } ⇒ Enumerator
Enumerates over every service.
-
#initialize(doc, path: nil) {|xml| ... } ⇒ XML
constructor
private
Creates a new XML object.
-
#scanner ⇒ String
The scanner that produced the XML (aka
ncrack
). -
#service ⇒ Service, nik
The first service object.
-
#services ⇒ Array<Service>
All service object.
-
#start ⇒ Time
The start time.
-
#to_s ⇒ String
Converts the XML to a String.
-
#verbose ⇒ Integer
The verbosity level.
-
#version ⇒ String
The version of
ncrack
. -
#xml_output_version ⇒ String
The version of the
ncrack
XML schema.
Constructor Details
#initialize(doc, path: nil) {|xml| ... } ⇒ XML
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new XML object.
55 56 57 58 59 60 |
# File 'lib/ncrack/xml.rb', line 55 def initialize(doc, path: nil) @doc = doc @path = File.(path) if path yield self if block_given? end |
Instance Attribute Details
#doc ⇒ Nokogiri::XML::Node (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The parsed XML document.
30 31 32 |
# File 'lib/ncrack/xml.rb', line 30 def doc @doc end |
#path ⇒ String? (readonly)
The path to the XML file.
35 36 37 |
# File 'lib/ncrack/xml.rb', line 35 def path @path end |
Class Method Details
.open(path) {|xml| ... } ⇒ XML
Opens an parses an XML file.
102 103 104 105 106 |
# File 'lib/ncrack/xml.rb', line 102 def self.open(path,&block) path = File.(path) new(Nokogiri::XML(File.open(path)), path: path, &block) end |
.parse(xml) {|xml| ... } ⇒ XML
Parses the given XML String.
80 81 82 |
# File 'lib/ncrack/xml.rb', line 80 def self.parse(xml,&block) new(Nokogiri::XML(xml),&block) end |
Instance Method Details
#args ⇒ String
Additional command-line arguments passed to ncrack
.
124 125 126 |
# File 'lib/ncrack/xml.rb', line 124 def args @args ||= @doc.root['args'] end |
#debugging ⇒ Integer
The debugging level.
176 177 178 |
# File 'lib/ncrack/xml.rb', line 176 def debugging @debugging ||= @doc.at_xpath('/ncrackrun/debugging')['level'].to_i end |
#each_service {|service| ... } ⇒ Enumerator
Enumerates over every service.
192 193 194 195 196 197 198 |
# File 'lib/ncrack/xml.rb', line 192 def each_service return enum_for(__method__) unless block_given? @doc.root.xpath('/ncrackrun/service').each do |node| yield Service.new(node) end end |
#scanner ⇒ String
The scanner that produced the XML (aka ncrack
).
114 115 116 |
# File 'lib/ncrack/xml.rb', line 114 def scanner @scanner ||= @doc.root['scanner'] end |
#service ⇒ Service, nik
The first service object.
214 215 216 |
# File 'lib/ncrack/xml.rb', line 214 def service each_service.first end |
#services ⇒ Array<Service>
All service object.
205 206 207 |
# File 'lib/ncrack/xml.rb', line 205 def services each_service.to_a end |
#start ⇒ Time
The start time.
134 135 136 |
# File 'lib/ncrack/xml.rb', line 134 def start @start ||= Time.at(@doc.root['start'].to_i) end |
#to_s ⇒ String
Converts the XML to a String.
225 226 227 228 229 230 231 |
# File 'lib/ncrack/xml.rb', line 225 def to_s if @path @path else @doc.to_s end end |
#verbose ⇒ Integer
The verbosity level.
165 166 167 |
# File 'lib/ncrack/xml.rb', line 165 def verbose @verbose ||= @doc.at_xpath('/ncrackrun/verbose')['level'].to_i end |
#version ⇒ String
The version of ncrack
.
144 145 146 |
# File 'lib/ncrack/xml.rb', line 144 def version @version ||= @doc.root['version'] end |
#xml_output_version ⇒ String
The version of the ncrack
XML schema.
154 155 156 |
# File 'lib/ncrack/xml.rb', line 154 def xml_output_version @xml_output_version ||= @doc.root['xmloutputversion'] end |