Module: Firebug

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

Defined Under Namespace

Classes: Configuration, Crypto, ParserError, Serializer, Session, Unserializer

Constant Summary collapse

VERSION =

The current version of Firebug

'1.1.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationFirebug::Configuration Also known as: config

Firebug configuration



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

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:



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

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:



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

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.



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

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:



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

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.



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

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:



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

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:



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

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