feat: reorganize workbook into 3 tracks (core, engineering-2026, ecosystems)

This commit is contained in:
soda64 committed 2026-11-30 22:30:53 +01:00
1 parent 82677455b2
commit 2e002b6176
64 files changed
+2295 -196

No files matched your search

@@ -0,0 +1,4 @@
[package]
name = "eng03-cross-platform"
version = "0.1.0"
edition = "2021"
@@ -0,0 +1,16 @@
# 03 — Programowanie Cross-Platform (Linux, Windows, macOS)
## Zakres
* Abstrakcje ścieżek `Path` i `PathBuf` (nigdy nie sklejaj ścieżek przez `format!("{}/{}", ...)`!)
* Kompilacja warunkowa: `#[cfg(target_os = "linux")]`, `#[cfg(target_os = "macos")]`, `#[cfg(target_os = "windows")]`
* Bezpieczna obsługa zmiennych środowiskowych (wstrzykiwanie źródła zamiast globalnego stanu w testach)
## Zadania (`src/lib.rs`)
1. `config_file_path(base_dir: &Path, app_name: &str) -> PathBuf` — zbuduj przenośną ścieżkę `<base_dir>/<app_name>/config.toml` używając `Path::join`.
2. `current_os_label() -> &'static str` — użyj `#[cfg(target_os = "...")]`, aby zwrócić `"linux"`, `"macos"`, `"windows"` lub `"other"`.
3. `has_extension(path: &Path, expected: &str) -> bool` — porównaj rozszerzenie pliku bez uwzględniania wielkości liter (ważne na Windows/macOS).
## Uruchomienie testów
```bash
make test PKG=eng03-cross-platform
```
@@ -0,0 +1,40 @@
#![allow(unused_variables, dead_code)]
use std::path::{Path, PathBuf};
pub fn config_file_path(base_dir: &Path, app_name: &str) -> PathBuf {
todo!("Użyj base_dir.join(app_name).join(\"config.toml\")")
}
pub fn current_os_label() -> &'static str {
todo!("Użyj #[cfg(target_os = \"...\")] dla linux, macos, windows oraz fallback other")
}
pub fn has_extension(path: &Path, expected: &str) -> bool {
todo!("Porównaj path.extension() z expected bez wrażliwości na wielkość liter")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn builds_portable_config_path() {
let base = Path::new("home").join("user");
let expected = base.join("myapp").join("config.toml");
assert_eq!(config_file_path(&base, "myapp"), expected);
}
#[test]
fn detects_known_os_label() {
let label = current_os_label();
assert!(matches!(label, "linux" | "macos" | "windows" | "other"));
}
#[test]
fn checks_extensions_case_insensitively() {
assert!(has_extension(Path::new("notes.MD"), "md"));
assert!(has_extension(Path::new("archive.tar.gz"), "gz"));
assert!(!has_extension(Path::new("README"), "md"));
}
}