module GxG

---------------------------------------------------------------------------------------------------------------------

Various preliminary patches to dependencies:


Various preliminary patches to standard classes: <none>


main module declaration:


Set GxG Version and instantiate GxG::SYSTEM object:

First attempt at object serialization/reconstitution:

determine the arch, platform with version, and ruby implementation with version store this in GxG::BOOTSTRAP

To overcome load-order issues:

GxG Communications Layer

PeristedArray Code:

PersistedHash Code:


Various data element classes:


GxG Engine interface: rational memory management, and quota supports


Preliminary Entity supports

IO Support Library Module & IO Classes ############################################

Auto-Transcoding Support Library Module ############################################


Units and support element classes:

gxg_ipc is there to pick the bones, but will be discarded : use this file.

GxG:

Networking Section of GxG

Constants

BOOTSTRAP

cleanup

return final result

BRIDGES
BRIDGES_AVAILABLE
DB
LOG

LOG = $LOG

RUBY_ENGINE
SYSTEM
VERSION

setup constants, dispose of BOOTSTRAP data.

VFS

Public Class Methods

apportioned_ranges(how_much_data=0, container_limit=0, original_offset=0) click to toggle source
# File lib/gxg.rb, line 530
def self.apportioned_ranges(how_much_data=0, container_limit=0, original_offset=0)
  result = []
  the_count = ::GxG::passes_needed(how_much_data, container_limit)
  if the_count > 0
    offset = original_offset
    the_count.times do
      if (offset + (container_limit - 1)) <= (how_much_data - 1)
        end_point = (offset + (container_limit - 1))
      else
        end_point = (how_much_data - 1)
      end
      result << ((offset)..(end_point))
      offset = (end_point + 1)
    end
  end
  result
end
passes_needed(size_used=0, container_limit=0) click to toggle source

Generic toolbox of methods

# File lib/gxg.rb, line 516
def self.passes_needed(size_used=0, container_limit=0)
  if size_used > 0 and container_limit > 0
    needed_raw = size_used.to_f / container_limit.to_f
    overhang = needed_raw - needed_raw.to_i.to_f
    needed_raw = needed_raw.to_i.to_f
    if overhang > 0.0
      needed_raw += 1.0
    end
    needed_raw.to_i
  else
    0
  end
end
reconstitute(raw_data="") click to toggle source
# File lib/gxg.rb, line 472
def self.reconstitute(raw_data="")
  # See: http://stackoverflow.com/questions/5758464/ruby-how-do-i-check-if-a-class-is-defined
  #
  if raw_data.is_a?(::String)
    if raw_data.serialized?()
      result = nil
      if raw_data.include?("marshal:")
        begin
          result = ::Marshal.load(raw_data[(8..-1)].decode64())
        rescue Exception
          # Question : what to do here.
        end
      else
        if raw_data.include?("structure:")
          data = ::Marshal.load(raw_data[(10..-1)].decode64())
          if data.is_any?(::Array, ::Hash, ::Set, ::Struct)
            result = data.process do |entry, selector|
              if entry.is_a?(::String)
                if entry.serialized?()
                  ::GxG::reconstitute(entry)
                  # entry.unserialize()
                else
                  entry
                end
              else
                entry
              end
            end
          end
        else
          raise Exception, "unrecognized serialization format"
        end
      end
    else
      result = raw_data
    end
  else
    result = raw_data
  end
  result
  #
end
shutdown() click to toggle source
# File lib/gxg.rb, line 465
def self.shutdown()
  $Dispatcher.shutdown()
  ::GxG::Networking::ZMQ::zmq_default_context.terminate()
end
sql_statement?(the_string) click to toggle source
# File lib/gxg.rb, line 569
def self.sql_statement?(the_string)
  # See: https://larrysteinle.com/2011/02/20/use-regular-expressions-to-detect-sql-code-injection/
  if /('(''|[^'])*')|(;)|(\\x08(ALTER|CREATE|DELETE|DROP|EXEC(UTE){0,1}|INSERT( +INTO){0,1}|MERGE|SELECT|UPDATE|UNION( +ALL){0,1})\\x08)/.match(the_string)
    true
  else
    false
  end
end
uuid_generate() click to toggle source
# File lib/gxg.rb, line 91
def self.uuid_generate()
  ::SecureRandom::uuid.to_s
end
valid_domain_name?(the_string) click to toggle source
# File lib/gxg.rb, line 578
def self.valid_domain_name?(the_string)
  if /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/.match(the_string)
    true
  else
    false
  end
end
valid_uuid?(uuid=nil,strict=true) click to toggle source
# File lib/gxg.rb, line 548
def self.valid_uuid?(uuid=nil,strict=true)
  if uuid.is_any?(::String, ::Symbol)
    if strict == true
      pattern = /[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]-[0-9a-f][0-9a-f][0-9a-f][0-9a-f]-[4][0-9a-f][0-9a-f][0-9a-f]-[0-9a-f][0-9a-f][0-9a-f][0-9a-f]-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]/
    else
      pattern = /[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]-[0-9a-f][0-9a-f][0-9a-f][0-9a-f]-[0-9a-f][0-9a-f][0-9a-f][0-9a-f]-[0-9a-f][0-9a-f][0-9a-f][0-9a-f]-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]/
    end
    if uuid.to_s.match(pattern)
      if uuid.to_s.size == 36
        true
      else
        false
      end
    else
      false
    end
  else
    false
  end
end

Public Instance Methods

find_local(the_key) click to toggle source
# File lib/gxg/gxg_entities.rb, line 6
def find_local(the_key)
  nil
end