Module Stella::Utils
In: lib/stella/utils.rb

A motley collection of methods that Stella loves to call!

Methods

Included Modules

Socket::Constants

Constants

ADDR_LOCAL = IPAddr.new("127.0.0.0/8")
ADDR_CLASSA = IPAddr.new("10.0.0.0/8")
ADDR_CLASSB = IPAddr.new("172.16.0.0/16")
ADDR_CLASSC = IPAddr.new("192.168.0.0/24")
ADDR_EC2_US_EAST = %w{ 216.182.224.0/20 72.44.32.0/19 67.202.0.0/18 75.101.128.0/17 174.129.0.0/16 204.236.192.0/18 184.73.0.0/16 184.72.128.0/17 184.72.64.0/18 50.16.0.0/15 }.collect { |ipr| IPAddr.new(ipr.strip) }   See: forums.aws.amazon.com/ann.jspa?annID=877
ADDR_EC2_US_WEST = %w{ 204.236.128.0/18 184.72.0.0/18 50.18.0.0/18 }.collect { |ipr| IPAddr.new(ipr.strip) }
ADDR_EC2_EU_WEST = %w{ 79.125.0.0/17 46.51.128.0/18 46.51.192.0/20 46.137.0.0/17 }.collect { |ipr| IPAddr.new(ipr.strip) }
ADDR_EC2_AP_EAST = %w{ 175.41.128.0/18 122.248.192.0/18 }.collect { |ipr| IPAddr.new(ipr.strip) }

Public Instance methods

Same as require_vendor, but uses autoload instead.

Checks if the file has more than 30% non-ASCII characters. NOTE: how to determine the difference between non-latin and binary?

Based on ptools by Daniel J. Berger raa.ruby-lang.org/project/ptools/

Returns a cname or nil

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

Based on ptools by Daniel J. Berger raa.ruby-lang.org/project/ptools/

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.

Returns an Array of ip addresses or nil

Based on ptools by Daniel J. Berger raa.ruby-lang.org/project/ptools/

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

Based on ptools by Daniel J. Berger raa.ruby-lang.org/project/ptools/

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.

require a library from the vendor directory. The vendor directory should be organized such that name and version can be used to create the path to the library.

e.g.

    vendor/httpclient-2.1.5.2/httpclient

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
    

[Validate]