Module: RailsAiBridge::Registry::SourceParser
- Defined in:
- lib/rails_ai_bridge/registry/source_parser.rb
Overview
Parses a raw pack source string and returns a typed ParsedSource value object.
Single responsibility: classify a source string into one of three formats and produce the canonical URL needed to resolve it. Raises RailsAiBridge::Registry::SkillSourceResolver::ResolutionError for unrecognized formats so callers get a clear error message naming all valid forms.
Supported formats:
- Local path — starts with
/,./, or../. Returned as-is; no git needed. - Full git URL — starts with
https://orgit@(SSH). Plainhttp://is rejected to prevent unencrypted transmission of credentials and pack content. Used directly as the clone URL. - GitHub shorthand — exactly
owner/repo. Expanded tohttps://github.com/owner/repo.git.
Defined Under Namespace
Classes: ParsedSource
Constant Summary collapse
- INVALID_SOURCE_MESSAGE =
<<~MSG Invalid source format: %<source>s Valid formats: Local path /absolute/path OR ./relative OR ../relative HTTPS URL https://github.com/owner/repo.git SSH URL git@github.com:owner/repo.git GitHub short owner/repo (expanded to https://github.com/owner/repo.git) Note: plain http:// URLs are not supported — use https:// or git@ (SSH) instead. MSG
Class Method Summary collapse
Class Method Details
.parse(source) ⇒ ParsedSource
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rails_ai_bridge/registry/source_parser.rb', line 48 def self.parse(source) if source.nil? || source.strip.empty? raise SkillSourceResolver::ResolutionError, format(INVALID_SOURCE_MESSAGE, source: source.inspect) end return parse_local(source) if local_path?(source) return parse_git_url(source) if git_url?(source) return parse_shorthand(source) if github_shorthand?(source) raise SkillSourceResolver::ResolutionError, format(INVALID_SOURCE_MESSAGE, source: source) end |