Skip to content

Commit

Permalink
Merge pull request #104 from tychy/output-position
Browse files Browse the repository at this point in the history
output positions
  • Loading branch information
tychy committed Jun 29, 2024
2 parents 6581164 + c50e4ae commit 250c846
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 22 deletions.
4 changes: 2 additions & 2 deletions annotate-samples.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
NUM_SAMPLE=450
NUM_SAMPLE=789

SKIP_SAMPLES=(674)
SKIP_SAMPLES=(0)

# スクリプト全体でエラーが発生したら停止する
set -e
Expand Down
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@ func main() {
if err != nil {
panic(err)
}
execNames, err := h.ListHoujinExecutives()
execs, err := h.GetHoujinExecutives()
if err != nil {
panic(err)
}

execNames, err := h.GetHoujinExecutiveNames()
if err != nil {
panic(err)
}

fmt.Println("HoujinKaku: " + h.GetHoujinKaku())
fmt.Println("HoujinName: " + h.GetHoujinName())
fmt.Println("HoujinAddress: " + h.GetHoujinAddress())
fmt.Print("HoujinExecutiveValues: \n" + execs.String())
fmt.Println("HoujinExecutiveNames: [" + strings.Join(execNames, ",") + "]")
fmt.Println("HoujinRepresentativeNames: [" + strings.Join(repName, ",") + "]")
fmt.Println("HoujinCapital: ", h.GetHoujinCapital())
Expand Down
41 changes: 30 additions & 11 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ import (
)

type TestData struct {
HoujinKaku string `yaml:"HoujinKaku"`
HoujinName string `yaml:"HoujinName"`
HoujinAddress string `yaml:"HoujinAddress"`
HoujinExecutiveNames []string `yaml:"HoujinExecutiveNames"`
HoujinRepresentativeNames []string `yaml:"HoujinRepresentativeNames"`
HoujinCapital string `yaml:"HoujinCapital"`
HoujinCreatedAt string `yaml:"HoujinCreatedAt"`
HoujinBankruptedAt string `yaml:"HoujinBankruptedAt"`
HoujinDissolvedAt string `yaml:"HoujinDissolvedAt"`
HoujinContinuedAt string `yaml:"HoujinContinuedAt"`
HoujinKaku string `yaml:"HoujinKaku"`
HoujinName string `yaml:"HoujinName"`
HoujinAddress string `yaml:"HoujinAddress"`
HoujinExecutiveValues []toukibo.HoujinExecutiveValue `yaml:"HoujinExecutiveValues"`
HoujinExecutiveNames []string `yaml:"HoujinExecutiveNames"`
HoujinRepresentativeNames []string `yaml:"HoujinRepresentativeNames"`
HoujinCapital string `yaml:"HoujinCapital"`
HoujinCreatedAt string `yaml:"HoujinCreatedAt"`
HoujinBankruptedAt string `yaml:"HoujinBankruptedAt"`
HoujinDissolvedAt string `yaml:"HoujinDissolvedAt"`
HoujinContinuedAt string `yaml:"HoujinContinuedAt"`
}

func TestToukiboParser(t *testing.T) {
Expand Down Expand Up @@ -62,8 +63,26 @@ func TestToukiboParser(t *testing.T) {
t.Fatalf("address is not match,\nwant : %s,\ngot : %s,", td.HoujinAddress, h.GetHoujinAddress())
}

// Exec
execs, err := h.GetHoujinExecutives()
if err != nil {
t.Fatal(err)
}

if len(execs) != len(td.HoujinExecutiveValues) {
t.Fatalf("executive count is not match,\nwant : %d,\ngot : %d", len(td.HoujinExecutiveValues), len(execs))
}
for i, v := range execs {
if v.Name != td.HoujinExecutiveValues[i].Name {
t.Fatalf("executive name is not match,\nwant : %s,\ngot : %s", td.HoujinExecutiveValues[i].Name, v.Name)
}
if v.Position != td.HoujinExecutiveValues[i].Position {
t.Fatalf("executive position is not match,\nwant : %s,\ngot : %s", td.HoujinExecutiveValues[i].Position, v.Position)
}
}

// ExecutiveNames
execNames, err := h.ListHoujinExecutives()
execNames, err := h.GetHoujinExecutiveNames()
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion toukibo/houjin_body.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (h *HoujinBody) GetHoujinKaku() (HoujinkakuType, error) {
return HoujinKakuUnknown, fmt.Errorf("not found houjin name")
}

func (h *HoujinBody) ListHoujinExecutives() ([]HoujinExecutiveValue, error) {
func (h *HoujinBody) GetHoujinExecutives() ([]HoujinExecutiveValue, error) {
if len(h.HoujinExecutive) == 0 {
if h.HoujinDissolvedAt != "" {
// 法人が解散していれば代表はいなくても良い
Expand Down
9 changes: 4 additions & 5 deletions toukibo/houjin_executive.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
)

type HoujinExecutiveValue struct {
Name string
Position string
Name string `yaml:"Name"`
Position string `yaml:"Position"`
Address string
IsValid bool
RegisterAt string
Expand All @@ -24,9 +24,8 @@ type HoujinExecutiveValueArray []HoujinExecutiveValue
func (hva HoujinExecutiveValueArray) String() string {
var b strings.Builder
for _, hv := range hva {
b.WriteString("{")
b.WriteString(hv.String())
b.WriteString("},")
b.WriteString(" - Name: " + hv.Name + "\n")
b.WriteString(" Position: " + hv.Position + "\n")
}
return b.String()
}
8 changes: 6 additions & 2 deletions toukibo/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,12 @@ func (h *Houjin) GetHoujinCapital() int {
return 0
}

func (h *Houjin) ListHoujinExecutives() ([]string, error) {
execs, err := h.body.ListHoujinExecutives()
func (h *Houjin) GetHoujinExecutives() (HoujinExecutiveValueArray, error) {
return h.body.GetHoujinExecutives()
}

func (h *Houjin) GetHoujinExecutiveNames() ([]string, error) {
execs, err := h.body.GetHoujinExecutives()
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 250c846

Please sign in to comment.