Skip to content

Commit

Permalink
ref(lfs): rename nfs to lfs (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Sep 27, 2024
1 parent d973003 commit c011c6f
Show file tree
Hide file tree
Showing 22 changed files with 62 additions and 62 deletions.
8 changes: 4 additions & 4 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ tasks:
cmds:
- go test ./cycle

tfs:
cmds:
- go test ./lfs

tk:
cmds:
- go test ./internal/kernel
Expand All @@ -76,10 +80,6 @@ tasks:
cmds:
- go test ./locale

tn:
cmds:
- go test ./nfs

tcore:
cmds:
- go test ./core
Expand Down
4 changes: 2 additions & 2 deletions director.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func Prime(using *pref.Using, settings ...pref.Option) *Builders {
return using.GetReadDirFS()
}

return NewNativeFS(using.Root)
return NewLocalFS(using.Root)
}),
queryFS: pref.CreateQueryStatusFS(func(qsys fs.FS) fs.StatFS {
if using.GetQueryStatusFS != nil {
Expand Down Expand Up @@ -141,7 +141,7 @@ func Resume(was *Was, settings ...pref.Option) *Builders {
if was.Using.GetReadDirFS != nil {
return was.Using.GetReadDirFS()
}
return NewNativeFS(was.Root)
return NewLocalFS(was.Root)
}),
queryFS: pref.CreateQueryStatusFS(func(fsys fs.FS) fs.StatFS {
if was.Using.GetQueryStatusFS != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/feat/filter/scheme-sampler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/snivilised/traverse/internal/filtering"
"github.com/snivilised/traverse/internal/third/lo"
"github.com/snivilised/traverse/internal/types"
"github.com/snivilised/traverse/nfs"
"github.com/snivilised/traverse/lfs"
)

type samplerScheme struct {
Expand Down Expand Up @@ -43,7 +43,7 @@ func (s *samplerScheme) next(node *core.Node,
) (bool, error) {
if node.Extension.Scope.IsRoot() {
matching := s.filter.Matching(
[]fs.DirEntry{nfs.FromFileInfo(node.Info)},
[]fs.DirEntry{lfs.FromFileInfo(node.Info)},
)
result := len(matching) > 0

Expand Down
4 changes: 2 additions & 2 deletions internal/feat/sampling/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/snivilised/traverse/enums"
"github.com/snivilised/traverse/internal/third/lo"
"github.com/snivilised/traverse/internal/types"
"github.com/snivilised/traverse/nfs"
"github.com/snivilised/traverse/lfs"
"github.com/snivilised/traverse/pref"
)

Expand All @@ -27,7 +27,7 @@ func (p *controller) Next(_ *core.Node, _ types.Inspection) (bool, error) {
func (p *controller) sample(result []fs.DirEntry, _ error,
_ fs.ReadDirFS, _ string,
) ([]fs.DirEntry, error) {
files, folders := nfs.Separate(result)
files, folders := lfs.Separate(result)

return union(&readResult{
files: files,
Expand Down
6 changes: 3 additions & 3 deletions internal/filtering/sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/snivilised/traverse/core"
"github.com/snivilised/traverse/enums"
"github.com/snivilised/traverse/internal/third/lo"
"github.com/snivilised/traverse/lfs"
"github.com/snivilised/traverse/locale"
"github.com/snivilised/traverse/nfs"
"github.com/snivilised/traverse/pref"
)

Expand Down Expand Up @@ -80,12 +80,12 @@ func NewSample(def *core.SampleFilterDef,
}

func (f *Sample) files(entries []fs.DirEntry) (wanted, others []fs.DirEntry) {
wanted, others = nfs.Separate(entries)
wanted, others = lfs.Separate(entries)
return wanted, others
}

func (f *Sample) folders(entries []fs.DirEntry) (wanted, others []fs.DirEntry) {
others, wanted = nfs.Separate(entries)
others, wanted = lfs.Separate(entries)
return wanted, others
}

Expand Down
4 changes: 2 additions & 2 deletions internal/kernel/contents.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/snivilised/traverse/core"
"github.com/snivilised/traverse/enums"
"github.com/snivilised/traverse/internal/third/lo"
"github.com/snivilised/traverse/nfs"
"github.com/snivilised/traverse/lfs"
"github.com/snivilised/traverse/pref"
"github.com/snivilised/traverse/tapable"
)
Expand All @@ -20,7 +20,7 @@ func newContents(behaviour *pref.SortBehaviour,
hook: hook,
}

contents.files, contents.folders = nfs.Separate(entries)
contents.files, contents.folders = lfs.Separate(entries)

return &contents
}
Expand Down
4 changes: 2 additions & 2 deletions internal/laboratory/directory-tree-builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/snivilised/traverse/collections"
"github.com/snivilised/traverse/internal/third/lo"
"github.com/snivilised/traverse/nfs"
"github.com/snivilised/traverse/lfs"
)

const (
Expand Down Expand Up @@ -55,7 +55,7 @@ func Provision(provider *IOProvider, verbose bool, portions ...string) (root str
func ensure(root string, provider *IOProvider, verbose bool) error {
repo := Repo("")
index := Path(repo, "test/data/musico-index.xml")
parent, _ := nfs.SplitParent(root)
parent, _ := lfs.SplitParent(root)
builder := directoryTreeBuilder{
root: TrimRoot(root),
stack: collections.NewStackWith([]string{parent}),
Expand Down
4 changes: 2 additions & 2 deletions internal/types/definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/snivilised/traverse/enums"
"github.com/snivilised/traverse/internal/measure"
"github.com/snivilised/traverse/internal/opts"
"github.com/snivilised/traverse/nfs"
"github.com/snivilised/traverse/lfs"
"github.com/snivilised/traverse/pref"
)

Expand Down Expand Up @@ -66,7 +66,7 @@ type (

// Resources are dependencies required for navigation
Resources struct {
FS nfs.FileSystems
FS lfs.FileSystems
Supervisor *measure.Supervisor
Binder *opts.Binder
}
Expand Down
2 changes: 1 addition & 1 deletion nfs/ensure-path-at.go → lfs/ensure-path-at.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nfs
package lfs

import (
"os"
Expand Down
10 changes: 5 additions & 5 deletions nfs/ensure-path-at_test.go → lfs/ensure-path-at_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nfs_test
package lfs_test

import (
"errors"
Expand All @@ -12,13 +12,13 @@ import (

"github.com/snivilised/li18ngo"
lab "github.com/snivilised/traverse/internal/laboratory"
"github.com/snivilised/traverse/lfs"
"github.com/snivilised/traverse/locale"
"github.com/snivilised/traverse/nfs"
)

var _ = Describe("EnsurePathAt", Ordered, func() {
var (
mocks *nfs.ResolveMocks
mocks *lfs.ResolveMocks
mfs *mkDirAllMapFS
)

Expand All @@ -33,7 +33,7 @@ var _ = Describe("EnsurePathAt", Ordered, func() {
})

BeforeEach(func() {
mocks = &nfs.ResolveMocks{
mocks = &lfs.ResolveMocks{
HomeFunc: func() (string, error) {
return filepath.Join(string(filepath.Separator), "home", "prodigy"), nil
},
Expand All @@ -60,7 +60,7 @@ var _ = Describe("EnsurePathAt", Ordered, func() {
location += string(filepath.Separator)
}

actual, err := nfs.EnsurePathAt(location, "default-test.log", perm, mfs)
actual, err := lfs.EnsurePathAt(location, "default-test.log", perm, mfs)
directory, _ := filepath.Split(actual)
directory = filepath.Clean(directory)
expected := lab.TrimRoot(lab.Path(home, entry.expected))
Expand Down
14 changes: 7 additions & 7 deletions nfs/file-systems.go → lfs/file-systems.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package nfs
package lfs

import (
"io/fs"
"os"
)

type nativeFS struct {
type localFS struct {
fsys fs.FS
}

// NewNativeFS creates a native file system.
func NewNativeFS(path string) fs.ReadDirFS {
return &nativeFS{
// NewLocalFS creates a native file system.
func NewLocalFS(path string) fs.ReadDirFS {
return &localFS{
fsys: os.DirFS(path),
}
}

func (n *nativeFS) Open(path string) (fs.File, error) {
func (n *localFS) Open(path string) (fs.File, error) {
return n.fsys.Open(path)
}

func (n *nativeFS) ReadDir(name string) ([]fs.DirEntry, error) {
func (n *localFS) ReadDir(name string) ([]fs.DirEntry, error) {
return fs.ReadDir(n.fsys, name)
}

Expand Down
2 changes: 1 addition & 1 deletion nfs/from-file-info.go → lfs/from-file-info.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nfs
package lfs

import (
"io/fs"
Expand Down
6 changes: 3 additions & 3 deletions nfs/matchers_test.go → lfs/matchers_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package nfs_test
package lfs_test

import (
"fmt"

"github.com/onsi/gomega/types"
"github.com/snivilised/traverse/nfs"
"github.com/snivilised/traverse/lfs"
)

type PathExistsMatcher struct {
Expand All @@ -21,7 +21,7 @@ func ExistInFS(fs interface{}) types.GomegaMatcher {
}

func (m *PathExistsMatcher) Match(actual interface{}) (bool, error) {
FS, fileSystemOK := m.FS.(nfs.MkDirAllFS)
FS, fileSystemOK := m.FS.(lfs.MkDirAllFS)
if !fileSystemOK {
return false, fmt.Errorf("❌ matcher expected a VirtualFS instance (%T)", FS)
}
Expand Down
6 changes: 3 additions & 3 deletions nfs/nfs-defs.go → lfs/nfs-defs.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package nfs
package lfs

import (
"io/fs"
"os"
)

// 📦 pkg: nfs - contains file system abstractions for navigation. Since
// there are no standard write-able file system interfaces,
// 📦 pkg: lfs - contains local file system abstractions for navigation.
// Since there are no standard write-able file system interfaces,
// we need to define proprietary ones here in this package.
// This is a low level package that should not use anything else in
// traverse.
Expand Down
2 changes: 1 addition & 1 deletion nfs/nfs-suite_test.go → lfs/nfs-suite_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nfs_test
package lfs_test

import (
"io/fs"
Expand Down
2 changes: 1 addition & 1 deletion nfs/resolve-mocks.go → lfs/resolve-mocks.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nfs
package lfs

// AbsFunc signature of function used to obtain the absolute representation of
// a path.
Expand Down
2 changes: 1 addition & 1 deletion nfs/resolve-path.go → lfs/resolve-path.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nfs
package lfs

import (
"os"
Expand Down
18 changes: 9 additions & 9 deletions nfs/resolve-path_test.go → lfs/resolve-path_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nfs_test
package lfs_test

import (
"fmt"
Expand All @@ -9,8 +9,8 @@ import (
. "github.com/onsi/gomega" //nolint:revive // ok

"github.com/snivilised/li18ngo"
"github.com/snivilised/traverse/lfs"
"github.com/snivilised/traverse/locale"
"github.com/snivilised/traverse/nfs"
)

var _ = Describe("ResolvePath", Ordered, func() {
Expand All @@ -26,19 +26,19 @@ var _ = Describe("ResolvePath", Ordered, func() {

DescribeTable("Overrides provided",
func(entry *RPEntry) {
mocks := nfs.ResolveMocks{
mocks := lfs.ResolveMocks{
HomeFunc: fakeHomeResolver,
AbsFunc: fakeAbsResolver,
}

if filepath.Separator == '/' {
actual := nfs.ResolvePath(entry.path, mocks)
actual := lfs.ResolvePath(entry.path, mocks)
Expect(actual).To(Equal(entry.expect))
} else {
normalisedPath := strings.ReplaceAll(entry.path, "/", string(filepath.Separator))
normalisedExpect := strings.ReplaceAll(entry.expect, "/", string(filepath.Separator))

actual := nfs.ResolvePath(normalisedPath, mocks)
actual := lfs.ResolvePath(normalisedPath, mocks)
Expect(actual).To(Equal(normalisedExpect))
}
},
Expand Down Expand Up @@ -81,25 +81,25 @@ var _ = Describe("ResolvePath", Ordered, func() {
When("No overrides provided", func() {
Context("and: home", func() {
It("🧪 should: not fail", func() {
nfs.ResolvePath("~/")
lfs.ResolvePath("~/")
})
})

Context("and: abs cwd", func() {
It("🧪 should: not fail", func() {
nfs.ResolvePath("./")
lfs.ResolvePath("./")
})
})

Context("and: abs parent", func() {
It("🧪 should: not fail", func() {
nfs.ResolvePath("../")
lfs.ResolvePath("../")
})
})

Context("and: abs grand parent", func() {
It("🧪 should: not fail", func() {
nfs.ResolvePath("../..")
lfs.ResolvePath("../..")
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion nfs/separate.go → lfs/separate.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nfs
package lfs

import (
"io/fs"
Expand Down
2 changes: 1 addition & 1 deletion nfs/split-parent.go → lfs/split-parent.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nfs
package lfs

import (
"path/filepath"
Expand Down
2 changes: 1 addition & 1 deletion tapable/tapable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ var _ = Describe("Tapable", Ordered, func() {
},
)

sys := tv.NewNativeFS(root)
sys := tv.NewLocalFS(root)
_, _ = o.Hooks.ReadDirectory.Default()(sys, root)
_, _ = o.Hooks.ReadDirectory.Invoke()(sys, root)

Expand Down
Loading

0 comments on commit c011c6f

Please sign in to comment.