dsl_compose 2.15.0 → 2.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af6d832ff6a9dbe899f76297a60555caf170045743dd6cf83cbabb6b26e87892
4
- data.tar.gz: a9628422e02b4cac58263ad72938c0297f42c75d81dd3337e43d227ec71ba664
3
+ metadata.gz: ae01b58f13f59318a89b06b444bd0dc0a17487e66d03a7701cb605673774f75a
4
+ data.tar.gz: 2feeab8f8494a6dea3ee59c52903a21c84cde2da623f406aea9530581146d124
5
5
  SHA512:
6
- metadata.gz: 82ee9d6210446826e52dec60de79f414d9769e4e571e2d95ccf41c66da3231728ad6ffecb9f55beedeceecbf651c286fc0499b076301d3c7f858fa84bd0d5106
7
- data.tar.gz: d30c48922a712e86138867c4b4de9daee988bf99b3af052a407a8b8bc739f292c974a143ea6b93c0de35b84a981d763c08e3da799114a17ca68f1ff4e6b086f4
6
+ metadata.gz: 6d1b476aef66fcaf034b3e7775a91233b69f30dc46c1dfc6d2891596ed859d0a9219e69c7bfec5ede49179d56a0fa2e59f31398b5b95504eb8ebd72c6f9a4d01
7
+ data.tar.gz: 565b63fb9b5e24f6d778e74f477b7aea4cd6619bfb39aa5ae62a9651daffd5b54e06ceaa8cef3378c111b508babe89d55d02af768c0692f24e4be9c68ad23845
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.15.1](https://github.com/craigulliott/dsl_compose/compare/v2.15.0...v2.15.1) (2023-10-03)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * sorting classes by ancestry chain (i.e. ancestors before descendants) in the parser ([4e7dd6f](https://github.com/craigulliott/dsl_compose/commit/4e7dd6fd302c50ee3147f76f59a52089fb6f39ee))
9
+
3
10
  ## [2.15.0](https://github.com/craigulliott/dsl_compose/compare/v2.14.3...v2.15.0) (2023-10-03)
4
11
 
5
12
 
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
+ 0
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.1"
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.1
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