From 1faa9e3e1f29f6d63296d0f80522b8c7c6c29e1d Mon Sep 17 00:00:00 2001 From: euglena1215 Date: Fri, 5 Jan 2024 17:10:22 +0900 Subject: [PATCH] fix parse logic --- Gemfile.lock | 1 + lib/packwerk_yard/parser.rb | 5 +++++ packwerk_yard.gemspec | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4ad96f8..76b26ff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,6 +18,7 @@ PATH remote: . specs: packwerk_yard (0.1.0) + parser yard GEM diff --git a/lib/packwerk_yard/parser.rb b/lib/packwerk_yard/parser.rb index 70e0f36..6487dd7 100644 --- a/lib/packwerk_yard/parser.rb +++ b/lib/packwerk_yard/parser.rb @@ -4,6 +4,10 @@ module PackwerkYard class Parser # rubocop:disable Style/Documentation include Packwerk::FileParser + # Array Syntax e.g. Array + ARRAY_REGEXP = /Array<(.+)>/.freeze + private_constant :ARRAY_REGEXP + def initialize(ruby_parser: Packwerk::Parsers::Ruby.new) @ruby_parser = ruby_parser end @@ -41,6 +45,7 @@ def extract_from_yard_to_types(source_code) end def to_constant(name) + name = Regexp.last_match(1) if name =~ ARRAY_REGEXP Object.const_get(name) rescue NameError nil diff --git a/packwerk_yard.gemspec b/packwerk_yard.gemspec index 87dbf7d..0ba2411 100644 --- a/packwerk_yard.gemspec +++ b/packwerk_yard.gemspec @@ -18,6 +18,7 @@ Gem::Specification.new do |spec| spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = "https://github.com/euglena1215/packwerk-yard" spec.metadata["changelog_uri"] = "https://github.com/euglena1215/packwerk-yard/blob/main/CHANGELOG.md" + spec.metadata["rubygems_mfa_required"] = "true" # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. @@ -32,5 +33,5 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_dependency "yard" - spec.metadata["rubygems_mfa_required"] = "true" + spec.add_dependency "parser" end