Class: Ronin::Wordlists::CLI::WordlistIndex Private
- Inherits:
-
Object
- Object
- Ronin::Wordlists::CLI::WordlistIndex
- Includes:
- Enumerable
- Defined in:
- lib/ronin/wordlists/cli/wordlist_index.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 an index of known wordlists.
Defined Under Namespace
Classes: Entry, InvalidSchema
Constant Summary collapse
- PATH =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Path to the builtin
wordlists.yml
index file. File.join(ROOT,'data','wordlists.yml')
Instance Attribute Summary collapse
-
#entries ⇒ Hash{String => Entry}
readonly
private
The entries in the wordlist index.
Class Method Summary collapse
-
.load(path = PATH) ⇒ WordlistIndex
private
Loads the wordlist index file from the given path.
Instance Method Summary collapse
-
#[](name) ⇒ Entry?
private
Looks up the wordlist by name within the wordlist index.
-
#each {|entry| ... } ⇒ Enumerator
private
Enumerates over every entry in the wordlist index.
-
#initialize(entries) ⇒ WordlistIndex
constructor
private
Initializes the wordlist index.
Constructor Details
#initialize(entries) ⇒ WordlistIndex
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 index.
98 99 100 |
# File 'lib/ronin/wordlists/cli/wordlist_index.rb', line 98 def initialize(entries) @entries = entries end |
Instance Attribute Details
#entries ⇒ Hash{String => Entry} (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 entries in the wordlist index.
90 91 92 |
# File 'lib/ronin/wordlists/cli/wordlist_index.rb', line 90 def entries @entries end |
Class Method Details
.load(path = PATH) ⇒ WordlistIndex
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.
Loads the wordlist index file from the given path.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/ronin/wordlists/cli/wordlist_index.rb', line 123 def self.load(path=PATH) yaml = YAML.load_file(path) unless yaml.kind_of?(Hash) raise(InvalidSchema,"wordlist index file does not contain a Hash: #{path.inspect}") end entries = yaml.to_h do |name,attributes| unless attributes[:url] raise(InvalidSchema,"wordlist index entry does not have a URL: #{name.inspect}") end unless attributes[:summary] raise(InvalidSchema,"wordlist index entry does not have a summary: #{name.inspect}") end [name, Entry.new(name,**attributes)] end return new(entries) end |
Instance Method Details
#[](name) ⇒ Entry?
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.
Looks up the wordlist by name within the wordlist index.
154 155 156 |
# File 'lib/ronin/wordlists/cli/wordlist_index.rb', line 154 def [](name) @entries[name] end |
#each {|entry| ... } ⇒ 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 every entry in the wordlist index.
171 172 173 |
# File 'lib/ronin/wordlists/cli/wordlist_index.rb', line 171 def each(&block) @entries.each_value(&block) end |