Skip to content

Commit

Permalink
Merge pull request soutaro#1364 from soutaro/symbolize-names
Browse files Browse the repository at this point in the history
Symbolize target/group names
  • Loading branch information
soutaro authored Nov 29, 2024
2 parents 577e677 + fd14350 commit 5a911ca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/steep/project/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions sig/steep/project/dsl.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
17 changes: 17 additions & 0 deletions test/steepfile_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5a911ca

Please sign in to comment.