lite-ruby 1.1.14 → 1.3.1

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: ff28b7935f151e1b0b380b88a846a43d5c26fd0ed8f0ec3868d8766c906d7a86
4
- data.tar.gz: 44d6ba04ae35be6ccc79030b8cf818cf7c073962619190e11ac0082146650e7a
3
+ metadata.gz: 8bbae849a2073a389f4e38ff5e8841d572f305c4bdb6a973595eda419c3638b7
4
+ data.tar.gz: e983d29b4799e2d9c608f680d0dfa93b8f813b9bdaf802860b6a867de4fa4159
5
5
  SHA512:
6
- metadata.gz: db466696e81b718156b43a0e9ae3f78f0c5c0dfd960b53fc34aaf4ef393be7b5aef9bf31acbb13d9612be1c9305c4bcc43aa4996f19bf3776ce57cbc38448238
7
- data.tar.gz: cec62b1c8ab6f99e88cc9d775d91411543ea016e9f40ea4c2c3d5fac7a8770bd5f985cf1a598c8a0c4a4a1b1505ae06d8dbda75ea3e3361b3a7ac5f01acf4307
6
+ metadata.gz: 264c6227410b80819e384fc612c4b3bd7802b5b021563c62027feb3901f9d1e023170639516ca0fde18fbda591d49595426b5e46d495c4a72f3d0680053884c8
7
+ data.tar.gz: b64b81b77447af8133eae36c57e3295f0073064e1138ec66380ac43410a9b794a59bffa22d4ef6bd00550adfcb9bd532dfaacea66fb2ad9218a07c7197a469f8
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ require:
3
3
  - rubocop-rake
4
4
  - rubocop-rspec
5
5
  AllCops:
6
- TargetRubyVersion: 2.7
6
+ TargetRubyVersion: 3.0
7
7
  NewCops: enable
8
8
  DisplayCopNames: true
9
9
  DisplayStyleGuide: true
data/CHANGELOG.md CHANGED
@@ -6,6 +6,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.3.1] - 2021-07-19
10
+ ### Removed
11
+ - Struct `[]` and `[]=` existing methods
12
+
13
+ ## [1.3.0] - 2021-07-19
14
+ ### Added
15
+ - Added Ruby 3.0 support
16
+
17
+ ## [1.2.0] - 2021-07-09
18
+ ### Removed
19
+ - OpenStruct block initialization due to unreliability
20
+
21
+ ## [1.1.15] - 2021-07-05
22
+ ### Changed
23
+ - Added more OpenStruct backwards compatibility
24
+
9
25
  ## [1.1.14] - 2021-07-05
10
26
  ### Changed
11
27
  - Fixed mistake in OpenStruct backwards compatibility
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-ruby (1.1.14)
4
+ lite-ruby (1.3.1)
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.1.1)
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.3)
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.2)
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)
@@ -93,9 +93,9 @@ GEM
93
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.7.0)
96
+ rubocop-ast (1.8.0)
97
97
  parser (>= 3.0.1.1)
98
- rubocop-performance (1.11.3)
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)
@@ -129,4 +129,4 @@ DEPENDENCIES
129
129
  rubocop-rspec
130
130
 
131
131
  BUNDLED WITH
132
- 2.2.19
132
+ 2.2.24
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.
data/docs/STRUCT.md CHANGED
@@ -1,30 +1,5 @@
1
1
  # Struct
2
2
 
3
- `[]`
4
- ------
5
- Access a value in the Struct by key, like a Hash.
6
-
7
- ```ruby
8
- person = Struct.new(:name, :age)
9
- person.new('bob', 60)
10
-
11
- person['name'] #=> 'bob'
12
- person['fake'] #=> nil
13
- ```
14
-
15
- `[]=`
16
- ------
17
- Store a value in the Struct by key, like a Hash.
18
-
19
- ```ruby
20
- person = Struct.new(:name, :age)
21
- person.new('bob', 60)
22
-
23
- person['name'] = 'tim'
24
-
25
- person['name'] #=> 'tim'
26
- ```
27
-
28
3
  `attributes`
29
4
  ------
30
5
  Returns the key values 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,36 +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
- owner = method!(name).owner
52
-
53
- if owner.instance_of?(::Class)
54
- owner < ::OpenStruct
55
- else
56
- self.class.ancestors.any? do |mod|
57
- return false if mod == ::OpenStruct
58
-
59
- mod == owner
60
- end
61
- end
62
- end
63
- # rubocop:enable Metrics/MethodLength, Naming/PredicateName
64
-
65
- def new_ostruct_member!(name)
66
- return if is_method_protected!(name)
67
-
68
- method = 'define_singleton_method'
69
- method << '!' if respond_to?(:define_singleton_method!)
70
-
71
- send(method, name) { @table[name] }
72
- send(method, "#{name}=") { |x| @table[name] = x }
73
- end
74
-
75
29
  end
76
30
  end
@@ -3,20 +3,12 @@
3
3
  if Lite::Ruby.configuration.monkey_patches.include?('struct')
4
4
  class Struct
5
5
 
6
- def [](key)
7
- attributes[key.to_sym]
8
- end
9
-
10
- def []=(key, val)
11
- send("#{key}=", val)
12
- end
13
-
14
6
  def attributes
15
7
  each_pair.with_object({}) { |(key, val), hash| hash[key] = val }
16
8
  end
17
9
 
18
10
  def replace(args)
19
- args.each_pair { |key, val| send("#{key}=", val) }
11
+ args.each_pair { |key, val| self[key] = val }
20
12
  end
21
13
 
22
14
  end
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Ruby
5
5
 
6
- VERSION = '1.1.14'
6
+ VERSION = '1.3.1'
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.14
4
+ version: 1.3.1
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-05 00:00:00.000000000 Z
11
+ date: 2021-07-20 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.19
225
+ rubygems_version: 3.2.24
226
226
  signing_key:
227
227
  specification_version: 4
228
228
  summary: Collection of useful Ruby methods for its primitive classes