From fd14350e64f3e4e30520a06a831b69e35d050b52 Mon Sep 17 00:00:00 2001 From: Soutaro Matsumoto Date: Fri, 29 Nov 2024 14:59:25 +0900 Subject: [PATCH] Symbolize target/group names --- lib/steep/project/dsl.rb | 2 ++ sig/steep/project/dsl.rbs | 6 +++--- test/steepfile_test.rb | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/steep/project/dsl.rb b/lib/steep/project/dsl.rb index 17bb0bc1..4550f169 100644 --- a/lib/steep/project/dsl.rb +++ b/lib/steep/project/dsl.rb @@ -164,6 +164,7 @@ def code_diagnostics_config end def group(name, &block) + name = name.to_str.to_sym unless Symbol === name group = GroupDSL.new(name, self) Steep.logger.tagged "group=#{name}" do @@ -230,6 +231,7 @@ def self.eval(project, &block) end def target(name, &block) + name = name.to_str.to_sym unless Symbol === name dsl = TargetDSL.new(name, project: project) Steep.logger.tagged "target=#{name}" do diff --git a/sig/steep/project/dsl.rbs b/sig/steep/project/dsl.rbs index 42180d69..0cac4f7f 100644 --- a/sig/steep/project/dsl.rbs +++ b/sig/steep/project/dsl.rbs @@ -133,7 +133,7 @@ module Steep def configure_code_diagnostics: (?diagnostics_config hash) { (diagnostics_config) -> void } -> void | (diagnostics_config config) -> void - def group: (Symbol) ?{ (GroupDSL) [self: GroupDSL] -> void } -> void + def group: (interned) ?{ (GroupDSL) [self: GroupDSL] -> void } -> void end class GroupDSL @@ -174,7 +174,7 @@ module Steep # ```rb # configure_code_diagnostics(nil) # ``` - # + # def configure_code_diagnostics: (?diagnostics_config hash) { (diagnostics_config) -> void } -> void | (diagnostics_config? config) -> void end @@ -189,7 +189,7 @@ module Steep include LibraryOptions - def target: (Symbol name) ?{ (TargetDSL) [self: TargetDSL] -> void } -> void + def target: (interned name) ?{ (TargetDSL) [self: TargetDSL] -> void } -> void end end end diff --git a/test/steepfile_test.rb b/test/steepfile_test.rb index b99a7aa9..e09d080d 100644 --- a/test/steepfile_test.rb +++ b/test/steepfile_test.rb @@ -319,4 +319,21 @@ def test_group end end end + + def test_string + in_tmpdir do + project = Project.new(steepfile_path: current_dir + "Steepfile") + + Project::DSL.eval(project) do + target "app" do + group "core" do + end + end + end + + project.targets.find {|target| target.name == :app }.tap do |target| + assert_equal [:core], target.groups.map(&:name) + end + end + end end