Module: Firebug

Defined in:
lib/firebug.rb,
lib/firebug/crypto.rb,
lib/firebug/errors.rb,
lib/firebug/session.rb,
lib/firebug/version.rb,
lib/firebug/serializer.rb,
lib/firebug/unserializer.rb,
lib/firebug/configuration.rb,
lib/firebug/string_io_reader.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Configuration, Crypto, FirebugMcrypt, Serializer, Session, StringIOReader, Unserializer

Constant Summary collapse

Error =

Base error class.

Class.new(StandardError)
ParserError =

An error unserializing a string.

Class.new(Error)
VERSION =

The current version of Firebug

'1.4.2'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationFirebug::Configuration Also known as: config

Firebug configuration



18
19
20
# File 'lib/firebug.rb', line 18

def configuration
  @configuration ||= Configuration.new
end

Class Method Details

.configure {|config| ... } ⇒ Object

Configure Firebug inside a block.

Examples:

Firebug.configure do |config|
  config.key = 'password'
end

Yield Parameters:



31
32
33
# File 'lib/firebug.rb', line 31

def configure
  yield configuration
end

.decrypt(data, key = nil) ⇒ Object

Decrypt data encrypted using CodeIgniters encryption.

Parameters:

  • data (Object)
  • key (String) (defaults to: nil)

    If ‘nil` use Firebug::Configuration.key

See Also:



71
72
73
# File 'lib/firebug.rb', line 71

def decrypt(data, key=nil)
  Crypto.new(key.nil? ? config.key : key).decrypt(data)
end

Decodes the base64 encoded string, decrypts, and unserializes.

Parameters:

  • data (String)

    A base64 encoded encrypted string.

Returns:

  • (Object)

    The unserialized data.



87
88
89
# File 'lib/firebug.rb', line 87

def decrypt_cookie(data)
  data.nil? ? {} : Firebug.unserialize(Firebug.decrypt(Base64.strict_decode64(data)))
end

.encrypt(data, key = nil) ⇒ Object

Encrypt data the way CodeIgniter does.

Parameters:

  • data (Object)
  • key (String) (defaults to: nil)

    if ‘nil` use Firebug::Configuration.key

See Also:



61
62
63
# File 'lib/firebug.rb', line 61

def encrypt(data, key=nil)
  Crypto.new(key.nil? ? config.key : key).encrypt(data)
end

Serializes, encrypts, and base64 encodes the data.

Parameters:

  • data (Object)

Returns:

  • (String)

    A base64 encoded string.



79
80
81
# File 'lib/firebug.rb', line 79

def encrypt_cookie(data)
  Base64.strict_encode64(Firebug.encrypt(Firebug.serialize(data)))
end

.serialize(value) ⇒ String

Serialize a ruby object into a PHP serialized string.

Parameters:

  • value (Object)

Returns:

  • (String)

See Also:



41
42
43
# File 'lib/firebug.rb', line 41

def serialize(value)
  Serializer.parse(value)
end

.unserialize(value) ⇒ Object

Unserialize a PHP serialized string into a ruby object.

Parameters:

  • value (String)

Returns:

  • (Object)

See Also:



51
52
53
# File 'lib/firebug.rb', line 51

def unserialize(value)
  Unserializer.parse(value)
end