yake 0.5.1 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -11
- data/lib/yake/support.rb +3 -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: 1c140a121e6c40b6342e4b69a30eea098b2ab53008b2b2e7b315d1d0db794dc5
|
4
|
+
data.tar.gz: a10c028d45ce96b4680f2caec4b031064c8f9737c09f4f82ac974ae8e077940d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47a790dbc53bbf1af9c6504f4bddba3a3759c237164f8ff466c876b6fe21c8c22d9e5f3d2d271ec489d25709223e9605f5b4bb4737463bc8dc67a5ea472f0ed9
|
7
|
+
data.tar.gz: 50e642a1e4f7c5fa3d611c0d54811e91391d2a8df7e6796e723694a4db116db050d7e69cd91d041e37073d4efe6a77d34b1509fbb9a5a086d7543642ee1f836d
|
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,20 +168,20 @@ 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
|
|
@@ -208,11 +208,14 @@ require 'yake/support'
|
|
208
208
|
`Integer` transformations:
|
209
209
|
|
210
210
|
```ruby
|
211
|
+
7.weeks
|
212
|
+
# => 4_233_600
|
213
|
+
|
211
214
|
7.days
|
212
|
-
# =>
|
215
|
+
# => 604_800
|
213
216
|
|
214
217
|
7.hours
|
215
|
-
# =>
|
218
|
+
# => 25_200
|
216
219
|
|
217
220
|
7.minutes
|
218
221
|
# => 420
|
@@ -224,8 +227,13 @@ require 'yake/support'
|
|
224
227
|
`String` transformations:
|
225
228
|
|
226
229
|
```ruby
|
230
|
+
host = 'https://example.com/'
|
231
|
+
path = '/path/to/resource'
|
232
|
+
host / path
|
233
|
+
# => "https://example.com/path/to/resource"
|
234
|
+
|
227
235
|
'snake_case_string'.camel_case
|
228
|
-
# => SnakeCaseString
|
236
|
+
# => "SnakeCaseString"
|
229
237
|
|
230
238
|
"Zml6eg==\n".decode64
|
231
239
|
# => "fizz"
|
@@ -234,7 +242,7 @@ require 'yake/support'
|
|
234
242
|
# => "Zml6eg==\n"
|
235
243
|
|
236
244
|
'CamelCaseString'.snake_case
|
237
|
-
# =>
|
245
|
+
# => "camel_case_string"
|
238
246
|
|
239
247
|
'Zml6eg=='.strict_decode64
|
240
248
|
# => "fizz"
|
@@ -256,7 +264,7 @@ require 'yake/support'
|
|
256
264
|
# => :SnakeCaseSymbol
|
257
265
|
|
258
266
|
:CamelCaseSymbol.snake_case
|
259
|
-
# =>
|
267
|
+
# => :camel_case_symbol
|
260
268
|
```
|
261
269
|
|
262
270
|
`UTC` Time helper
|
data/lib/yake/support.rb
CHANGED
@@ -4,7 +4,9 @@ require 'time'
|
|
4
4
|
|
5
5
|
class Hash
|
6
6
|
def encode64() to_json.encode64 end
|
7
|
+
def except(*keys) self.reject { |key,_| keys.include? key } end
|
7
8
|
def strict_encode64() to_json.strict_encode64 end
|
9
|
+
def stringify_names() JSON.parse(to_json) end
|
8
10
|
def symbolize_names() JSON.parse(to_json, symbolize_names: true) end
|
9
11
|
def to_form() URI.encode_www_form(self) end
|
10
12
|
end
|
@@ -25,6 +27,7 @@ class Integer
|
|
25
27
|
end
|
26
28
|
|
27
29
|
class String
|
30
|
+
def /(path) File.join(self, path.to_s) end
|
28
31
|
def camel_case() split(/_/).map(&:capitalize).join end
|
29
32
|
def decode64() Base64.decode64(self) end
|
30
33
|
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.4
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|