Class: AgentsSkillVault::UrlParser::ParseResult
- Inherits:
-
Object
- Object
- AgentsSkillVault::UrlParser::ParseResult
- Defined in:
- lib/agents_skill_vault/url_parser.rb
Overview
Result object returned by UrlParser.parse
Contains the parsed components of a GitHub URL.
Instance Attribute Summary collapse
-
#branch ⇒ String
readonly
Branch name (defaults to "main").
-
#relative_path ⇒ String?
readonly
Path within the repository (for folder/file URLs).
-
#repo ⇒ String
readonly
Repository name.
-
#skill_folder_path ⇒ String?
readonly
The full path to the skill folder (for SKILL.md file URLs).
-
#skill_name ⇒ String?
readonly
The name of the skill (for SKILL.md file URLs).
-
#type ⇒ Symbol
readonly
Type of URL (:repo, :folder, or :file).
-
#username ⇒ String
readonly
GitHub username or organization.
Instance Method Summary collapse
-
#initialize(username:, repo:, type:, branch: "main", relative_path: nil, skill_name: nil, skill_folder_path: nil) ⇒ ParseResult
constructor
Creates a new ParseResult.
-
#label ⇒ String
Generates a default label for this URL.
-
#skill_file? ⇒ Boolean
Checks if this URL points to a SKILL.md file.
Constructor Details
#initialize(username:, repo:, type:, branch: "main", relative_path: nil, skill_name: nil, skill_folder_path: nil) ⇒ ParseResult
Creates a new ParseResult.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/agents_skill_vault/url_parser.rb', line 63 def initialize(username:, repo:, type:, branch: "main", relative_path: nil, skill_name: nil, skill_folder_path: nil) @username = username @repo = repo @branch = branch @relative_path = relative_path @type = type @skill_name = skill_name @skill_folder_path = skill_folder_path end |
Instance Attribute Details
#branch ⇒ String (readonly)
39 40 41 |
# File 'lib/agents_skill_vault/url_parser.rb', line 39 def branch @branch end |
#relative_path ⇒ String? (readonly)
42 43 44 |
# File 'lib/agents_skill_vault/url_parser.rb', line 42 def relative_path @relative_path end |
#repo ⇒ String (readonly)
36 37 38 |
# File 'lib/agents_skill_vault/url_parser.rb', line 36 def repo @repo end |
#skill_folder_path ⇒ String? (readonly)
51 52 53 |
# File 'lib/agents_skill_vault/url_parser.rb', line 51 def skill_folder_path @skill_folder_path end |
#skill_name ⇒ String? (readonly)
48 49 50 |
# File 'lib/agents_skill_vault/url_parser.rb', line 48 def skill_name @skill_name end |
#type ⇒ Symbol (readonly)
45 46 47 |
# File 'lib/agents_skill_vault/url_parser.rb', line 45 def type @type end |
#username ⇒ String (readonly)
33 34 35 |
# File 'lib/agents_skill_vault/url_parser.rb', line 33 def username @username end |
Instance Method Details
#label ⇒ String
Generates a default label for this URL.
For repositories: "username/repo" For SKILL.md files: "username/skill-name" For other folders/files: "username/last-path-component"
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/agents_skill_vault/url_parser.rb', line 82 def label if type == :repo "#{username}/#{repo}" elsif skill_file? "#{username}/#{repo}/#{skill_name}" else parts = relative_path&.split("/") || [] folder = parts.last "#{username}/#{repo}/#{folder}" end end |
#skill_file? ⇒ Boolean
Checks if this URL points to a SKILL.md file.
98 99 100 |
# File 'lib/agents_skill_vault/url_parser.rb', line 98 def skill_file? type == :file && skill_name && !skill_name.empty? end |