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 1faa9e3 commit 6c4a5fc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/packwerk_yard/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ def initialize(ruby_parser: Packwerk::Parsers::Ruby.new)

def call(io:, file_path: "<unknown>")
source_code = io.read
return to_ruby_ast(nil.inspect, file_path + ".yard") if source_code.nil?
file_path = file_path.gsub('.rb', '.yard.rb')
return to_ruby_ast(nil.inspect, file_path) if source_code.nil?

types = extract_from_yard_to_types(source_code)

to_ruby_ast(types.map { |type| to_constant(type) }.compact.inspect, file_path + ".yard")
to_ruby_ast(types.map { |type| to_constant(type) }.compact.inspect, file_path)
end

def match?(path:)
Expand Down

0 comments on commit 6c4a5fc

Please sign in to comment.