yake 0.5.3 → 0.5.6

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: f2cf5c971016a9089087501bca0a31862c9f2f9ffdd586e2dfb965a190a664da
4
- data.tar.gz: 8eaab803ca82cb0610f8775753e3cc2f1c472833417ff7db3940f0813a3561d0
3
+ metadata.gz: aba47b876459cd693e66fd9920a01e381bb8ab2d697697c78d96f88459505bb9
4
+ data.tar.gz: 583adb36b2bbd8183b7035616a64b13ae3acd33e04c5fdd68336af873047ddf0
5
5
  SHA512:
6
- metadata.gz: ecafe24268afd558fcd5bbf388d03f334112d8c272a1f49688121a70662186ccfbb706a2d96407b8bbc13870515e5f7907a2b267432387e71070aa9bd6d2da29
7
- data.tar.gz: ae003774e4626ee4afc13fef2f0a480813fa91a4a03ba3d1a1480e5c5770a748d2c629949fdb07d6e3941cecfb2eb963276613082fbb7a1866105f4f4a831fd6
6
+ metadata.gz: 60093f85ac70f2dc1d3fe23e378b5bba428191be5cfe18035db864ad54ad640f7ddd007e539831bbd377953d3e30368b5ac85a4f7abf0e3d214f0909ba4a275e
7
+ data.tar.gz: 42f019aa7400f97cc04e55892b3f1f4be312a539e8ea8f29f4596cbaf412ad4696c468d330ddbb0fd935e38aeb78062227aa4983d678f8131a6c78f1ff1925d0
data/README.md CHANGED
@@ -189,15 +189,31 @@ Enable the helpers by requiring the `support` submodule:
189
189
  require 'yake/support'
190
190
  ```
191
191
 
192
- `Hash` transformations:
192
+ `Object` helpers:
193
+
194
+ ```ruby
195
+ MyObject.new.some_method
196
+ # => NoMethodError
197
+
198
+ MyObject.new.try(:some_method)
199
+ # => nil
200
+ ```
201
+
202
+ `Hash` helpers:
193
203
 
194
204
  ```ruby
195
205
  { fizz: 'buzz' }.encode64
196
206
  # => "eyJmaXp6IjoiYnV6eiJ9\n"
197
207
 
208
+ { fizz: 'buzz', jazz: 'fuzz' }.except(:buzz)
209
+ # => { :fizz => 'buzz' }
210
+
198
211
  { fizz: 'buzz' }.strict_encode64
199
212
  # => "eyJmaXp6IjoiYnV6eiJ9"
200
213
 
214
+ { fizz: { buzz: %w[jazz fuzz] } }.stringify_names
215
+ # => { "fizz" => { "buzz" => ["jazz", "fuzz"] } }
216
+
201
217
  { 'fizz' => { 'buzz' => %w[jazz fuzz] } }.symbolize_names
202
218
  # => { :fizz => { :buzz => ["jazz", "fuzz"] } }
203
219
 
@@ -205,7 +221,7 @@ require 'yake/support'
205
221
  # => "fizz=buzz"
206
222
  ```
207
223
 
208
- `Integer` transformations:
224
+ `Integer` helpers:
209
225
 
210
226
  ```ruby
211
227
  7.weeks
@@ -224,7 +240,7 @@ require 'yake/support'
224
240
  # => 2009-02-13 23:31:30 UTC
225
241
  ```
226
242
 
227
- `String` transformations:
243
+ `String` helpers:
228
244
 
229
245
  ```ruby
230
246
  host = 'https://example.com/'
@@ -257,7 +273,7 @@ host / path
257
273
  # => { "fizz" => "buzz" }
258
274
  ```
259
275
 
260
- `Symbol` transformations
276
+ `Symbol` helpers
261
277
 
262
278
  ```ruby
263
279
  :snake_case_symbol.camel_case
@@ -267,7 +283,7 @@ host / path
267
283
  # => :camel_case_symbol
268
284
  ```
269
285
 
270
- `UTC` Time helper
286
+ `UTC` Time helpers
271
287
 
272
288
  ```ruby
273
289
  UTC.at 1234567890
data/lib/yake/support.rb CHANGED
@@ -4,6 +4,7 @@ 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
8
9
  def stringify_names() JSON.parse(to_json) end
9
10
  def symbolize_names() JSON.parse(to_json, symbolize_names: true) end
@@ -25,6 +26,14 @@ class Integer
25
26
  alias :week :weeks
26
27
  end
27
28
 
29
+ class Object
30
+ def try(method, *args, **kwargs)
31
+ send(method, *args, **kwargs)
32
+ rescue
33
+ nil
34
+ end
35
+ end
36
+
28
37
  class String
29
38
  def /(path) File.join(self, path.to_s) end
30
39
  def camel_case() split(/_/).map(&:capitalize).join end
@@ -43,6 +52,7 @@ class Symbol
43
52
  end
44
53
 
45
54
  class UTC < Time
55
+ def initialize(...) super.utc end
46
56
  def self.at(...) super.utc end
47
57
  def self.now() super.utc end
48
58
  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.3'
4
+ VERSION = '0.5.6'
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.3
4
+ version: 0.5.6
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-04-09 00:00:00.000000000 Z
11
+ date: 2022-05-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: