Files
articulate-parser/internal/interfaces/parser.go
Kaj Kowalski 2790064ad5 refactor: Standardize method names and introduce context propagation
Removes the `Get` prefix from exporter methods (e.g., GetSupportedFormat -> SupportedFormat) to better align with Go conventions for simple accessors.

Introduces `context.Context` propagation through the application, starting from `ProcessCourseFromURI` down to the HTTP request in the parser. This makes network operations cancellable and allows for setting deadlines, improving application robustness.

Additionally, optimizes the HTML cleaner by pre-compiling regular expressions for a minor performance gain.
2025-11-06 04:26:41 +01:00

26 lines
1.1 KiB
Go

// Package interfaces provides the core contracts for the articulate-parser application.
// It defines interfaces for parsing and exporting Articulate Rise courses.
package interfaces
import (
"context"
"github.com/kjanat/articulate-parser/internal/models"
)
// CourseParser defines the interface for loading course data.
// It provides methods to fetch course content either from a remote URI
// or from a local file path.
type CourseParser interface {
// FetchCourse loads a course from a URI (typically an Articulate Rise share URL).
// It retrieves the course data from the remote location and returns a parsed Course model.
// The context can be used for cancellation and timeout control.
// Returns an error if the fetch operation fails or if the data cannot be parsed.
FetchCourse(ctx context.Context, uri string) (*models.Course, error)
// LoadCourseFromFile loads a course from a local file.
// It reads and parses the course data from the specified file path.
// Returns an error if the file cannot be read or if the data cannot be parsed.
LoadCourseFromFile(filePath string) (*models.Course, error)
}