Skip to content

Commit

Permalink
chore: rewrite rot13 title and description
Browse files Browse the repository at this point in the history
Fixes #46
  • Loading branch information
ccoVeille committed Jun 6, 2024
1 parent a7d35c1 commit aa70067
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
12 changes: 6 additions & 6 deletions cmd/processor_rot13-encode.go → cmd/processor_rot13.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion processors/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var List = []list.Item{
Reverse{},
ReverseLines{},
ReverseLines{},
ROT13Encode{},
ROT13{},
SHA1{},
SHA224{},
SHA256{},
Expand Down
27 changes: 14 additions & 13 deletions processors/rot.go → processors/rot13.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,36 @@ import (
"strings"
)

// ROT13Encode converts string to ROT13 encoding.
type ROT13Encode struct{}
// ROT13 converts string with ROT13 cypher.
// https://en.wikipedia.org/wiki/ROT13
type ROT13 struct{}

func (p ROT13Encode) Name() string {
return "rot13-encode"
func (p ROT13) Name() string {
return "rot13"
}

func (p ROT13Encode) Alias() []string {
return []string{"rot13", "rot13-enc"}
func (p ROT13) Alias() []string {
return []string{"rot13-encode", "rot13-enc"}
}

func (p ROT13Encode) Transform(data []byte, _ ...Flag) (string, error) {
func (p ROT13) Transform(data []byte, _ ...Flag) (string, error) {
return strings.Map(rot13, string(data)), nil
}

func (p ROT13Encode) Flags() []Flag {
func (p ROT13) Flags() []Flag {
return nil
}

func (p ROT13Encode) Title() string {
title := "ROT13 Encode"
func (p ROT13) Title() string {
title := "ROT13 Letter Substitution"
return fmt.Sprintf("%s (%s)", title, p.Name())
}

func (p ROT13Encode) Description() string {
return "Encode your text to ROT13"
func (p ROT13) Description() string {
return "Cipher/Decipher your text with ROT13 letter substitution"
}

func (p ROT13Encode) FilterValue() string {
func (p ROT13) FilterValue() string {
return p.Title()
}

Expand Down
18 changes: 9 additions & 9 deletions processors/rot_test.go → processors/rot13_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
)

func TestROT13Encode_Transform(t *testing.T) {
func TestROT13_Transform(t *testing.T) {
type args struct {
data []byte
in1 []Flag
Expand Down Expand Up @@ -36,7 +36,7 @@ func TestROT13Encode_Transform(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := ROT13Encode{}
p := ROT13{}
got, err := p.Transform(tt.args.data, tt.args.in1...)
if (err != nil) != tt.wantErr {
t.Errorf("Transform() error = %v, wantErr %v", err, tt.wantErr)
Expand All @@ -49,7 +49,7 @@ func TestROT13Encode_Transform(t *testing.T) {
}
}

func TestROT13Encode_Command(t *testing.T) {
func TestROT13_Command(t *testing.T) {
test := struct {
alias []string
description string
Expand All @@ -58,14 +58,14 @@ func TestROT13Encode_Command(t *testing.T) {
name string
title string
}{
alias: []string{"rot13", "rot13-enc"},
description: "Encode your text to ROT13",
filterValue: "ROT13 Encode (rot13-encode)",
alias: []string{"rot13-encode", "rot13-enc"},
description: "Cipher/Decipher your text with ROT13 letter substitution",
filterValue: "ROT13 Letter Substitution (rot13)",
flags: nil,
name: "rot13-encode",
title: "ROT13 Encode (rot13-encode)",
name: "rot13",
title: "ROT13 Letter Substitution (rot13)",
}
p := ROT13Encode{}
p := ROT13{}
if got := p.Alias(); !reflect.DeepEqual(got, test.alias) {
t.Errorf("Alias() = %v, want %v", got, test.alias)
}
Expand Down

0 comments on commit aa70067

Please sign in to comment.