Sha256: 62207afc39344dc10e93074bb0a40097d6015936675f7af7f8ddbe0813d4e4d6

Contents?: true

Size: 951 Bytes

Versions: 52

Compression:

Stored size: 951 Bytes

Contents

module Refinery #:nodoc:
  # Utilities that can be mixed into a class
  module Utilities
    # Camelize the given word.
    def camelize(word, first_letter_in_uppercase = true)
      if first_letter_in_uppercase
        word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
      else
        word.first.downcase + camelize(word)[1..-1]
      end
    end
    
    # Decode the message_body from Base 64 and then parse from JSON.
    def decode_message(message_body)
      JSON.parse(Base64.decode64(message_body))
    end
    
    # Convert the given message_data object to JSON and then Base 64
    # encode it
    def encode_message(message_data)
      Base64.encode64(message_data.to_json)
    end
    
    # Get a Hash of useful host information that can be sent with
    # messages to the monitoring system.
    def host_info
      {
        'hostname' => Socket.gethostname,
        'pid' => $$
      }
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
aeden-refinery-0.10.0 lib/refinery/utilities.rb
aeden-refinery-0.10.1 lib/refinery/utilities.rb
aeden-refinery-0.10.10 lib/refinery/utilities.rb
aeden-refinery-0.10.2 lib/refinery/utilities.rb
aeden-refinery-0.10.3 lib/refinery/utilities.rb
aeden-refinery-0.10.5 lib/refinery/utilities.rb
aeden-refinery-0.10.6 lib/refinery/utilities.rb
aeden-refinery-0.10.8 lib/refinery/utilities.rb
aeden-refinery-0.9.1 lib/refinery/utilities.rb
aeden-refinery-0.9.10 lib/refinery/utilities.rb
aeden-refinery-0.9.11 lib/refinery/utilities.rb
aeden-refinery-0.9.12 lib/refinery/utilities.rb
aeden-refinery-0.9.13 lib/refinery/utilities.rb
aeden-refinery-0.9.14 lib/refinery/utilities.rb
aeden-refinery-0.9.15 lib/refinery/utilities.rb
aeden-refinery-0.9.2 lib/refinery/utilities.rb
aeden-refinery-0.9.4 lib/refinery/utilities.rb
aeden-refinery-0.9.5 lib/refinery/utilities.rb
aeden-refinery-0.9.6 lib/refinery/utilities.rb
aeden-refinery-0.9.7 lib/refinery/utilities.rb