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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acdf3ddd8cf03e33f61d6163eaf6a7c0ae963c783eeca9ed1f38d64f4e1acfb3
4
- data.tar.gz: 172a238259d0896be26f26ecfbdc1a0def703f7004204a6c292fb844c3181048
3
+ metadata.gz: 1382787f77f9cf877782c6d299d737df126dac69ed3d793001d10001e1a0bd75
4
+ data.tar.gz: b491cf4e131f9bd9645fc6d39ca76979e116847c5e1dba08a2f083d3beb693f4
5
5
  SHA512:
6
- metadata.gz: 8697c8f22452bc0e1a0836cc8e5b34c24e3a00f405a2295be63eceda8b7104488900c1da74884d2d6f9f5c396ceec88f98699bc87f0715dc205a493e088c6d20
7
- data.tar.gz: 145a3c73e2b3fcdd1496c4a3aba907103aa5172fee7b1b1e4c1295844a5372287c8bfbb49ba88f3e86c1019bf1fe2bae3ca451198a0fa8baa201c3cbdfd04a3a
6
+ metadata.gz: 34cffee6f74c1f7cc3bfa17a4bd251f7ccd9629af5d541b7810fd510b7440f9a3e8fc26181dd0706ba87a1df7903cc992454af180cb328c35ca9af32fa568923
7
+ data.tar.gz: 67148c48ec1ee9e771bbb225c9ae67eaf0ad441df61695ad57fea8abd65f6403778fe0267276f3fdeffb0f1ff0c65a209d1c49a759cfc05ea98f68adf8144c81
@@ -2,12 +2,13 @@ module Collection
2
2
  class Array
3
3
  include Collection
4
4
 
5
- def content
6
- @content ||= ::Array.new
5
+ def items
6
+ @items ||= ::Array.new
7
7
  end
8
+ alias :content :items
8
9
 
9
10
  def last
10
- content.last
11
+ items.last
11
12
  end
12
13
 
13
14
  def length
@@ -15,47 +15,55 @@ module Collection
15
15
  raise ArgumentError, "#{val.inspect} must be a #{type_parameter.name}"
16
16
  end
17
17
 
18
- content << val
18
+ items << val
19
19
 
20
20
  self
21
21
  end
22
22
  alias :<< :add
23
23
 
24
24
  def each(&action)
25
- content.each(&action)
25
+ items.each(&action)
26
26
  end
27
27
 
28
28
  def empty?
29
- content.empty?
29
+ items.empty?
30
30
  end
31
31
 
32
32
  def clear
33
- content.clear
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.content == self.content
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].build(items)
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].build(items)
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
- [Member.new, Member.new]
5
+ [member_class.new, member_class.new]
6
6
  end
7
7
 
8
- class Member
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
- [Array::Member.new, Member.new]
25
+ [member_class.new, member_class.new]
14
26
  end
15
27
 
16
- class Member
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
- example_class.new
5
+ Class.example.new
6
6
  end
7
7
 
8
- def self.example_class
9
- Member
8
+ module Root
9
+ def self.example
10
+ Class.random
11
+ end
10
12
  end
11
13
 
12
- class Member
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
@@ -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
@@ -2,12 +2,13 @@ module Collection
2
2
  class Set
3
3
  include Collection
4
4
 
5
- def content
6
- @content ||= ::Set.new
5
+ def items
6
+ @items ||= ::Set.new
7
7
  end
8
+ alias :content :items
8
9
 
9
10
  def last
10
- content.to_a.last
11
+ items.to_a.last
11
12
  end
12
13
 
13
14
  def length
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.3.0
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: 2022-10-03 00:00:00.000000000 Z
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.3.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: []