Skip to main content
Glama

MCP Source Relation Server

ruby.py1.89 kB
import re from pathlib import Path from typing import Set from ..utils.path import search_in_path from .base import BaseAnalyzer class RubyAnalyzer(BaseAnalyzer): """Ruby用アナライザー""" def __init__(self, base_dir: Path): super().__init__(base_dir) # Ruby標準ライブラリやGemのパスは除外 self.search_paths = [ self.base_dir / "lib", self.base_dir / "app", self.base_dir, ] @property def file_extensions(self) -> list[str]: return [".rb"] def analyze_imports(self, content: str, file_path: Path) -> Set[str]: imports = set() patterns = [ r'require\s+[\'"](.+?)[\'"]', r'require_relative\s+[\'"](.+?)[\'"]', ] for pattern in patterns: for match in re.finditer(pattern, content): path = match.group(1) resolved_path = None if pattern.startswith("require_relative"): # require_relativeは現在のファイルからの相対パス resolved_path = self.resolve_relative_path( path, file_path, allow_index=False ) else: # requireはライブラリパスから探索 # 拡張子がない場合は.rbを補完 if "." not in path: path = f"{path}.rb" resolved_path = search_in_path( path, self.search_paths, self.file_extensions, allow_index=False, ) if resolved_path: normalized_path = self.normalize_path(resolved_path) imports.add(normalized_path) return imports

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/owayo/mcp-source-relation'

If you have feedback or need assistance with the MCP directory API, please join our Discord server