evt-collection 2.4.3.0 → 2.4.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/collection/array.rb +4 -3
- data/lib/collection/collection.rb +17 -9
- data/lib/collection/controls/array.rb +17 -4
- data/lib/collection/controls/member.rb +17 -4
- data/lib/collection/generic.rb +7 -3
- data/lib/collection/set.rb +4 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1382787f77f9cf877782c6d299d737df126dac69ed3d793001d10001e1a0bd75
|
4
|
+
data.tar.gz: b491cf4e131f9bd9645fc6d39ca76979e116847c5e1dba08a2f083d3beb693f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34cffee6f74c1f7cc3bfa17a4bd251f7ccd9629af5d541b7810fd510b7440f9a3e8fc26181dd0706ba87a1df7903cc992454af180cb328c35ca9af32fa568923
|
7
|
+
data.tar.gz: 67148c48ec1ee9e771bbb225c9ae67eaf0ad441df61695ad57fea8abd65f6403778fe0267276f3fdeffb0f1ff0c65a209d1c49a759cfc05ea98f68adf8144c81
|
data/lib/collection/array.rb
CHANGED
@@ -15,47 +15,55 @@ module Collection
|
|
15
15
|
raise ArgumentError, "#{val.inspect} must be a #{type_parameter.name}"
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
items << val
|
19
19
|
|
20
20
|
self
|
21
21
|
end
|
22
22
|
alias :<< :add
|
23
23
|
|
24
24
|
def each(&action)
|
25
|
-
|
25
|
+
items.each(&action)
|
26
26
|
end
|
27
27
|
|
28
28
|
def empty?
|
29
|
-
|
29
|
+
items.empty?
|
30
30
|
end
|
31
31
|
|
32
32
|
def clear
|
33
|
-
|
33
|
+
items.clear
|
34
34
|
self
|
35
35
|
end
|
36
36
|
|
37
37
|
def ==(other)
|
38
|
-
other.class == self.class && other.type_parameter == self.type_parameter && other.
|
38
|
+
other.class == self.class && other.type_parameter == self.type_parameter && other.items == self.items
|
39
39
|
end
|
40
40
|
alias :eql? :==
|
41
41
|
|
42
|
-
def self.Set(items)
|
42
|
+
def self.Set(items, &implementation)
|
43
43
|
items = Kernel::Array(items)
|
44
44
|
|
45
45
|
raise ArgumentError, "Collection can't be empty" if items.empty?
|
46
46
|
|
47
47
|
type_parameter = items[0].class
|
48
48
|
|
49
|
-
Set[type_parameter]
|
49
|
+
cls = Set[type_parameter, &implementation]
|
50
|
+
|
51
|
+
collection = cls.build(items)
|
52
|
+
|
53
|
+
collection
|
50
54
|
end
|
51
55
|
|
52
|
-
def self.Array(items)
|
56
|
+
def self.Array(items, &implementation)
|
53
57
|
items = Kernel::Array(items)
|
54
58
|
|
55
59
|
raise ArgumentError, "Collection can't be empty" if items.empty?
|
56
60
|
|
57
61
|
type_parameter = items[0].class
|
58
62
|
|
59
|
-
Array[type_parameter]
|
63
|
+
cls = Array[type_parameter, &implementation]
|
64
|
+
|
65
|
+
collection = cls.build(items)
|
66
|
+
|
67
|
+
collection
|
60
68
|
end
|
61
69
|
end
|
@@ -2,18 +2,31 @@ module Collection
|
|
2
2
|
module Controls
|
3
3
|
module Array
|
4
4
|
def self.example
|
5
|
-
[
|
5
|
+
[member_class.new, member_class.new]
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
def self.member_class
|
9
|
+
Member::Class.example
|
10
|
+
end
|
11
|
+
|
12
|
+
module RandomMemberClass
|
13
|
+
def self.example
|
14
|
+
cls = member_class
|
15
|
+
[cls.new, cls.new]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.member_class
|
19
|
+
Member::Class.random
|
20
|
+
end
|
9
21
|
end
|
10
22
|
|
11
23
|
module Anomaly
|
12
24
|
def self.example
|
13
|
-
[
|
25
|
+
[member_class.new, member_class.new]
|
14
26
|
end
|
15
27
|
|
16
|
-
|
28
|
+
def self.member_class
|
29
|
+
Member::Class.random
|
17
30
|
end
|
18
31
|
end
|
19
32
|
end
|
@@ -2,14 +2,27 @@ module Collection
|
|
2
2
|
module Controls
|
3
3
|
module Member
|
4
4
|
def self.example
|
5
|
-
|
5
|
+
Class.example.new
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
module Root
|
9
|
+
def self.example
|
10
|
+
Class.random
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
12
|
-
|
14
|
+
module Class
|
15
|
+
def self.example
|
16
|
+
Member
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.random
|
20
|
+
class_name = "Class#{SecureRandom.hex(2).upcase}"
|
21
|
+
Object.const_set(class_name, ::Class.new)
|
22
|
+
end
|
23
|
+
|
24
|
+
class Member
|
25
|
+
end
|
13
26
|
end
|
14
27
|
end
|
15
28
|
end
|
data/lib/collection/generic.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Collection
|
2
2
|
module Generic
|
3
|
-
def [](type_parameter)
|
3
|
+
def [](type_parameter, &implementation)
|
4
4
|
type_parameter_name = constant_name(type_parameter)
|
5
5
|
|
6
6
|
cls = nil
|
7
7
|
unless self.const_defined?(type_parameter_name, false)
|
8
|
-
cls = define_class(type_parameter)
|
8
|
+
cls = define_class(type_parameter, &implementation)
|
9
9
|
set_collection_constant(type_parameter, cls)
|
10
10
|
else
|
11
11
|
cls = const_get(type_parameter_name)
|
@@ -14,7 +14,7 @@ module Collection
|
|
14
14
|
cls
|
15
15
|
end
|
16
16
|
|
17
|
-
def define_class(type_parameter)
|
17
|
+
def define_class(type_parameter, &implementation)
|
18
18
|
cls = Class.new(self) do
|
19
19
|
def self.build(items)
|
20
20
|
instance = new
|
@@ -33,6 +33,10 @@ module Collection
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
if not implementation.nil?
|
37
|
+
cls.class_exec(&implementation)
|
38
|
+
end
|
39
|
+
|
36
40
|
set_collection_constant(type_parameter, cls)
|
37
41
|
|
38
42
|
cls
|
data/lib/collection/set.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-collection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test_bench
|
@@ -57,8 +57,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
|
-
rubygems_version: 3.
|
60
|
+
rubygems_version: 3.4.6
|
61
61
|
signing_key:
|
62
62
|
specification_version: 4
|
63
|
-
summary: Type-checked set
|
63
|
+
summary: Type-checked set and array
|
64
64
|
test_files: []
|