dsl_compose 2.15.0 → 2.15.3

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: af6d832ff6a9dbe899f76297a60555caf170045743dd6cf83cbabb6b26e87892
4
- data.tar.gz: a9628422e02b4cac58263ad72938c0297f42c75d81dd3337e43d227ec71ba664
3
+ metadata.gz: 2fd1fd8c1e9fa1f20c3a46fa9d27bd9aca1cf5f4529e8faa2e86ba5b972ef211
4
+ data.tar.gz: ca41bb7b1ef3f699b0d96baf77dee95fb27a7fcf0d26b7dcc37838b3a575dbff
5
5
  SHA512:
6
- metadata.gz: 82ee9d6210446826e52dec60de79f414d9769e4e571e2d95ccf41c66da3231728ad6ffecb9f55beedeceecbf651c286fc0499b076301d3c7f858fa84bd0d5106
7
- data.tar.gz: d30c48922a712e86138867c4b4de9daee988bf99b3af052a407a8b8bc739f292c974a143ea6b93c0de35b84a981d763c08e3da799114a17ca68f1ff4e6b086f4
6
+ metadata.gz: 53328f870487ad66a45bf7d179a5085d39049a0eb02eefacaa7e38a386bdd2fa043cd9fb7a887888ed53156d6b6cdf9fe828e19c53fd0c768f8e81d3b666ec8d
7
+ data.tar.gz: d904bb0b9c0188755031e678099fa8644f5712433eea0471b0f581ea1247d6f29725766f638383d412bfb0fa7a187d1bcb5bba51ec61fd725ab171446cc87e7b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.15.3](https://github.com/craigulliott/dsl_compose/compare/v2.15.2...v2.15.3) (2023-10-03)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * updating class sorting method so that it is stable (we were getting different results on ubuntu/the CI server) ([70139a1](https://github.com/craigulliott/dsl_compose/commit/70139a11fa5190c3019e95199656385676a10177))
9
+
10
+ ## [2.15.2](https://github.com/craigulliott/dsl_compose/compare/v2.15.1...v2.15.2) (2023-10-03)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * fix: sorting classes by ancestry chain (i.e. ancestors before descendants) in the parser ([c301c4b](https://github.com/craigulliott/dsl_compose/commit/c301c4b9e1393c996d5b29dd7a6fd0e2758ae109))
16
+
17
+ ## [2.15.1](https://github.com/craigulliott/dsl_compose/compare/v2.15.0...v2.15.1) (2023-10-03)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * sorting classes by ancestry chain (i.e. ancestors before descendants) in the parser ([4e7dd6f](https://github.com/craigulliott/dsl_compose/commit/4e7dd6fd302c50ee3147f76f59a52089fb6f39ee))
23
+
3
24
  ## [2.15.0](https://github.com/craigulliott/dsl_compose/compare/v2.14.3...v2.15.0) (2023-10-03)
4
25
 
5
26
 
data/README.md CHANGED
@@ -371,7 +371,7 @@ In addition to parser classes (or as a useful tool within parser classes) you ca
371
371
  # simple API to access the arguments, methods and method arguments which
372
372
  # were provided when using a DSL.
373
373
  #
374
- # In the example below, MyClass is a class, or descendent of a class which
374
+ # In the example below, MyClass is a class, or descendant of a class which
375
375
  # had a DSL defined on it with the name :my_dsl.
376
376
  #
377
377
  # An error will be raised if a DSL with the provided name was never defined
@@ -82,7 +82,7 @@ module DSLCompose
82
82
  def get_last_dsl_execution klass, dsl_name
83
83
  # note that this method does not need to do any special sorting, the required
84
84
  # order for getting the most recent execution is already guaranteed because
85
- # parent classes in ruby always have to be evaluated before their descendents
85
+ # parent classes in ruby always have to be evaluated before their descendants
86
86
  class_dsl_executions(klass, dsl_name, true, true).last
87
87
  end
88
88
 
@@ -3,7 +3,7 @@
3
3
  module DSLCompose
4
4
  class Parser
5
5
  class ForChildrenOfParser
6
- class Descendents
6
+ class Descendants
7
7
  def initialize base_class, final_children_only, skip_classes = []
8
8
  @base_class = base_class
9
9
  @final_children_only = final_children_only
@@ -14,10 +14,21 @@ module DSLCompose
14
14
  # all objects which extend the provided base class
15
15
  extending_classes = subclasses @base_class
16
16
 
17
- # sort the results, classes are ordered first by the depth of their namespace, and second
18
- # by the presence of decendents and finally by their name
17
+ # sort the results
18
+ #
19
+ # classes are ordered first by name
19
20
  extending_classes.sort_by! do |child_class|
20
- "#{child_class.name.split("::").count}_#{has_descendents(child_class) ? 0 : 1}_#{child_class.name}"
21
+ "#{child_class.name.split("::").count}_#{has_descendants(child_class) ? 0 : 1}_#{child_class.name}"
22
+ end
23
+ # then by ansestory chain (i.e. ancestors before descendants)
24
+ extending_classes.sort! do |a, b|
25
+ if a < b
26
+ 1
27
+ elsif a > b
28
+ -1
29
+ else
30
+ a.name <=> b.name
31
+ end
21
32
  end
22
33
 
23
34
  # reject any classes which we are skipping
@@ -27,9 +38,9 @@ module DSLCompose
27
38
 
28
39
  # if this is not a final child, but we are processing final children only, then skip it
29
40
  if @final_children_only
30
- # reject any classes which have descendents
41
+ # reject any classes which have descendants
31
42
  extending_classes.reject! do |child_class|
32
- has_descendents child_class
43
+ has_descendants child_class
33
44
  end
34
45
  end
35
46
 
@@ -45,7 +56,7 @@ module DSLCompose
45
56
  }.flatten
46
57
  end
47
58
 
48
- def has_descendents base_class
59
+ def has_descendants base_class
49
60
  base_class.subclasses.count { |subclass| class_is_still_defined? subclass } > 0
50
61
  end
51
62
 
@@ -56,8 +56,8 @@ module DSLCompose
56
56
  end
57
57
  end
58
58
 
59
- # yeild the block for all descendents of the provided base_class
60
- Descendents.new(base_class, final_children_only, skip_classes).classes.each do |child_class|
59
+ # yeild the block for all descendants of the provided base_class
60
+ Descendants.new(base_class, final_children_only, skip_classes).classes.each do |child_class|
61
61
  # determine which arguments to send to the block
62
62
  args = {}
63
63
  if BlockArguments.accepts_argument?(:child_class, &block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DSLCompose
4
- VERSION = "2.15.0"
4
+ VERSION = "2.15.3"
5
5
  end
data/lib/dsl_compose.rb CHANGED
@@ -42,7 +42,7 @@ require "dsl_compose/interpreter"
42
42
 
43
43
  require "dsl_compose/parser/for_children_of_parser/for_dsl_parser/for_method_parser"
44
44
  require "dsl_compose/parser/for_children_of_parser/for_dsl_parser"
45
- require "dsl_compose/parser/for_children_of_parser/descendents"
45
+ require "dsl_compose/parser/for_children_of_parser/descendants"
46
46
  require "dsl_compose/parser/for_children_of_parser"
47
47
  require "dsl_compose/parser/block_arguments"
48
48
  require "dsl_compose/parser"
@@ -2,7 +2,7 @@
2
2
  module DSLCompose
3
3
  class Parser
4
4
  class ForChildrenOfParser
5
- class Descendents
5
+ class Descendants
6
6
  @base_class: singleton(Object)
7
7
  @skip_classes: Array[String]
8
8
  @final_children_only: bool
@@ -11,7 +11,7 @@ module DSLCompose
11
11
  def classes: -> Array[singleton(Object)]
12
12
 
13
13
  private
14
- def has_descendents: (singleton(Object) base_class) -> bool
14
+ def has_descendants: (singleton(Object) base_class) -> bool
15
15
  end
16
16
  end
17
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsl_compose
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.15.0
4
+ version: 2.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ulliott
@@ -70,7 +70,7 @@ files:
70
70
  - lib/dsl_compose/parser.rb
71
71
  - lib/dsl_compose/parser/block_arguments.rb
72
72
  - lib/dsl_compose/parser/for_children_of_parser.rb
73
- - lib/dsl_compose/parser/for_children_of_parser/descendents.rb
73
+ - lib/dsl_compose/parser/for_children_of_parser/descendants.rb
74
74
  - lib/dsl_compose/parser/for_children_of_parser/for_dsl_parser.rb
75
75
  - lib/dsl_compose/parser/for_children_of_parser/for_dsl_parser/for_method_parser.rb
76
76
  - lib/dsl_compose/reader.rb
@@ -112,7 +112,7 @@ files:
112
112
  - sig/dsl_compose/parser.rbs
113
113
  - sig/dsl_compose/parser/block_arguments.rbs
114
114
  - sig/dsl_compose/parser/for_children_of_parser.rbs
115
- - sig/dsl_compose/parser/for_children_of_parser/descendents.rbs
115
+ - sig/dsl_compose/parser/for_children_of_parser/descendants.rbs
116
116
  - sig/dsl_compose/parser/for_children_of_parser/for_dsl_parser.rbs
117
117
  - sig/dsl_compose/parser/for_children_of_parser/for_dsl_parser/for_method_parser.rbs
118
118
  - sig/dsl_compose/reader.rbs