Module: Obfuscate

Defined in:
lib/obfuscate/version.rb,
lib/obfuscate.rb,
lib/obfuscate/obfuscatable.rb

Overview

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Modules: Obfuscatable Classes: Config, Crypt

Constant Summary collapse

VERSION =
"0.0.7"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



23
24
25
# File 'lib/obfuscate.rb', line 23

def config
  @config
end

Class Method Details

.clarify(text, options = {}) ⇒ String

Clarify obfuscated text. Depends on Obfuscate.setup to be called first

Parameters:

  • text (String)

    to be clarified

  • options (Hash) (defaults to: {})

    overrides how clarify should be handled

Returns:

  • (String)


39
40
41
# File 'lib/obfuscate.rb', line 39

def clarify(text, options = {} )
  cryptor( options ).clarify( text )
end

.cryptor(options = {}) ⇒ Obfuscate::Crypt

Create instance of Obfuscate::Crypt. Depends on Obfuscate.setup to be called first

Parameters:

  • overrides (Hash)

    how instance should be created

Returns:



47
48
49
# File 'lib/obfuscate.rb', line 47

def cryptor(options = {} )
  Obfuscate::Crypt.new( @config.apply( options ) )
end

.obfuscate(text, options = {}) ⇒ String

Obfuscate text. Depends on Obfuscate.setup to be called first

Parameters:

  • text (String)

    to be obfuscated

  • options (Hash) (defaults to: {})

    overrides how obfuscation should be handled

Returns:

  • (String)


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

def obfuscate(text, options = {} )
  cryptor( options ).obfuscate( text )
end

.setup(options = {}, &blk) ⇒ Obfuscate::Config

Setup Obfuscate passing in a hash and/or block

Parameters:

  • options (Hash) (defaults to: {})

    of configurations

  • blk (block)

    of configuration, has precedence over options Hash.

Options Hash (options):

  • :salt (Symbol)

    A Model specific salt

  • :encode (Symbol)

    Enable Base64 and URL encoding for this Model. Enabled by default.

  • :remove_trailing_equal (Symbol)

    When in :block mode, removes the trailing = from the obfuscated text.

Returns:



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

def setup(options ={}, &blk)
  @config = @config.apply(options, &blk)
end