< Summary - Neospec Coverage

Information
Class: Version
Assembly: domain
File(s): /home/runner/work/neospec/neospec/internal/domain/neovim.go
Line coverage
100%
Covered lines: 21
Uncovered lines: 0
Coverable lines: 21
Total lines: 81
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
String0%00100%
AssetName0%00100%

File(s)

/home/runner/work/neospec/neospec/internal/domain/neovim.go

#LineLine coverage
 1package domain
 2
 3import (
 4  "fmt"
 5  "regexp"
 6  "strconv"
 7)
 8
 9// Version represents a Neovim release version. The Tag field is the canonical
 10// form used in GitHub release URLs (e.g. "v0.10.4", "stable", "nightly").
 11type Version struct {
 12  Major int
 13  Minor int
 14  Patch int
 15  // Tag is the GitHub release tag, e.g. "stable", "nightly", or "v0.10.4".
 16  Tag string
 17}
 18
 19var semverRe = regexp.MustCompile(`^v?(\d+)\.(\d+)\.(\d+)$`)
 20
 21// ParseVersion parses a version string. It accepts:
 22//   - "stable" and "nightly" as special tags with zero Major/Minor/Patch
 23//   - semantic version strings like "0.10.4" or "v0.10.4"
 24func ParseVersion(s string) (Version, error) {
 25  if s == "stable" || s == "nightly" {
 26    return Version{Tag: s}, nil
 27  }
 28
 29  m := semverRe.FindStringSubmatch(s)
 30  if m == nil {
 31    return Version{}, fmt.Errorf("invalid neovim version %q: want \"stable\", \"nightly\", or semver like \"0.10.4\"", s
 32  }
 33
 34  major, _ := strconv.Atoi(m[1])
 35  minor, _ := strconv.Atoi(m[2])
 36  patch, _ := strconv.Atoi(m[3])
 37
 38  tag := s
 39  if s[0] != 'v' {
 40    tag = "v" + s
 41  }
 42
 43  return Version{Major: major, Minor: minor, Patch: patch, Tag: tag}, nil
 44}
 45
 46// String returns the canonical version tag.
 447func (v Version) String() string {
 448  return v.Tag
 449}
 50
 51// AssetName returns the filename of the Neovim release archive for a given platform.
 52// These match the actual asset names used in Neovim GitHub releases.
 653func (v Version) AssetName(p Platform) string {
 654  switch p.OS {
 255  case OSDarwin:
 256    // As of Neovim 0.10, GitHub releases ship separate x86_64 and arm64
 257    // tarballs for macOS rather than a single universal binary.
 158    if p.Arch == ArchARM64 {
 159      return "nvim-macos-arm64.tar.gz"
 160    }
 161    return "nvim-macos-x86_64.tar.gz"
 262  case OSLinux:
 263    switch p.Arch {
 164    case ArchARM64:
 165      return "nvim-linux-arm64.tar.gz"
 166    default:
 167      return "nvim-linux-x86_64.tar.gz"
 68    }
 169  case OSWindows:
 170    return "nvim-win64.zip"
 71  }
 172  return ""
 73}
 74
 75// BinaryName returns the Neovim executable name for a platform.
 76func BinaryName(p Platform) string {
 77  if p.OS == OSWindows {
 78    return "nvim.exe"
 79  }
 80  return "nvim"
 81}

Methods/Properties

String
AssetName