Module: Wordlist

Defined in:
lib/wordlist.rb,
lib/wordlist/cli.rb,
lib/wordlist/file.rb,
lib/wordlist/lexer.rb,
lib/wordlist/words.rb,
lib/wordlist/format.rb,
lib/wordlist/builder.rb,
lib/wordlist/version.rb,
lib/wordlist/exceptions.rb,
lib/wordlist/lexer/lang.rb,
lib/wordlist/list_methods.rb,
lib/wordlist/modifiers/tr.rb,
lib/wordlist/modifiers/sub.rb,
lib/wordlist/unique_filter.rb,
lib/wordlist/modifiers/gsub.rb,
lib/wordlist/operators/power.rb,
lib/wordlist/operators/union.rb,
lib/wordlist/lexer/stop_words.rb,
lib/wordlist/modifiers/mutate.rb,
lib/wordlist/modifiers/upcase.rb,
lib/wordlist/operators/concat.rb,
lib/wordlist/operators/unique.rb,
lib/wordlist/abstract_wordlist.rb,
lib/wordlist/operators/product.rb,
lib/wordlist/compression/reader.rb,
lib/wordlist/compression/writer.rb,
lib/wordlist/modifiers/downcase.rb,
lib/wordlist/modifiers/modifier.rb,
lib/wordlist/operators/operator.rb,
lib/wordlist/operators/subtract.rb,
lib/wordlist/operators/intersect.rb,
lib/wordlist/modifiers/capitalize.rb,
lib/wordlist/modifiers/mutate_case.rb,
lib/wordlist/operators/unary_operator.rb,
lib/wordlist/operators/binary_operator.rb

Defined Under Namespace

Modules: Compression, Format, ListMethods, Modifiers, Operators Classes: AbstractWordlist, AppendNotSupported, Builder, CLI, CommandNotFound, File, Lexer, UniqueFilter, UnknownFormat, UnsupportedLanguage, WordlistError, WordlistNotFound, Words

Constant Summary collapse

VERSION =

wordlist version

'1.1.1'

Class Method Summary collapse

Class Method Details

.[](*words) ⇒ File

Creates an in-memory wordlist from the given words.

Parameters:

  • words (Array<String>)

    The literal words for the list.

Returns:

  • (File)

    The in-memory wordlist.

Since:

  • 1.0.0



21
22
23
# File 'lib/wordlist.rb', line 21

def self.[](*words)
  Words[*words]
end

.build(path, **kwargs) {|builder| ... } ⇒ Builder

Creates a new wordlist builder.

Parameters:

  • path (String)

    The path to the file.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments for Wordlist::Builder#initialize.

Options Hash (**kwargs):

  • :format (:txt, :bzip, :bzip2, :xz, nil)

    Specifies the format of the wordlist. If no format is given, the format will be inferred from the path's file extension.

  • :append (Boolean)

    Specifies whether new words will be appended onto the end of the wordlist file or if it will be overwritten.

Yields:

  • (builder)

    If a block is given, the newly created builder object will be yielded. After the block has returned the builder will automatically be closed.

Yield Parameters:

  • builder (Builder)

    The newly created builder object.

Returns:

Raises:

  • (ArgumentError)

    No format: was given, the wordlist format could not be inferred from the path's file extension.

Since:

  • 1.0.0



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/wordlist.rb', line 93

def self.build(path,**kwargs)
  builder = Builder.new(path,**kwargs)

  if block_given?
    begin
      yield builder
    ensure
      builder.close
    end
  end

  return builder
end

.open(path, **kwargs) {|wordlist| ... } ⇒ Wordlist::File

Opens a wordlist file.

Parameters:

  • path (String)

    The path to the file.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments for Wordlist::File#initialize.

Options Hash (**kwargs):

  • :format (:txt, :bzip, :bzip2, :xz, :zip, :7zip)

    Specifies the format of the wordlist. If no format is given, the format will be inferred from the path's file extension.

Yields:

  • (wordlist)

    If a block is given, it will be passed the newly opened wordlist.

Yield Parameters:

Returns:

Raises:

  • (ArgumentError)

    No format: was given, the wordlist format could not be inferred from the path's file extension.

Since:

  • 1.0.0



55
56
57
# File 'lib/wordlist.rb', line 55

def self.open(path,**kwargs,&block)
  File.open(path,**kwargs,&block)
end