Skip to content

Commit

Permalink
Rename NestNonPublicMethods into NestNonPublicMembers
Browse files Browse the repository at this point in the history
Breaking API change.

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
  • Loading branch information
Morriar committed Aug 6, 2024
1 parent ccf2b14 commit 26561dc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/rbi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Error < StandardError
require "rbi/rewriters/filter_versions"
require "rbi/rewriters/merge_trees"
require "rbi/rewriters/nest_singleton_methods"
require "rbi/rewriters/nest_non_public_methods"
require "rbi/rewriters/nest_non_public_members"
require "rbi/rewriters/group_nodes"
require "rbi/rewriters/remove_known_definitions"
require "rbi/rewriters/attr_to_methods"
Expand Down
8 changes: 4 additions & 4 deletions lib/rbi/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Formatter
group_nodes: T::Boolean,
max_line_length: T.nilable(Integer),
nest_singleton_methods: T::Boolean,
nest_non_public_methods: T::Boolean,
nest_non_public_members: T::Boolean,
sort_nodes: T::Boolean,
).void
end
Expand All @@ -26,14 +26,14 @@ def initialize(
group_nodes: false,
max_line_length: nil,
nest_singleton_methods: false,
nest_non_public_methods: false,
nest_non_public_members: false,
sort_nodes: false
)
@add_sig_templates = add_sig_templates
@group_nodes = group_nodes
@max_line_length = max_line_length
@nest_singleton_methods = nest_singleton_methods
@nest_non_public_methods = nest_non_public_methods
@nest_non_public_members = nest_non_public_members
@sort_nodes = sort_nodes
end

Expand All @@ -52,7 +52,7 @@ def format_file(file)
def format_tree(tree)
tree.add_sig_templates! if @add_sig_templates
tree.nest_singleton_methods! if @nest_singleton_methods
tree.nest_non_public_methods! if @nest_non_public_methods
tree.nest_non_public_members! if @nest_non_public_members
tree.group_nodes! if @group_nodes
tree.sort_nodes! if @sort_nodes
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module RBI
module Rewriters
class NestNonPublicMethods < Visitor
class NestNonPublicMembers < Visitor
extend T::Sig

sig { override.params(node: T.nilable(Node)).void }
Expand Down Expand Up @@ -43,8 +43,8 @@ class Tree
extend T::Sig

sig { void }
def nest_non_public_methods!
visitor = Rewriters::NestNonPublicMethods.new
def nest_non_public_members!
visitor = Rewriters::NestNonPublicMembers.new
visitor.visit(self)
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/rbi/formatter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ module Foo
file = File.new
file.root = parse_rbi(rbi)

out = Formatter.new(nest_non_public_methods: false).print_file(file)
out = Formatter.new(nest_non_public_members: false).print_file(file)
assert_equal(rbi, out)

out = Formatter.new(nest_non_public_methods: true).print_file(file)
out = Formatter.new(nest_non_public_members: true).print_file(file)
assert_equal(<<~RBI, out)
module Foo
private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
require "test_helper"

module RBI
class NestNonPublicMethodsTest < Minitest::Test
class NestNonPublicMembersTest < Minitest::Test
include TestHelper

def test_nest_non_public_methods_in_tree
def test_nest_non_public_members_in_tree
tree = parse_rbi(<<~RBI)
def m1; end
protected def m2; end
private def m3; end
public attr_reader :m4
RBI

tree.nest_non_public_methods!
tree.nest_non_public_members!

assert_equal(<<~RBI, tree.string)
def m1; end
Expand All @@ -31,7 +31,7 @@ def m3; end
RBI
end

def test_nest_non_public_methods_in_scopes
def test_nest_non_public_members_in_scopes
tree = parse_rbi(<<~RBI)
module S1
def m1; end
Expand All @@ -49,7 +49,7 @@ def m5; end
end
RBI

tree.nest_non_public_methods!
tree.nest_non_public_members!

assert_equal(<<~RBI, tree.string)
module S1
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_nest_non_public_singleton_methods
public def self.m3; end
RBI

tree.nest_non_public_methods!
tree.nest_non_public_members!

assert_equal(<<~RBI, tree.string)
def self.m3; end
Expand Down

0 comments on commit 26561dc

Please sign in to comment.