lite-ruby 1.0.25 → 1.0.26
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/.rubocop.yml +2 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +6 -3
- data/docs/HASH.md +13 -2
- data/lib/lite/ruby/hash.rb +8 -3
- data/lib/lite/ruby/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: a60b6620f1f96b3e70290ffef9a747511107a86449742e1be095be4aa0ffea91
|
4
|
+
data.tar.gz: 23e7fdc0cf9e7948812d95b4f36528eb264d7e041f7986d86cf1ebff770d70a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 883d36b8714d876f6a5f31da52da55c1da86641033724c94e2e0045e261e6e2427a4f1cb3f2d9bda234d564018f97f4c21efa55e8d9276826cead809d6c7f949
|
7
|
+
data.tar.gz: a457a5207c0e203689ad0064232032b7419e13c9297e1ad7365ea8f5c0f699736eb5b9851a94c475262b21ab8429ae2772240e8d8f7046b6113ba53b61889d2c
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.0.26] - 2020-05-22
|
10
|
+
### Changed
|
11
|
+
- Changed hash `to_open_struct` and `to_object` to be independent methods
|
12
|
+
|
9
13
|
## [1.0.25] - 2020-05-20
|
10
14
|
### Added
|
11
15
|
- Added Hash => `to_open_struct`
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lite-ruby (1.0.
|
4
|
+
lite-ruby (1.0.26)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -81,14 +81,17 @@ GEM
|
|
81
81
|
diff-lcs (>= 1.2.0, < 2.0)
|
82
82
|
rspec-support (~> 3.9.0)
|
83
83
|
rspec-support (3.9.3)
|
84
|
-
rubocop (0.
|
84
|
+
rubocop (0.84.0)
|
85
85
|
parallel (~> 1.10)
|
86
86
|
parser (>= 2.7.0.1)
|
87
87
|
rainbow (>= 2.2.2, < 4.0)
|
88
88
|
rexml
|
89
|
+
rubocop-ast (>= 0.0.3)
|
89
90
|
ruby-progressbar (~> 1.7)
|
90
91
|
unicode-display_width (>= 1.4.0, < 2.0)
|
91
|
-
rubocop-
|
92
|
+
rubocop-ast (0.0.3)
|
93
|
+
parser (>= 2.7.0.1)
|
94
|
+
rubocop-performance (1.6.0)
|
92
95
|
rubocop (>= 0.71.0)
|
93
96
|
rubocop-rspec (1.39.0)
|
94
97
|
rubocop (>= 0.68.1)
|
data/docs/HASH.md
CHANGED
@@ -425,12 +425,22 @@ Symbolize and underscore hash keys.
|
|
425
425
|
{ 'firstName' => 'foo', 'last Name' => 'test' }.symbolize_and_underscore_keys #=> { first_name: 'foo', last_name: 'test' }
|
426
426
|
```
|
427
427
|
|
428
|
-
`
|
428
|
+
`to_object` aka `to_o`
|
429
|
+
------
|
430
|
+
Converts a hash and all nested hashes to open structs.
|
431
|
+
|
432
|
+
```ruby
|
433
|
+
{ foo: { bar: true } }.to_object.foo.bar #=> true
|
434
|
+
{ foo: { bar: true } }.to_object.foo.bax #=> nil
|
435
|
+
```
|
436
|
+
|
437
|
+
`to_open_struct`
|
429
438
|
------
|
430
439
|
Converts a hash to an open struct to have an object like API.
|
431
440
|
|
432
441
|
```ruby
|
433
|
-
{ foo: { bar: true } }.to_open_struct.foo
|
442
|
+
{ foo: { bar: true } }.to_open_struct.foo #=> { bar: true }
|
443
|
+
{ foo: { bar: true } }.to_open_struct.bax #=> nil
|
434
444
|
```
|
435
445
|
|
436
446
|
`to_struct`
|
@@ -439,6 +449,7 @@ Converts a hash to a struct to have an object like API.
|
|
439
449
|
|
440
450
|
```ruby
|
441
451
|
{ foo: { bar: true } }.to_struct.foo #=> { bar: true }
|
452
|
+
{ foo: { bar: true } }.to_struct.bax #=> Raises error
|
442
453
|
```
|
443
454
|
|
444
455
|
`update_each`
|
data/lib/lite/ruby/hash.rb
CHANGED
@@ -440,12 +440,17 @@ if Lite::Ruby.configuration.monkey_patches.include?('hash')
|
|
440
440
|
replace(symbolize_and_underscore_keys)
|
441
441
|
end
|
442
442
|
|
443
|
-
def
|
443
|
+
def to_object
|
444
444
|
JSON.parse(to_json, object_class: OpenStruct)
|
445
445
|
end
|
446
446
|
|
447
|
-
alias to_object
|
448
|
-
|
447
|
+
alias to_o to_object
|
448
|
+
|
449
|
+
def to_open_struct(lazy: true)
|
450
|
+
struct = OpenStruct.new(self)
|
451
|
+
struct.methods(lazy)
|
452
|
+
struct
|
453
|
+
end
|
449
454
|
|
450
455
|
def to_struct
|
451
456
|
struct = Struct.new(*keys)
|
data/lib/lite/ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lite-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|