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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6688bf834975490165ca48ff259e22402ec5dc417099c8c2291b4796eb76b5b2
4
- data.tar.gz: d92d5faec4b6bd8b60a65962af51493176a4184a87a52de188f84367bce4002b
3
+ metadata.gz: f2cf5c971016a9089087501bca0a31862c9f2f9ffdd586e2dfb965a190a664da
4
+ data.tar.gz: 8eaab803ca82cb0610f8775753e3cc2f1c472833417ff7db3940f0813a3561d0
5
5
  SHA512:
6
- metadata.gz: 2cf319bba7cd22f2c5f58a66c401dd77dfc2d050214d39d755748d9dc78baed88c603dbfdbbe3d233385e35270c73ec19ab9d3edae394ef9e6dbc2c89c9c1a34
7
- data.tar.gz: 2221a9a8108091b59c9e0eeeb7959c675faee09385847ed5fbf9a75ebbc788be6a734c13eec4a948af883ce1210d9d7fe45401c1e0f3b0cba2efceab03a88df5
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
- #### Event Logging
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
- #### API Routes
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
- #### Zero Dependencies
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 `v0.5`, `yake` comes with a support module for common transformations.
184
+ As of `~> 0.5`, `yake` comes with a support module for common transformations.
185
185
 
186
- `Hash` transformations:
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
- # => 604800
215
+ # => 604_800
209
216
 
210
217
  7.hours
211
- # => 25200
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
- # => 'camel_case_string'
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
- # => 'camel_case_symbol'
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yake
4
- VERSION = '0.5.0'
4
+ VERSION = '0.5.3'
5
5
  end
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.0
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-02-26 00:00:00.000000000 Z
11
+ date: 2022-04-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: