yake 0.5.0 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +24 -12
- data/lib/yake/support.rb +9 -0
- data/lib/yake/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2cf5c971016a9089087501bca0a31862c9f2f9ffdd586e2dfb965a190a664da
|
4
|
+
data.tar.gz: 8eaab803ca82cb0610f8775753e3cc2f1c472833417ff7db3940f0813a3561d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecafe24268afd558fcd5bbf388d03f334112d8c272a1f49688121a70662186ccfbb706a2d96407b8bbc13870515e5f7907a2b267432387e71070aa9bd6d2da29
|
7
|
+
data.tar.gz: ae003774e4626ee4afc13fef2f0a480813fa91a4a03ba3d1a1480e5c5770a748d2c629949fdb07d6e3941cecfb2eb963276613082fbb7a1866105f4f4a831fd6
|
data/README.md
CHANGED
@@ -67,11 +67,11 @@ gem install yake
|
|
67
67
|
|
68
68
|
So why use `yake` for your Lambda functions?
|
69
69
|
|
70
|
-
|
70
|
+
### Event Logging
|
71
71
|
|
72
72
|
By default, the `handler` function wraps its block in log lines formatted to match the style of Amazon's native Lambda logs sent to CloudWatch. Each invocation of the handler will log both the _input event_ and the _returned value_, prefixed with the ID of the request:
|
73
73
|
|
74
|
-
```
|
74
|
+
```plaintext
|
75
75
|
START RequestId: 149c500f-028a-4b57-8977-0ef568cf8caf Version: $LATEST
|
76
76
|
INFO RequestId: 149c500f-028a-4b57-8977-0ef568cf8caf EVENT { … }
|
77
77
|
…
|
@@ -101,7 +101,7 @@ Fizz.new.logger == Yake.logger
|
|
101
101
|
# => true
|
102
102
|
```
|
103
103
|
|
104
|
-
|
104
|
+
### API Routes
|
105
105
|
|
106
106
|
A common use of Lambda functions is as a proxy for API Gateway. Oftentimes users will deploy a single Lambda function to handle all requests coming from API Gateway.
|
107
107
|
|
@@ -168,26 +168,30 @@ Route an event to one of the declared routes:
|
|
168
168
|
```ruby
|
169
169
|
handler :lambda_handler do |event|
|
170
170
|
route event
|
171
|
-
rescue Yake::UndeclaredRoute => err
|
171
|
+
rescue Yake::Errors::UndeclaredRoute => err
|
172
172
|
respond 404, { message: err.message }.to_json
|
173
173
|
rescue => err
|
174
174
|
respond 500, { message: err.message }.to_json
|
175
175
|
end
|
176
176
|
```
|
177
177
|
|
178
|
-
|
178
|
+
### Zero Dependencies
|
179
179
|
|
180
180
|
Finally, `yake` does not depend on any other gems, using the Ruby stdlib only. This helps keep your Lambda packages slim & speedy.
|
181
181
|
|
182
182
|
## Support Helpers
|
183
183
|
|
184
|
-
As of
|
184
|
+
As of `~> 0.5`, `yake` comes with a support module for common transformations.
|
185
185
|
|
186
|
-
`
|
186
|
+
Enable the helpers by requiring the `support` submodule:
|
187
187
|
|
188
188
|
```ruby
|
189
189
|
require 'yake/support'
|
190
|
+
```
|
191
|
+
|
192
|
+
`Hash` transformations:
|
190
193
|
|
194
|
+
```ruby
|
191
195
|
{ fizz: 'buzz' }.encode64
|
192
196
|
# => "eyJmaXp6IjoiYnV6eiJ9\n"
|
193
197
|
|
@@ -204,11 +208,14 @@ require 'yake/support'
|
|
204
208
|
`Integer` transformations:
|
205
209
|
|
206
210
|
```ruby
|
211
|
+
7.weeks
|
212
|
+
# => 4_233_600
|
213
|
+
|
207
214
|
7.days
|
208
|
-
# =>
|
215
|
+
# => 604_800
|
209
216
|
|
210
217
|
7.hours
|
211
|
-
# =>
|
218
|
+
# => 25_200
|
212
219
|
|
213
220
|
7.minutes
|
214
221
|
# => 420
|
@@ -220,8 +227,13 @@ require 'yake/support'
|
|
220
227
|
`String` transformations:
|
221
228
|
|
222
229
|
```ruby
|
230
|
+
host = 'https://example.com/'
|
231
|
+
path = '/path/to/resource'
|
232
|
+
host / path
|
233
|
+
# => "https://example.com/path/to/resource"
|
234
|
+
|
223
235
|
'snake_case_string'.camel_case
|
224
|
-
# => SnakeCaseString
|
236
|
+
# => "SnakeCaseString"
|
225
237
|
|
226
238
|
"Zml6eg==\n".decode64
|
227
239
|
# => "fizz"
|
@@ -230,7 +242,7 @@ require 'yake/support'
|
|
230
242
|
# => "Zml6eg==\n"
|
231
243
|
|
232
244
|
'CamelCaseString'.snake_case
|
233
|
-
# =>
|
245
|
+
# => "camel_case_string"
|
234
246
|
|
235
247
|
'Zml6eg=='.strict_decode64
|
236
248
|
# => "fizz"
|
@@ -252,7 +264,7 @@ require 'yake/support'
|
|
252
264
|
# => :SnakeCaseSymbol
|
253
265
|
|
254
266
|
:CamelCaseSymbol.snake_case
|
255
|
-
# =>
|
267
|
+
# => :camel_case_symbol
|
256
268
|
```
|
257
269
|
|
258
270
|
`UTC` Time helper
|
data/lib/yake/support.rb
CHANGED
@@ -5,19 +5,28 @@ require 'time'
|
|
5
5
|
class Hash
|
6
6
|
def encode64() to_json.encode64 end
|
7
7
|
def strict_encode64() to_json.strict_encode64 end
|
8
|
+
def stringify_names() JSON.parse(to_json) end
|
8
9
|
def symbolize_names() JSON.parse(to_json, symbolize_names: true) end
|
9
10
|
def to_form() URI.encode_www_form(self) end
|
10
11
|
end
|
11
12
|
|
12
13
|
class Integer
|
14
|
+
def weeks() days * 7 end
|
13
15
|
def days() hours * 24 end
|
14
16
|
def hours() minutes * 60 end
|
15
17
|
def minutes() seconds * 60 end
|
16
18
|
def seconds() self end
|
17
19
|
def utc() UTC.at(self) end
|
20
|
+
|
21
|
+
alias :second :seconds
|
22
|
+
alias :minute :minutes
|
23
|
+
alias :hour :hours
|
24
|
+
alias :day :days
|
25
|
+
alias :week :weeks
|
18
26
|
end
|
19
27
|
|
20
28
|
class String
|
29
|
+
def /(path) File.join(self, path.to_s) end
|
21
30
|
def camel_case() split(/_/).map(&:capitalize).join end
|
22
31
|
def decode64() Base64.decode64(self) end
|
23
32
|
def encode64() Base64.encode64(self) end
|
data/lib/yake/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Mancevice
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|