Module Rudy::Utils
In: lib/rudy/utils.rb

A motley collection of methods that Rudy loves to call!

Methods

Included Modules

Socket::Constants

Classes and Modules

Module Rudy::Utils::RSSReader

Public Instance methods

msg The message to return as a banner size One of: :normal (default), :huge colour a valid Returns a string with styling applying

Make a terminal bell chime

Have you seen that episode of The Cosby Show where Dizzy Gillespie… ah nevermind.

Capture STDOUT or STDERR to prevent it from being printed.

   capture(:stdout) do
     ...
   end

Return the external IP address (the one seen by the internet)

Generates a canonical tag name in the form:

    2009-12-31-USER-SUFFIX

where USER is equal to the user executing the Rudy process and SUFFIX is equal to suffix (optional)

Returns the object type associated to str or nil if unknown.

  • str is a string you‘re investigating

Returns the string identifier associated to this key

Return the local IP address which receives external traffic from: coderrr.wordpress.com/2008/05/28/get-your-local-ip-address/ NOTE: This does not open a connection to the IP address.

Is the given string str an ID of type identifier?

  • identifier is expected to be a key from ID_MAP
  • str is a string you‘re investigating

Is the given key a known type of object?

Return a string ID without the identifier. e.g. key-stage-app-root => stage-app-root

require a glob of files.

  • path is a list of path elements which is sent to File.join

and then to Dir.glob. The list of files found are sent to require. Nothing is returned but LoadError exceptions are caught. The message is printed to STDERR and the program exits with 7.

Checks whether something is listening to a socket.

  • host A hostname
  • port The port to check
  • wait The number of seconds to wait for before timing out.

Returns true if host allows a socket connection on port. Returns false if one of the following exceptions is raised: Errno::EAFNOSUPPORT, Errno::ECONNREFUSED, SocketError, Timeout::Error

Generates a string of random alphanumeric characters.

  • len is the length, an Integer. Default: 8
  • safe in safe-mode, ambiguous characters are removed (default: true):
        i l o 1 0
    

Wait for something to happen.

  • duration seconds to wait between tries (default: 2).
  • max maximum time to wait (default: 240). Throws an exception when exceeded.
  • logger IO object to print dot to.
  • msg the message to print before executing the block.
  • bells number of terminal bells to ring. Set to nil or false to keep the waiter silent

The check block must return false while waiting. Once it returns true the waiter will return true too.

Returns str with the leading indentation removed. Stolen from github.com/mynyml/unindent/ because it was better.

[Validate]