mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Track children in DSL
This commit is contained in:
parent
a06ea6088c
commit
80fbe89b4c
2 changed files with 14 additions and 5 deletions
|
@ -15,12 +15,14 @@ module Spectator
|
||||||
module_name = (type.id + safe_name.camelcase).id
|
module_name = (type.id + safe_name.camelcase).id
|
||||||
absolute_module_name = [parent_module, module_name].join("::").id
|
absolute_module_name = [parent_module, module_name].join("::").id
|
||||||
what_arg = what.is_a?(StringLiteral) ? what : what.stringify
|
what_arg = what.is_a?(StringLiteral) ? what : what.stringify
|
||||||
parent_given = ::Spectator::Definitions::ALL[parent_module.id][:given]
|
parent_def = ::Spectator::Definitions::ALL[parent_module.id]
|
||||||
|
parent_def[:children] << absolute_module_name
|
||||||
|
|
||||||
::Spectator::Definitions::ALL[absolute_module_name] = {
|
::Spectator::Definitions::ALL[absolute_module_name] = {
|
||||||
name: module_name,
|
name: module_name,
|
||||||
parent: parent_module,
|
parent: parent_module,
|
||||||
given: parent_given.map { |e| e } # Duplicate elements without dup method.
|
given: parent_def[:given].map { |e| e }, # Duplicate elements without dup method.
|
||||||
|
children: [] of Object
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
@ -127,8 +129,11 @@ module Spectator
|
||||||
parent_module = @type
|
parent_module = @type
|
||||||
safe_name = description.id.stringify.chars.map { |c| ::Spectator::Definitions::SPECIAL_CHARS[c] || c }.join("").gsub(/\W+/, "_")
|
safe_name = description.id.stringify.chars.map { |c| ::Spectator::Definitions::SPECIAL_CHARS[c] || c }.join("").gsub(/\W+/, "_")
|
||||||
class_name = (safe_name.camelcase + "Example").id
|
class_name = (safe_name.camelcase + "Example").id
|
||||||
given_vars = ::Spectator::Definitions::ALL[parent_module.id][:given]
|
absolute_class_name = [parent_module.id, class_name].join("::").id
|
||||||
|
parent_def = ::Spectator::Definitions::ALL[parent_module.id]
|
||||||
|
given_vars = parent_def[:given]
|
||||||
var_names = given_vars.map { |v| v[:name] }
|
var_names = given_vars.map { |v| v[:name] }
|
||||||
|
parent_def[:children] << absolute_class_name
|
||||||
%}
|
%}
|
||||||
|
|
||||||
class Example%example
|
class Example%example
|
||||||
|
@ -188,8 +193,11 @@ module Spectator
|
||||||
parent_module = @type
|
parent_module = @type
|
||||||
safe_name = description.id.stringify.chars.map { |c| ::Spectator::Definitions::SPECIAL_CHARS[c] || c }.join("").gsub(/\W+/, "_")
|
safe_name = description.id.stringify.chars.map { |c| ::Spectator::Definitions::SPECIAL_CHARS[c] || c }.join("").gsub(/\W+/, "_")
|
||||||
class_name = (safe_name.camelcase + "Example").id
|
class_name = (safe_name.camelcase + "Example").id
|
||||||
given_vars = ::Spectator::Definitions::ALL[parent_module.id][:given]
|
absolute_class_name = [parent_module.id, class_name].join("::").id
|
||||||
|
parent_def = ::Spectator::Definitions::ALL[parent_module.id]
|
||||||
|
given_vars = parent_def[:given]
|
||||||
var_names = given_vars.map { |v| v[:name] }
|
var_names = given_vars.map { |v| v[:name] }
|
||||||
|
parent_def[:children] << absolute_class_name
|
||||||
%}
|
%}
|
||||||
|
|
||||||
class Example%example
|
class Example%example
|
||||||
|
|
|
@ -8,7 +8,8 @@ module Spectator
|
||||||
{% ::Spectator::Definitions::ALL[@type.id] = {
|
{% ::Spectator::Definitions::ALL[@type.id] = {
|
||||||
name: "ROOT",
|
name: "ROOT",
|
||||||
parent: nil,
|
parent: nil,
|
||||||
given: [] of Object
|
given: [] of Object,
|
||||||
|
children: [] of Object
|
||||||
} %}
|
} %}
|
||||||
::Spectator::Definitions::MAPPING[{{@type.stringify}}] = ::Spectator::ExampleGroup::ROOT
|
::Spectator::Definitions::MAPPING[{{@type.stringify}}] = ::Spectator::ExampleGroup::ROOT
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue