-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FS interface for glob, file, and directory sourcers. (#2)
- Loading branch information
Showing
15 changed files
with
830 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package config | ||
|
||
type ( | ||
directorySourcerOptions struct{ fs FileSystem } | ||
|
||
// DirectorySourcerConfigFunc is a function used to configure instances of | ||
// directory sourcers. | ||
DirectorySourcerConfigFunc func(*directorySourcerOptions) | ||
) | ||
|
||
// WithDirectorySourcerFS sets the FileSystem instance. | ||
func WithDirectorySourcerFS(fs FileSystem) DirectorySourcerConfigFunc { | ||
return func(o *directorySourcerOptions) { o.fs = fs } | ||
} | ||
|
||
func getDirectorySourcerConfigOptions(configs []DirectorySourcerConfigFunc) *directorySourcerOptions { | ||
options := &directorySourcerOptions{ | ||
fs: &realFileSystem{}, | ||
} | ||
|
||
for _, f := range configs { | ||
f(options) | ||
} | ||
|
||
return options | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package config | ||
|
||
type ( | ||
fileSourcerOptions struct{ fs FileSystem } | ||
|
||
// FileSourcerConfigFunc is a function used to configure instances of | ||
// file sourcers. | ||
FileSourcerConfigFunc func(*fileSourcerOptions) | ||
) | ||
|
||
// WithFileSourcerFS sets the FileSystem instance. | ||
func WithFileSourcerFS(fs FileSystem) FileSourcerConfigFunc { | ||
return func(o *fileSourcerOptions) { o.fs = fs } | ||
} | ||
|
||
func getFileSourcerConfigOptions(configs []FileSourcerConfigFunc) *fileSourcerOptions { | ||
options := &fileSourcerOptions{ | ||
fs: &realFileSystem{}, | ||
} | ||
|
||
for _, f := range configs { | ||
f(options) | ||
} | ||
|
||
return options | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.