lib/rbs/diff.rb in rbs-3.3.2 vs lib/rbs/diff.rb in rbs-3.4.0.pre.1

- old
+ new

@@ -1,14 +1,15 @@ # frozen_string_literal: true module RBS class Diff - def initialize(type_name:, library_options:, after_path: [], before_path: []) + def initialize(type_name:, library_options:, after_path: [], before_path: [], detail: false) @type_name = type_name @library_options = library_options @after_path = after_path @before_path = before_path + @detail = detail end def each_diff(&block) return to_enum(:each_diff) unless block @@ -98,23 +99,25 @@ def definition_method_to_s(key, kind, definition_method) if definition_method prefix = kind == :instance ? "" : "self." + detail_to_s = @detail ? "[#{definition_method.defined_in} #{definition_method.accessibility}] " : "" if definition_method.alias_of first_def = definition_method.alias_of.defs.first #: Definition::Method::TypeDef - "alias #{prefix}#{key} #{prefix}#{first_def.member.name}" + "#{detail_to_s}alias #{prefix}#{key} #{prefix}#{first_def.member.name}" else - "def #{prefix}#{key}: #{definition_method.method_types.join(" | ")}" + "#{detail_to_s}def #{prefix}#{key}: #{definition_method.method_types.join(" | ")}" end else +"-" end end def constant_to_s(constant) if constant - "#{constant.name.name}: #{constant.type}" + detail_to_s = @detail ? "[#{constant.name.namespace.to_type_name.to_s}] " : "" + "#{detail_to_s}#{constant.name.name}: #{constant.type}" else +"-" end end end