lite-ruby 1.1.9 → 1.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b32c7f149936f48b462434da3dd84d20667a9bbe0771fd284df29b8d515a8339
4
- data.tar.gz: a220ce1b98faa3487d4a6fead4eaf9a7dccf00b6c480d2657e94f3e449bd5884
3
+ metadata.gz: 63d0d01fd2b88f0a9362009571181cd8d13f1c504662138d2c5b811cf1e8282c
4
+ data.tar.gz: b1f8de0ba8ab9c9516a59e949108d476527d285d0397c392cd03968f771e032c
5
5
  SHA512:
6
- metadata.gz: 7e878a158ba8b9118ee0ad83aee4538b55ab70a379bc288c4985f3243901d4a4b3b481669fbff8dfde32b262f53294f0ecd35061a201acc50e64e73b5eabf8fa
7
- data.tar.gz: e51ce8fa082348bca0020a6190d72b8845944f01e230ba5f6c67c6f405f6311c0ca002d02fee9c93037c11d4e762c1d1b6df164c3ab7b35a3bd573dd09926932
6
+ metadata.gz: da98aab18c440e3b346ace43c94773688930837ce9df4ada5ecab7e8512e957e63cb126103b5d7e4dceaa3d124af0983797dc352a53767b1791fa83389ed9cf4
7
+ data.tar.gz: 56a911edc10244b5316665eabb0b8b68d2c572362e28a7a3b60ca6760008875c9736f92904f70b1c0367cb503f7a6c9eb9459464273c15bfcc26364caf774221
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.1.10] - 2021-06-21
10
+ ### Changed
11
+ - Struct `[]` to be accessible via `attributes`
12
+ ### Removed
13
+ - OpenStruct `[]` and `[]=` existing methods
14
+
9
15
  ## [1.1.9] - 2021-05-26
10
16
  ### Added
11
17
  - Added Array => `match`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-ruby (1.1.9)
4
+ lite-ruby (1.1.10)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -28,7 +28,7 @@ GEM
28
28
  ast (2.4.2)
29
29
  builder (3.2.4)
30
30
  colorize (0.8.1)
31
- concurrent-ruby (1.1.8)
31
+ concurrent-ruby (1.1.9)
32
32
  crass (1.0.6)
33
33
  diff-lcs (1.4.4)
34
34
  erubi (1.10.0)
@@ -40,13 +40,13 @@ GEM
40
40
  railties (>= 3.0.0)
41
41
  i18n (1.8.10)
42
42
  concurrent-ruby (~> 1.0)
43
- loofah (2.9.1)
43
+ loofah (2.10.0)
44
44
  crass (~> 1.0.2)
45
45
  nokogiri (>= 1.5.9)
46
46
  method_source (1.0.0)
47
- mini_portile2 (2.5.1)
47
+ mini_portile2 (2.5.3)
48
48
  minitest (5.14.4)
49
- nokogiri (1.11.6)
49
+ nokogiri (1.11.7)
50
50
  mini_portile2 (~> 2.5.0)
51
51
  racc (~> 1.4)
52
52
  parallel (1.20.1)
@@ -84,23 +84,23 @@ 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.15.0)
87
+ rubocop (1.17.0)
88
88
  parallel (~> 1.10)
89
89
  parser (>= 3.0.0.0)
90
90
  rainbow (>= 2.2.2, < 4.0)
91
91
  regexp_parser (>= 1.8, < 3.0)
92
92
  rexml
93
- rubocop-ast (>= 1.5.0, < 2.0)
93
+ rubocop-ast (>= 1.7.0, < 2.0)
94
94
  ruby-progressbar (~> 1.7)
95
95
  unicode-display_width (>= 1.4.0, < 3.0)
96
- rubocop-ast (1.6.0)
96
+ rubocop-ast (1.7.0)
97
97
  parser (>= 3.0.1.1)
98
98
  rubocop-performance (1.11.3)
99
99
  rubocop (>= 1.7.0, < 2.0)
100
100
  rubocop-ast (>= 0.4.0)
101
101
  rubocop-rake (0.5.1)
102
102
  rubocop
103
- rubocop-rspec (2.3.0)
103
+ rubocop-rspec (2.4.0)
104
104
  rubocop (~> 1.0)
105
105
  rubocop-ast (>= 1.1.0)
106
106
  ruby-progressbar (1.11.0)
@@ -129,4 +129,4 @@ DEPENDENCIES
129
129
  rubocop-rspec
130
130
 
131
131
  BUNDLED WITH
132
- 2.2.18
132
+ 2.2.19
data/docs/OPEN_STRUCT.md CHANGED
@@ -9,26 +9,6 @@ OpenStruct.new(name: 'bob', age: 60) do |o|
9
9
  end
10
10
  ```
11
11
 
12
- `[]`
13
- ------
14
- Access a value in the OpenStruct by key, like a Hash.
15
-
16
- ```ruby
17
- person = OpenStruct.new(name: 'bob', age: 60)
18
-
19
- person['name'] #=> 'bob'
20
- ```
21
-
22
- `[]=`
23
- ------
24
- Store a value in the OpenStruct by key, like a Hash.
25
-
26
- ```ruby
27
- person = OpenStruct.new(name: 'bob', age: 60)
28
-
29
- person['name'] = 'tim'
30
- ```
31
-
32
12
  `attributes`
33
13
  ------
34
14
  Returns the key values as a hash of the assigned struct.
data/docs/STRUCT.md CHANGED
@@ -9,6 +9,7 @@ person = Struct.new(:name, :age)
9
9
  person.new('bob', 60)
10
10
 
11
11
  person['name'] #=> 'bob'
12
+ person['fake'] #=> nil
12
13
  ```
13
14
 
14
15
  `[]=`
@@ -20,24 +20,12 @@ if Lite::Ruby.configuration.monkey_patches.include?('open_struct')
20
20
  yield self if block && block.arity == 1
21
21
  end
22
22
 
23
- def [](key)
24
- key = key.to_sym unless key.is_a?(Symbol)
25
- @table[key]
26
- end
27
-
28
- def []=(key, val)
29
- raise TypeError, "can't modify frozen #{self.class}", caller(1) if frozen?
30
-
31
- key = key.to_sym unless key.is_a?(Symbol)
32
- @table[key] = val
33
- end
34
-
35
23
  def attributes
36
24
  @table
37
25
  end
38
26
 
39
27
  def replace(args)
40
- args.each_pair { |key, val| send("#{key}=", val) }
28
+ args.each { |key, val| send("#{key}=", val) }
41
29
  end
42
30
 
43
31
  def to_hash(table: true)
@@ -53,5 +41,14 @@ if Lite::Ruby.configuration.monkey_patches.include?('open_struct')
53
41
  alias as_json to_json
54
42
  alias to_h to_hash
55
43
 
44
+ private
45
+
46
+ def new_ostruct_member!(name)
47
+ return if is_method_protected!(name)
48
+
49
+ define_singleton_method!(name) { @table[name] }
50
+ define_singleton_method!("#{name}=") { |x| @table[name] = x }
51
+ end
52
+
56
53
  end
57
54
  end
@@ -4,7 +4,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('struct')
4
4
  class Struct
5
5
 
6
6
  def [](key)
7
- send(key)
7
+ attributes[key.to_sym]
8
8
  end
9
9
 
10
10
  def []=(key, val)
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Ruby
5
5
 
6
- VERSION = '1.1.9'
6
+ VERSION = '1.1.10'
7
7
 
8
8
  end
9
9
  end
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.1.9
4
+ version: 1.1.10
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-05-27 00:00:00.000000000 Z
11
+ date: 2021-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  - !ruby/object:Gem::Version
223
223
  version: '0'
224
224
  requirements: []
225
- rubygems_version: 3.2.18
225
+ rubygems_version: 3.2.19
226
226
  signing_key:
227
227
  specification_version: 4
228
228
  summary: Collection of useful Ruby methods for its primitive classes