Class: Ronin::Wordlists::SearchPaths Private
- Inherits:
-
Object
- Object
- Ronin::Wordlists::SearchPaths
- Includes:
- Enumerable
- Defined in:
- lib/ronin/wordlists/search_paths.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents the wordlist directories to search for wordlists within.
Instance Attribute Summary collapse
-
#paths ⇒ Array<WordlistDir>
readonly
private
The paths of the wordlist directories.
Class Method Summary collapse
-
.[](*paths) ⇒ SearchPaths
private
Initializes the wordlist search paths.
Instance Method Summary collapse
-
#<<(new_dir) ⇒ self
private
Adds a new wordlist directory to the search paths.
-
#each {|wordlist_dir| ... } ⇒ Enumerator
private
Enumerates over each wordlist directory within the search paths.
-
#find(name) ⇒ String?
private
Finds a wordlist within one of the wordlist directories.
-
#initialize(paths = []) ⇒ SearchPaths
constructor
private
Initializes the wordlist search paths.
-
#list(name = '*') ⇒ Set<String>
private
Lists all wordlists in the wordlist directories.
-
#open(name) ⇒ Wordlist::File
private
Opens a wordlist from one of the wordlist directories.
Constructor Details
#initialize(paths = []) ⇒ SearchPaths
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.
Initializes the wordlist search paths.
47 48 49 50 51 52 53 |
# File 'lib/ronin/wordlists/search_paths.rb', line 47 def initialize(paths=[]) @paths = [] paths.each do |path| self << path end end |
Instance Attribute Details
#paths ⇒ Array<WordlistDir> (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 paths of the wordlist directories.
39 40 41 |
# File 'lib/ronin/wordlists/search_paths.rb', line 39 def paths @paths end |
Class Method Details
.[](*paths) ⇒ SearchPaths
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.
Initializes the wordlist search paths.
64 65 66 |
# File 'lib/ronin/wordlists/search_paths.rb', line 64 def self.[](*paths) new(paths) end |
Instance Method Details
#<<(new_dir) ⇒ self
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.
Adds a new wordlist directory to the search paths.
92 93 94 95 |
# File 'lib/ronin/wordlists/search_paths.rb', line 92 def <<(new_dir) @paths.unshift(WordlistDir.new(new_dir)) return self end |
#each {|wordlist_dir| ... } ⇒ Enumerator
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.
Enumerates over each wordlist directory within the search paths.
80 81 82 |
# File 'lib/ronin/wordlists/search_paths.rb', line 80 def each(&block) @paths.each(&block) end |
#find(name) ⇒ String?
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.
Finds a wordlist within one of the wordlist directories.
106 107 108 109 110 111 112 113 114 |
# File 'lib/ronin/wordlists/search_paths.rb', line 106 def find(name) @paths.each do |wordlist_dir| if (wordlist_path = wordlist_dir.find(name)) return wordlist_path end end return nil end |
#list(name = '*') ⇒ Set<String>
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.
Lists all wordlists in the wordlist directories.
125 126 127 128 129 |
# File 'lib/ronin/wordlists/search_paths.rb', line 125 def list(name='*') each_with_object(Set.new) do |wordlist_dir,files| files.merge(wordlist_dir.list(name)) end end |
#open(name) ⇒ Wordlist::File
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.
Opens a wordlist from one of the wordlist directories.
143 144 145 146 147 148 149 |
# File 'lib/ronin/wordlists/search_paths.rb', line 143 def open(name) if (path = find(name)) Wordlist.open(path) else raise(WordlistNotFound,"wordlist not found: #{name.inspect}") end end |