From ed2b7b7cb98f5e771075338c650f50416a13d620 Mon Sep 17 00:00:00 2001 From: bel Date: Fri, 24 Mar 2023 22:27:56 -0600 Subject: [PATCH] rename v1 to v01 for git tag --- src/device/input/button/parser.go | 4 ++-- src/device/input/button/parser_test.go | 2 +- src/device/input/button/{v1.go => v01.go} | 20 +++++++++---------- .../input/button/{v1_test.go => v01_test.go} | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) rename src/device/input/button/{v1.go => v01.go} (73%) rename src/device/input/button/{v1_test.go => v01_test.go} (88%) diff --git a/src/device/input/button/parser.go b/src/device/input/button/parser.go index 6a7ea09..2a45977 100644 --- a/src/device/input/button/parser.go +++ b/src/device/input/button/parser.go @@ -12,8 +12,8 @@ type Parser interface { } func New(ctx context.Context, src raw.Raw) Parser { - if os.Getenv("BUTTON_PARSER_V1") == "true" { - return NewV1(src) + if os.Getenv("BUTTON_PARSER_V01") == "true" { + return NewV01(src) } return NewPlaintext(src) } diff --git a/src/device/input/button/parser_test.go b/src/device/input/button/parser_test.go index caba359..55adf25 100644 --- a/src/device/input/button/parser_test.go +++ b/src/device/input/button/parser_test.go @@ -7,5 +7,5 @@ import ( func TestParser(t *testing.T) { var _ button.Parser = button.Plaintext{} - var _ button.Parser = button.V1{} + var _ button.Parser = button.V01{} } diff --git a/src/device/input/button/v1.go b/src/device/input/button/v01.go similarity index 73% rename from src/device/input/button/v1.go rename to src/device/input/button/v01.go index a91c832..5dccd48 100644 --- a/src/device/input/button/v1.go +++ b/src/device/input/button/v01.go @@ -10,10 +10,10 @@ import ( var debugging = os.Getenv("DEBUG") == "true" type ( - V1 struct { + V01 struct { src raw.Raw } - v1Msg struct { + v01Msg struct { T int64 U string Y string @@ -21,26 +21,26 @@ type ( } ) -func NewV1(src raw.Raw) V1 { - return V1{ +func NewV01(src raw.Raw) V01 { + return V01{ src: src, } } -func (v1 V1) Close() { - v1.src.Close() +func (v01 V01) Close() { + v01.src.Close() } -func (v1 V1) Read() []Button { - line := v1.src.Read() - var msg v1Msg +func (v01 V01) Read() []Button { + line := v01.src.Read() + var msg v01Msg if err := json.Unmarshal(line, &msg); err != nil { log.Printf("%v: %s", err, line) } return msg.buttons() } -func (msg v1Msg) buttons() []Button { +func (msg v01Msg) buttons() []Button { buttons := make([]Button, len(msg.Y)+len(msg.N)) for i := range msg.Y { buttons[i] = Button{Char: msg.Y[i], Down: true} diff --git a/src/device/input/button/v1_test.go b/src/device/input/button/v01_test.go similarity index 88% rename from src/device/input/button/v1_test.go rename to src/device/input/button/v01_test.go index 45063cc..e1da2da 100644 --- a/src/device/input/button/v1_test.go +++ b/src/device/input/button/v01_test.go @@ -5,11 +5,11 @@ import ( "testing" ) -func TestV1(t *testing.T) { +func TestV01(t *testing.T) { src := constSrc(`{"T":1,"U":"bel","Y":"abc","N":"cde"}`) t.Logf("(%v) %s", len(src), src.Read()) - v1 := button.NewV1(src) - got := v1.Read() + v01 := button.NewV01(src) + got := v01.Read() want := []button.Button{ {Down: true, Char: 'a'}, {Down: true, Char: 'b'},