A small Ruby utility that extracts direct download URLs for Logic Pro X and MainStage additional content by parsing Apple-provided package metadata (plist converted to JSON). It generates organized text files with all links and mandatory-only links and opens the destination folder for user convenience. The project emphasizes reliability, clear CLI behavior, and a robust automated test suite.
- Root
lpx_links.rb— Main entry point executable (CLI). Handles argument parsing, orchestrates workflow, writes outputs, and opens the links directory.lib/file_helpers.rb— Paths and URL helpers. Encapsulates application resource discovery and output locations.Rakefile— Test task wiring for Minitest viarake test.Gemfile— Development/test dependencies (Minitest, reporters, SimpleCov, Rake)..rubocop.yml— Style and metrics configuration (Ruby 2.7 target).- Scripts:
scripts/install.sh,scripts/test_local_workflow.sh - Docs:
docs/CONTRIBUTING.md,docs/BEST_PRACTICES.md,docs/TEST_WORKFLOW.md,README.md. - Meta/config:
.qodo_merge.toml(PR review/quality automation), CI in.github/.
lib/— Library code (non-executable code, helpers, utilities).test/— Minitest test suitetest_helper.rb— Test bootstrap (SimpleCov, reporters, requires app code).lib/file_helpers_test.rb,lpx_links_test.rb— Unit tests.
images/— Documentation assets.
Conventions
- Source files use
# frozen_string_literal: trueand idiomatic Ruby 2.7. - File names are snake_case; modules/classes are CamelCase; methods are snake_case.
- Output artifacts are written to the user’s Desktop under
~/Desktop/lpx_download_links.
- Frameworks: Minitest + minitest-reporters (Spec reporter) + SimpleCov for coverage.
- Organization: Tests reside under
test/, mirroring code locations (e.g.,test/lib/..._test.rb). Files end with_test.rb. - Execution:
- Unit tests:
bundle exec rake testorrake testif environment is set up. - Local end-to-end workflow:
./scripts/test_local_workflow.sh(runs RuboCop, test suite, and simulates user flow).
- Unit tests:
- Mocking/Stubbing: Prefer Minitest’s built-in
stubto isolate filesystem, environment, and shell calls:- Stub
File.read,File.exist?,Dir.home, backticks (`cmd`), and helpers inFileHelpersas needed. - Keep tests deterministic and independent of host macOS setup.
- Stub
- Coverage Expectations: Target 90%+ line coverage; cover success paths, edge cases, and error branches.
- Unit vs Integration:
- Unit: Validate pure logic (path building, sorting, filtering, memoization, error propagation).
- Integration/E2E: Use
scripts/test_local_workflow.shto simulate the full CLI pipeline and verify generated files where possible.
- Ruby Version: Target Ruby 2.7 (see
.rubocop.yml). - Linting: Must pass RuboCop with project rules.
- Idioms:
- Use
module_functionfor modules with stateless helpers. - Prefer
File.join,URI, andPathname#cleanpathfor robust path/URL handling. - Use memoization for cached computations (e.g.,
@packages). Clear/reset in tests when required. - Keep methods small and cohesive; respect configured metrics in
.rubocop.yml.
- Use
- Naming:
- Modules/Classes: CamelCase (
LpxLinks,FileHelpers). - Methods/Variables: snake_case (
download_links,json_dir). - Files: snake_case matching the primary class/module where applicable.
- Modules/Classes: CamelCase (
- Comments/Docs:
- Use concise comments where non-obvious behavior exists (shelling out, side effects, OS assumptions).
- Keep README/docs/TEST_WORKFLOW.md up to date when user-facing behavior changes.
- Error Handling:
- Raise clear errors in helpers (e.g., when app resources are missing) and handle at the top-level (
run) with user-friendly messages and non-zero exit. - Avoid rescuing overly-broad exceptions unless necessary; allow JSON parsing errors to surface in tests when appropriate.
- When shelling out, ensure quoting and safe input handling.
- Raise clear errors in helpers (e.g., when app resources are missing) and handle at the top-level (
- CLI Orchestration:
OptionParserfor flags (-n/--name,-h/--help). - Shell Interactions: Backticks (
`plutil ...`,`open ...`) for converting plist to JSON and opening directories. Inputs are derived from known paths to reduce risk. - Path/URL Safety:
File.joinandURIto avoid malformed separators;Pathname.cleanpathto normalize relative segments like../../. - Output Files:
print_filewrites arrays of lines; ensure newline semantics are preserved. - Memoization: Cache expensive reads (e.g., packages) and reset between tests.
- Testing Practices: Heavy use of
stubto isolate side effects; verify error messages, sorting, and edge cases.
- Do
- Run
./scripts/test_local_workflow.shbefore pushing changes; it enforces RuboCop, tests, and basic workflow. - Keep code RuboCop-clean; adjust
.rubocop.ymlsparingly and with justification. - Add unit tests for new logic, including error branches and edge cases (nil/missing keys, empty structures).
- Use
File.join,URI,Pathname.cleanpathfor all paths/URLs; avoid manual string concatenation. - Prefer non-bang methods for comparisons (e.g.,
n.upcase == 'LOGIC') to avoidnilsurprises from bang methods’ return values. - Keep user messaging clear and actionable on failures.
- Stub external effects in tests (filesystem, environment, shell commands) to keep tests deterministic.
- Run
- Don't
- Don’t introduce global state or hidden side effects; keep helpers pure where possible.
- Don’t hardcode OS-specific assumptions beyond documented macOS tooling; always guard with checks and clear errors.
- Don’t rescue and swallow exceptions that should fail fast or be validated by tests.
- Don’t depend on network or actual installed apps in unit tests; use stubs.
- Don’t change output file locations or formats without updating docs and tests.
- Runtime
- Ruby (2.7 compatible environment)
- macOS tools:
plutil(for plist→JSON),open(to open output directory)
- Development/Test Gems (Gemfile)
minitest— Unit testing frameworkminitest-reporters— Spec-style test outputsimplecov— Code coveragerake— Test task runner
- Linting
- RuboCop with
.rubocop.ymlproject rules
- RuboCop with
- Setup
- Install Ruby dependencies:
bundle install - Run tests:
bundle exec rake test - Local workflow validation:
./scripts/test_local_workflow.sh
- Install Ruby dependencies:
- Platform Assumptions: macOS with Logic Pro or MainStage installed for the full workflow; unit tests do not require installed apps.
- File Outputs: Generated under
~/Desktop/lpx_download_links/withall_download_links.txt,mandatory_download_links.txt, andjson/logicpro_content.json. - Safety & Reliability:
- Avoid command injection by keeping shell inputs constrained to known paths and quoting arguments.
- Ensure directory creation precedes any writes (
create_dirs).
- Extensibility:
- When adding new CLI options, extend
OptionParser, keep defaults explicit, and document in README. - Add tests for new flags and behaviors; maintain 90%+ coverage.
- When adding new CLI options, extend
- CI & Reviews:
- GitHub Actions (in
.github/) runs linting/tests on PRs. .qodo_merge.tomlenforces high-quality PR review standards; keep tests and coverage strong to pass automated checks.
- GitHub Actions (in