From aa5661914ccc22bff7f3dbce95e002cb55503c84 Mon Sep 17 00:00:00 2001 From: ddddddO Date: Tue, 1 Feb 2022 00:55:11 +0900 Subject: [PATCH] refactor --- programmable.go | 4 ++-- tree.go | 12 ++++++------ tree_json.go | 2 +- tree_toml.go | 2 +- tree_yaml.go | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/programmable.go b/programmable.go index d9f9cc4..fadf042 100644 --- a/programmable.go +++ b/programmable.go @@ -41,7 +41,7 @@ func OutputProgrammably(w io.Writer, root *Node, optFns ...OptFn) error { if err := tree.grow(); err != nil { return err } - return tree.expand(w) + return tree.spread(w) } // MkdirProgrammably makes directories. @@ -70,7 +70,7 @@ func MkdirProgrammably(root *Node, optFns ...OptFn) error { if err := tree.grow(); err != nil { return err } - return tree.expand(os.Stdout) + return tree.spread(os.Stdout) } // 微妙? diff --git a/tree.go b/tree.go index 537de63..a15c582 100644 --- a/tree.go +++ b/tree.go @@ -23,7 +23,7 @@ func Output(w io.Writer, r io.Reader, optFns ...OptFn) error { if err := tree.grow(); err != nil { return err } - return tree.expand(w) + return tree.spread(w) } // Mkdir makes directories. @@ -96,7 +96,7 @@ type treeer interface { addRoot(root *Node) setDryRun(bool) // tree初期化のタイミングではなく、tree生成後に差し込む為に追加 grow() error - expand(w io.Writer) error + spread(w io.Writer) error mkdir() error } @@ -214,18 +214,18 @@ func (*tree) assembleBranchFinally(current, root *Node) { current.branch.path = filepath.Join(root.Name, current.branch.path) } -func (t *tree) expand(w io.Writer) error { +func (t *tree) spread(w io.Writer) error { branches := "" for _, root := range t.roots { - branches += t.expandBranch(root, "") + branches += t.spreadBranch(root, "") } return t.write(w, branches) } -func (*tree) expandBranch(current *Node, out string) string { +func (*tree) spreadBranch(current *Node, out string) string { out += current.getBranch() for _, child := range current.Children { - out = (*tree)(nil).expandBranch(child, out) + out = (*tree)(nil).spreadBranch(child, out) } return out } diff --git a/tree_json.go b/tree_json.go index 90536fc..47768db 100644 --- a/tree_json.go +++ b/tree_json.go @@ -9,7 +9,7 @@ type jsonTree struct { *tree } -func (jt *jsonTree) expand(w io.Writer) error { +func (jt *jsonTree) spread(w io.Writer) error { enc := json.NewEncoder(w) for _, root := range jt.roots { diff --git a/tree_toml.go b/tree_toml.go index e29e016..2334f46 100644 --- a/tree_toml.go +++ b/tree_toml.go @@ -10,7 +10,7 @@ type tomlTree struct { *tree } -func (tt *tomlTree) expand(w io.Writer) error { +func (tt *tomlTree) spread(w io.Writer) error { enc := toml.NewEncoder(w) for _, root := range tt.roots { diff --git a/tree_yaml.go b/tree_yaml.go index fc78c5a..4a5d454 100644 --- a/tree_yaml.go +++ b/tree_yaml.go @@ -10,7 +10,7 @@ type yamlTree struct { *tree } -func (yt *yamlTree) expand(w io.Writer) error { +func (yt *yamlTree) spread(w io.Writer) error { enc := yaml.NewEncoder(w) for _, root := range yt.roots {