lite-ruby 1.1.15 → 1.2.0
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/CHANGELOG.md +4 -0
- data/Gemfile.lock +5 -5
- data/docs/OPEN_STRUCT.md +0 -9
- data/lib/lite/ruby/open_struct.rb +0 -48
- 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: 6bd71beaa77809d81b1e0bebf2a5c1796644e4ecc3236bbefbc85683c348e85a
|
4
|
+
data.tar.gz: 9d3d106d3fc6e87844a59b05be070bd0a91ba613a1e31ba3d3b06bdb2d73330c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a61410e6e67e6d3ccef314c5fdfb2cbb419469ef8106ca3b6a4e20dddefc9254978566d0d1260f9292c2ef65da07c2c8afe2bf3505ce09ef3d67cb17eed2dd73
|
7
|
+
data.tar.gz: 54c104fb81fa10b5df25a634ce802acd49ee8b058daa19e77b8cb689d8638c42edf6b4e4481fb58853d4087bce2e9e919055fb056abbde9e14c7f314e076fc31
|
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.2.0] - 2021-07-09
|
10
|
+
### Removed
|
11
|
+
- OpenStruct block initialization due to unreliability
|
12
|
+
|
9
13
|
## [1.1.15] - 2021-07-05
|
10
14
|
### Changed
|
11
15
|
- Added more OpenStruct backwards compatibility
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lite-ruby (1.
|
4
|
+
lite-ruby (1.2.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -50,7 +50,7 @@ GEM
|
|
50
50
|
mini_portile2 (~> 2.5.0)
|
51
51
|
racc (~> 1.4)
|
52
52
|
parallel (1.20.1)
|
53
|
-
parser (3.0.
|
53
|
+
parser (3.0.2.0)
|
54
54
|
ast (~> 2.4.1)
|
55
55
|
racc (1.5.2)
|
56
56
|
rack (2.2.3)
|
@@ -68,7 +68,7 @@ GEM
|
|
68
68
|
rake (>= 0.13)
|
69
69
|
thor (~> 1.0)
|
70
70
|
rainbow (3.0.0)
|
71
|
-
rake (13.0.
|
71
|
+
rake (13.0.6)
|
72
72
|
regexp_parser (2.1.1)
|
73
73
|
rexml (3.2.5)
|
74
74
|
rspec (3.10.0)
|
@@ -84,7 +84,7 @@ GEM
|
|
84
84
|
diff-lcs (>= 1.2.0, < 2.0)
|
85
85
|
rspec-support (~> 3.10.0)
|
86
86
|
rspec-support (3.10.2)
|
87
|
-
rubocop (1.18.
|
87
|
+
rubocop (1.18.3)
|
88
88
|
parallel (~> 1.10)
|
89
89
|
parser (>= 3.0.0.0)
|
90
90
|
rainbow (>= 2.2.2, < 4.0)
|
@@ -95,7 +95,7 @@ GEM
|
|
95
95
|
unicode-display_width (>= 1.4.0, < 3.0)
|
96
96
|
rubocop-ast (1.7.0)
|
97
97
|
parser (>= 3.0.1.1)
|
98
|
-
rubocop-performance (1.11.
|
98
|
+
rubocop-performance (1.11.4)
|
99
99
|
rubocop (>= 1.7.0, < 2.0)
|
100
100
|
rubocop-ast (>= 0.4.0)
|
101
101
|
rubocop-rake (0.6.0)
|
data/docs/OPEN_STRUCT.md
CHANGED
@@ -1,14 +1,5 @@
|
|
1
1
|
# OpenStruct
|
2
2
|
|
3
|
-
`Initialize`
|
4
|
-
Allows the initialization of an OpenStruct with a setter block.
|
5
|
-
|
6
|
-
```ruby
|
7
|
-
OpenStruct.new(name: 'bob', age: 60) do |o|
|
8
|
-
o.gender = :M
|
9
|
-
end
|
10
|
-
```
|
11
|
-
|
12
3
|
`attributes`
|
13
4
|
------
|
14
5
|
Returns the key values as a hash of the assigned struct.
|
@@ -5,21 +5,6 @@ if Lite::Ruby.configuration.monkey_patches.include?('open_struct')
|
|
5
5
|
|
6
6
|
class OpenStruct
|
7
7
|
|
8
|
-
def initialize(hash = nil, &block)
|
9
|
-
@table = if block && block.arity == 2
|
10
|
-
Hash.new(&block)
|
11
|
-
else
|
12
|
-
{}
|
13
|
-
end
|
14
|
-
|
15
|
-
hash&.each do |key, val|
|
16
|
-
@table[key.to_sym] = val
|
17
|
-
new_ostruct_member!(key)
|
18
|
-
end
|
19
|
-
|
20
|
-
yield self if block && block.arity == 1
|
21
|
-
end
|
22
|
-
|
23
8
|
def attributes
|
24
9
|
@table
|
25
10
|
end
|
@@ -41,38 +26,5 @@ if Lite::Ruby.configuration.monkey_patches.include?('open_struct')
|
|
41
26
|
alias as_json to_json
|
42
27
|
alias to_h to_hash
|
43
28
|
|
44
|
-
private
|
45
|
-
|
46
|
-
# rubocop:disable Metrics/MethodLength, Naming/PredicateName
|
47
|
-
def is_method_protected!(name)
|
48
|
-
return false unless respond_to?(name, true)
|
49
|
-
return true if name.match?(/!$/)
|
50
|
-
|
51
|
-
method = 'method'
|
52
|
-
method << '!' if respond_to?(:method!)
|
53
|
-
owner = send(method, name).owner
|
54
|
-
|
55
|
-
if owner.instance_of?(::Class)
|
56
|
-
owner < ::OpenStruct
|
57
|
-
else
|
58
|
-
self.class.ancestors.any? do |mod|
|
59
|
-
return false if mod == ::OpenStruct
|
60
|
-
|
61
|
-
mod == owner
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
# rubocop:enable Metrics/MethodLength, Naming/PredicateName
|
66
|
-
|
67
|
-
def new_ostruct_member!(name)
|
68
|
-
return if is_method_protected!(name)
|
69
|
-
|
70
|
-
method = 'define_singleton_method'
|
71
|
-
method << '!' if respond_to?(:define_singleton_method!)
|
72
|
-
|
73
|
-
send(method, name) { @table[name] }
|
74
|
-
send(method, "#{name}=") { |x| @table[name] = x }
|
75
|
-
end
|
76
|
-
|
77
29
|
end
|
78
30
|
end
|
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.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|