Skip to content

Commit

Permalink
fix parse logic
Browse files Browse the repository at this point in the history
  • Loading branch information
euglena1215 committed Jan 5, 2024
1 parent 6226159 commit 1faa9e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ PATH
remote: .
specs:
packwerk_yard (0.1.0)
parser
yard

GEM
Expand Down
5 changes: 5 additions & 0 deletions lib/packwerk_yard/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module PackwerkYard
class Parser # rubocop:disable Style/Documentation
include Packwerk::FileParser

# Array Syntax e.g. Array<String>
ARRAY_REGEXP = /Array<(.+)>/.freeze
private_constant :ARRAY_REGEXP

def initialize(ruby_parser: Packwerk::Parsers::Ruby.new)
@ruby_parser = ruby_parser
end
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion packwerk_yard.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

0 comments on commit 1faa9e3

Please sign in to comment.