A Rake-like DSL for writing AWS Lambda handlers
MIT License
Published by amancevice over 2 years ago
Add UTC::new
method to behave like Time::new
Published by amancevice over 2 years ago
Add Object#try
support helper
MyObject.new.some_method
# => NoMethodError
MyObject.new.try(:some_method)
# => nil
Published by amancevice over 2 years ago
Add Hash#except
support helper
{ fizz: 'buzz', jazz: 'fuzz' }.except(:buzz)
# => { :fizz => 'buzz' }
Published by amancevice over 2 years ago
Add Hash#stringify_names
method
require 'yake/support'
{ fizz: 'buzz' }.stringify_names
# => { "fizz" => "buzz" }
Published by amancevice over 2 years ago
Add String#/
method to concat URI/file paths in support module:
require 'yake/support'
host = 'https://example.com/'
path = '/path/to/resource/'
host / path
# => "https://example.com/path/to/resource/"
Published by amancevice over 2 years ago
Add Integer#weeks
to yake/support
module
Add singular aliases to Integer#<time>
functions (eg, 1.day
, 1.hour
, etc)
Published by amancevice over 2 years ago
Added yake/support
module for common transformations
Enable the helpers by requiring the support
submodule:
require 'yake/support'
Hash
transformations:
{ fizz: 'buzz' }.encode64
# => "eyJmaXp6IjoiYnV6eiJ9\n"
{ fizz: 'buzz' }.strict_encode64
# => "eyJmaXp6IjoiYnV6eiJ9"
{ 'fizz' => { 'buzz' => %w[jazz fuzz] } }.symbolize_names
# => { :fizz => { :buzz => ["jazz", "fuzz"] } }
{ fizz: 'buzz' }.to_form
# => "fizz=buzz"
Integer
transformations:
7.days
# => 604800
7.hours
# => 25200
7.minutes
# => 420
1234567890.utc
# => 2009-02-13 23:31:30 UTC
String
transformations:
'snake_case_string'.camel_case
# => SnakeCaseString
"Zml6eg==\n".decode64
# => "fizz"
'fizz'.encode64
# => "Zml6eg==\n"
'CamelCaseString'.snake_case
# => 'camel_case_string'
'Zml6eg=='.strict_decode64
# => "fizz"
'fizz'.strict_encode64
# => "Zml6eg=="
'{"fizz":"buzz"}'.to_h_from_json
# => { "fizz" => "buzz" }
'fizz=buzz'.to_h_from_form
# => { "fizz" => "buzz" }
Symbol
transformations
:snake_case_symbol.camel_case
# => :SnakeCaseSymbol
:CamelCaseSymbol.snake_case
# => 'camel_case_symbol'
UTC
Time helper
UTC.at 1234567890
# => 2009-02-13 23:31:30 UTC
UTC.now
# => 2022-02-26 13:57:07.860539 UTC