Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
= hash_engine
HashEngine is designed to operate on inputs given a hash of instructions to genetate an output hash HashEngine is compatible with Ruby versions 1.8.7, 1.9, and 2.0, mostly because I have a legacy project still on 1.8.7.
The primary manipulations HashEngin is capable of are:
HashEngine has several functions built in which will be covered below, however HashEngine was designed with extensability and customizability in mind. You can add your own functions and/or remove some of the built in functions.
There are two main classes of instructions for HashEngine, fetchers and actions. Fetchers are instructions to 'fetch' data. Actions are instructions which 'act' on previously fetched data. A majority of tranformations involve only one fetcher and action, but can specify multiple instructions.
1.8.7 vs 1.9 and 2.0 Since hashes in 1.8.7 do not remembering insert order all instruction chaining needs to be specified as array elements. The exception being a single fetcher followed by a single action, which can be specified as an array.
== Fetchers The defined fetchers are:
data_key_1: data_value_1 data_key_2: data_value_2 data_key_3: data_value_3 data_key_4: data_value_4 data_key_5: data_value_5
conditional_input -- variant of subgroup_input where conditional logic is applied to the data, the equivalent Ruby code would be: if left_operand operator right_operand true_instructions else false_instructions
-- The structure of this fetcher is a bit different There must be a fetcher specified for the
== Actions The main actions are:
== Global settings
The version of Ruby in use will change how multiple instructions must be specified to maintain the correct order of operations. In Ruby 1.8 an Array must be used, however since Ruby 1.9 Hashes maintain insertion order an Array or Hash can be used.
Input Data Type:
== Builtin Actions:
lookup_map => mostly equivalent to a hash lookup, the differences are because Hashes loaded from YAML don't have default procs modifiers: default: => will return <default_value> if input is not found default_to_key: true => will return the key if input is not found for example given the following instructions: output_field_1:
first_value => find the first non-nil value YAML example: output_1: data: - data_key_1 - data_key_2 join: ', ' When data_value_1 exists the result would be => data_value_1 When data_value_1 doesn't exist the result would be => data_value_2
join => join all the data using the specified string YAML example: output_1: data: - data_key_1 - data_key_2 join: ', ' Result would be => data_value_1, data_value_2
max_length => cut the output down to the size specified YAML example: output_1: input: data_key_1 max_length: 8 Result would be => data_val
strtfmt: This will call strfmt using the supplied pattern on the value if the value responds to strfmt
format: These are for formatting or casting values The built in formats are:
string = effectively calls to_s on the value, as well as stripping all leading and trailing spaces, examples (initial, result):
first = returns first character, if needed calls to_s first, examples (initial, result):
alphanumeric = , examples (initial, result):
no_whitespace = , examples (initial, result):
alpha = calls to_s on value and then keeps only a-zA-Z, examples (initial, result):
numeric = keeps only digits 0-9, examples (initial, result):
float = calls to_f, examples (initial, result):
integer = calls to_i with the following exceptions, true => 1, nil and false => 0, examples (initial, result):
boolean = converts values to true or false, examples (initial, result):
upcase = changes all characters to upper case, examples (initial, result):
capitalize = capitalizes the string, examples (initial, result):
downcase = changes all characters to lower case, examples (initial, result):
reverse = reverse the order of the characters
== Adding/Removing/Changing Actions To add a new action using a block do: HashEngine.register_action_block('first_value') {|data, action_data, error_array| data.find {|field| (field && !field.empty?) } }
To change a action, simply register the new action. To delete a action use: HashEngine.remove_format_block('float')
== Adding/Removing/Changing Formats To add a new format using a block do: HashEngine.register_format_block('float') {|data| data.to_f}
To add a new format using a hash do: i_hash = Hash.new {|hash, key| key.to_i } i_hash[true] = 1 i_hash[false] = 0 i_hash[nil] = 0 HashEngine.register_format_hash('integer', i_hash)
To change a format, simply register the new format. To delete a format use: HashEngine.remove_format_block('float')
== Contributing to hash_engine
== Copyright
Copyright (c) 2011-2012 Michael King (kingmt@gmail.com).
FAQs
Unknown package
We found that hash_engine demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.