Skip to content

Commit

Permalink
Switched to using require_relative to improve load-times (closes #93).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Jan 25, 2024
1 parent 929bcfa commit 5687622
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 42 deletions.
6 changes: 3 additions & 3 deletions lib/nmap.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require 'nmap/program'
require 'nmap/xml'
require 'nmap/version'
require_relative 'nmap/program'
require_relative 'nmap/xml'
require_relative 'nmap/version'
14 changes: 7 additions & 7 deletions lib/nmap/xml.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require 'nmap/xml/scanner'
require 'nmap/xml/scan_task'
require 'nmap/xml/scan'
require 'nmap/xml/host'
require 'nmap/xml/run_stat'
require 'nmap/xml/prescript'
require 'nmap/xml/postscript'
require_relative 'xml/scanner'
require_relative 'xml/scan_task'
require_relative 'xml/scan'
require_relative 'xml/host'
require_relative 'xml/run_stat'
require_relative 'xml/prescript'
require_relative 'xml/postscript'

require 'nokogiri'

Expand Down
2 changes: 1 addition & 1 deletion lib/nmap/xml/cpe.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'nmap/xml/cpe/url'
require_relative 'cpe/url'

module Nmap
class XML
Expand Down
24 changes: 12 additions & 12 deletions lib/nmap/xml/host.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
require 'nmap/xml/status'
require 'nmap/xml/address'
require 'nmap/xml/hostname'
require 'nmap/xml/os'
require 'nmap/xml/port'
require 'nmap/xml/ip_id_sequence'
require 'nmap/xml/tcp_sequence'
require 'nmap/xml/tcp_ts_sequence'
require 'nmap/xml/uptime'
require 'nmap/xml/traceroute'
require 'nmap/xml/host_script'
require_relative 'status'
require_relative 'address'
require_relative 'hostname'
require_relative 'os'
require_relative 'port'
require_relative 'ip_id_sequence'
require_relative 'tcp_sequence'
require_relative 'tcp_ts_sequence'
require_relative 'uptime'
require_relative 'traceroute'
require_relative 'host_script'

require 'nokogiri'
require 'time'
Expand Down Expand Up @@ -258,7 +258,7 @@ def os
# @yield [uptime]
# If a block is given, it will be passed the resulting object
#
# @yieldparam [Uptime]
# @yieldparam [Uptime]
# Uptime value.
#
# @return [Uptime]
Expand Down
2 changes: 1 addition & 1 deletion lib/nmap/xml/host_script.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'nmap/xml/scripts'
require_relative 'scripts'

module Nmap
class XML
Expand Down
2 changes: 1 addition & 1 deletion lib/nmap/xml/ip_id_sequence.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'nmap/xml/sequence'
require_relative 'sequence'

module Nmap
class XML
Expand Down
4 changes: 2 additions & 2 deletions lib/nmap/xml/os.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'nmap/xml/os_class'
require 'nmap/xml/os_match'
require_relative 'os_class'
require_relative 'os_match'

module Nmap
class XML
Expand Down
2 changes: 1 addition & 1 deletion lib/nmap/xml/os_class.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'nmap/xml/cpe'
require_relative 'cpe'

module Nmap
class XML
Expand Down
4 changes: 2 additions & 2 deletions lib/nmap/xml/port.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'nmap/xml/service'
require 'nmap/xml/scripts'
require_relative 'service'
require_relative 'scripts'

module Nmap
class XML
Expand Down
2 changes: 1 addition & 1 deletion lib/nmap/xml/postscript.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'nmap/xml/scripts'
require_relative 'scripts'

module Nmap
class XML
Expand Down
2 changes: 1 addition & 1 deletion lib/nmap/xml/prescript.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'nmap/xml/scripts'
require_relative 'scripts'

module Nmap
class XML
Expand Down
2 changes: 1 addition & 1 deletion lib/nmap/xml/scripts.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'nmap/xml/script'
require_relative 'script'

module Nmap
class XML
Expand Down
2 changes: 1 addition & 1 deletion lib/nmap/xml/service.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'nmap/xml/cpe'
require_relative 'cpe'

module Nmap
class XML
Expand Down
4 changes: 2 additions & 2 deletions lib/nmap/xml/tcp_sequence.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'nmap/xml/sequence'
require_relative 'sequence'

module Nmap
class XML
Expand All @@ -14,7 +14,7 @@ class TcpSequence < Sequence
# The difficulty index from nmap
#
# @since 0.5.0
#
#
def index
@index ||= if (index_string = @node['index'])
index_string.to_i
Expand Down
2 changes: 1 addition & 1 deletion lib/nmap/xml/tcp_ts_sequence.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'nmap/xml/sequence'
require_relative 'sequence'

module Nmap
class XML
Expand Down
2 changes: 1 addition & 1 deletion lib/nmap/xml/traceroute.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'nmap/xml/hop'
require_relative 'hop'

module Nmap
class XML
Expand Down
5 changes: 1 addition & 4 deletions ruby-nmap.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ Gem::Specification.new do |gem|

gem.name = gemspec.fetch('name')
gem.version = gemspec.fetch('version') do
lib_dir = File.join(File.dirname(__FILE__),'lib')
$LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)

require 'nmap/version'
require_relative 'lib/nmap/version'
Nmap::VERSION
end

Expand Down

0 comments on commit 5687622

Please sign in to comment.