Skip to content

Commit

Permalink
Merge pull request #11 from goark/migrate-repos
Browse files Browse the repository at this point in the history
Migrated repository to github.com/goark/aozora-api
  • Loading branch information
spiegel-im-spiegel committed Mar 20, 2022
2 parents da46c4d + 24bdaf8 commit ee8eeb5
Show file tree
Hide file tree
Showing 27 changed files with 98 additions and 710 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ^1.17
go-version: ^1.18
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/vulns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ^1.17
go-version: ^1.18
- name: install depm
run: go install github.com/spiegel-im-spiegel/depm@latest
run: go install github.com/goark/depm@latest
- name: WriteGoList
run: depm list --json > go.list
- name: Nancy
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# [aozora-api] -- APIs for Aozora-bunko RESTful Service by Golang

[![check vulns](https://github.com/spiegel-im-spiegel/aozora-api/workflows/vulns/badge.svg)](https://github.com/spiegel-im-spiegel/aozora-api/actions)
[![lint status](https://github.com/spiegel-im-spiegel/aozora-api/workflows/lint/badge.svg)](https://github.com/spiegel-im-spiegel/aozora-api/actions)
[![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/spiegel-im-spiegel/aozora-api/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/spiegel-im-spiegel/aozora-api.svg)](https://github.com/spiegel-im-spiegel/aozora-api/releases/latest)
[![check vulns](https://github.com/goark/aozora-api/workflows/vulns/badge.svg)](https://github.com/goark/aozora-api/actions)
[![lint status](https://github.com/goark/aozora-api/workflows/lint/badge.svg)](https://github.com/goark/aozora-api/actions)
[![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/goark/aozora-api/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/goark/aozora-api.svg)](https://github.com/goark/aozora-api/releases/latest)

This package is required Go 1.16 or later.

**Migrated repository to [github.com/goark/aozora-api][aozora-api]**

## Usage of package

### Import Package

```go
import "github.com/spiegel-im-spiegel/aozora-api"
import "github.com/goark/aozora-api"
```

### Search for Aozora-bunko Books Data
Expand Down Expand Up @@ -173,7 +175,7 @@ type Ranking []struct {
### Install and Build

```
$ go get github.com/spiegel-im-spiegel/aozora-api/cli/aozora-bunko
$ go get github.com/goark/aozora-api/cli/aozora-bunko
```

### Search for Aozora-bunko Books Data
Expand Down Expand Up @@ -223,4 +225,4 @@ $ aozora-bunko ranking 2019-01
- [aozorahack/pubserver2: Pubserver](https://github.com/aozorahack/pubserver2)
- [aozorahack/aozora-cli](https://github.com/aozorahack/aozora-cli) : CLI by Python

[aozora-api]: https://github.com/spiegel-im-spiegel/aozora-api "spiegel-im-spiegel/aozora-api: APIs for Aozora-bunko RESTful Service by Golang"
[aozora-api]: https://github.com/goark/aozora-api "goark/aozora-api: APIs for Aozora-bunko RESTful Service by Golang"
4 changes: 2 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ tasks:
cmds:
- go mod verify
- go test -shuffle on ./...
- docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.42.1 golangci-lint run --enable gosec --timeout 3m0s ./...
- docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.45.0 golangci-lint run --enable gosec --timeout 3m0s ./...
sources:
- ./go.mod
- '**/*.go'

clean:
desc: Initialize module and build cache, and remake go.sum file.
cmds:
- go mod tidy -v -go=1.17
- go mod tidy -v -go=1.18
8 changes: 4 additions & 4 deletions cli/aozora-bunko/facade/facade.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"fmt"
"runtime"

"github.com/goark/aozora-api/cli/aozora-bunko/ecode"
"github.com/goark/errs"
"github.com/goark/gocli/exitcode"
"github.com/goark/gocli/rwi"
"github.com/spf13/cobra"
"github.com/spiegel-im-spiegel/aozora-api/cli/aozora-bunko/ecode"
"github.com/spiegel-im-spiegel/errs"
"github.com/spiegel-im-spiegel/gocli/exitcode"
"github.com/spiegel-im-spiegel/gocli/rwi"
)

var (
Expand Down
6 changes: 3 additions & 3 deletions cli/aozora-bunko/facade/lookup-book.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"strconv"
"strings"

"github.com/goark/aozora-api"
"github.com/goark/errs"
"github.com/goark/gocli/rwi"
"github.com/spf13/cobra"
"github.com/spiegel-im-spiegel/aozora-api"
"github.com/spiegel-im-spiegel/errs"
"github.com/spiegel-im-spiegel/gocli/rwi"
)

type ContentType int
Expand Down
6 changes: 3 additions & 3 deletions cli/aozora-bunko/facade/lookup-person.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"os"
"strconv"

"github.com/goark/aozora-api"
"github.com/goark/errs"
"github.com/goark/gocli/rwi"
"github.com/spf13/cobra"
"github.com/spiegel-im-spiegel/aozora-api"
"github.com/spiegel-im-spiegel/errs"
"github.com/spiegel-im-spiegel/gocli/rwi"
)

//newLookupPersonCmd returns cobra.Command instance for show sub-command
Expand Down
6 changes: 3 additions & 3 deletions cli/aozora-bunko/facade/lookup-worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"os"
"strconv"

"github.com/goark/aozora-api"
"github.com/goark/errs"
"github.com/goark/gocli/rwi"
"github.com/spf13/cobra"
"github.com/spiegel-im-spiegel/aozora-api"
"github.com/spiegel-im-spiegel/errs"
"github.com/spiegel-im-spiegel/gocli/rwi"
)

//newLookupPersonCmd returns cobra.Command instance for show sub-command
Expand Down
4 changes: 2 additions & 2 deletions cli/aozora-bunko/facade/lookup.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package facade

import (
"github.com/goark/aozora-api/cli/aozora-bunko/ecode"
"github.com/goark/gocli/rwi"
"github.com/spf13/cobra"
"github.com/spiegel-im-spiegel/aozora-api/cli/aozora-bunko/ecode"
"github.com/spiegel-im-spiegel/gocli/rwi"
)

//newLookupCmd returns cobra.Command instance for show sub-command
Expand Down
6 changes: 3 additions & 3 deletions cli/aozora-bunko/facade/ranking.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"os"
"time"

"github.com/goark/aozora-api"
"github.com/goark/errs"
"github.com/goark/gocli/rwi"
"github.com/spf13/cobra"
"github.com/spiegel-im-spiegel/aozora-api"
"github.com/spiegel-im-spiegel/errs"
"github.com/spiegel-im-spiegel/gocli/rwi"
)

//newRankingCmd returns cobra.Command instance for show sub-command
Expand Down
8 changes: 4 additions & 4 deletions cli/aozora-bunko/facade/search-books.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package facade

import (
"github.com/goark/aozora-api"
"github.com/goark/aozora-api/cli/aozora-bunko/ecode"
"github.com/goark/errs"
"github.com/goark/gocli/rwi"
"github.com/spf13/cobra"
"github.com/spiegel-im-spiegel/aozora-api"
"github.com/spiegel-im-spiegel/aozora-api/cli/aozora-bunko/ecode"
"github.com/spiegel-im-spiegel/errs"
"github.com/spiegel-im-spiegel/gocli/rwi"
)

//newSearchBooksCmd returns cobra.Command instance for show sub-command
Expand Down
8 changes: 4 additions & 4 deletions cli/aozora-bunko/facade/search-persons.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package facade

import (
"github.com/goark/aozora-api"
"github.com/goark/aozora-api/cli/aozora-bunko/ecode"
"github.com/goark/errs"
"github.com/goark/gocli/rwi"
"github.com/spf13/cobra"
"github.com/spiegel-im-spiegel/aozora-api"
"github.com/spiegel-im-spiegel/aozora-api/cli/aozora-bunko/ecode"
"github.com/spiegel-im-spiegel/errs"
"github.com/spiegel-im-spiegel/gocli/rwi"
)

//newSearchPersonsCmd returns cobra.Command instance for show sub-command
Expand Down
8 changes: 4 additions & 4 deletions cli/aozora-bunko/facade/search-workers.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package facade

import (
"github.com/goark/aozora-api"
"github.com/goark/aozora-api/cli/aozora-bunko/ecode"
"github.com/goark/errs"
"github.com/goark/gocli/rwi"
"github.com/spf13/cobra"
"github.com/spiegel-im-spiegel/aozora-api"
"github.com/spiegel-im-spiegel/aozora-api/cli/aozora-bunko/ecode"
"github.com/spiegel-im-spiegel/errs"
"github.com/spiegel-im-spiegel/gocli/rwi"
)

//newSearchWorkersCmd returns cobra.Command instance for show sub-command
Expand Down
4 changes: 2 additions & 2 deletions cli/aozora-bunko/facade/search.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package facade

import (
"github.com/goark/aozora-api/cli/aozora-bunko/ecode"
"github.com/goark/gocli/rwi"
"github.com/spf13/cobra"
"github.com/spiegel-im-spiegel/aozora-api/cli/aozora-bunko/ecode"
"github.com/spiegel-im-spiegel/gocli/rwi"
)

//newSearchCmd returns cobra.Command instance for show sub-command
Expand Down
4 changes: 2 additions & 2 deletions cli/aozora-bunko/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"os"

"github.com/spiegel-im-spiegel/aozora-api/cli/aozora-bunko/facade"
"github.com/spiegel-im-spiegel/gocli/rwi"
"github.com/goark/aozora-api/cli/aozora-bunko/facade"
"github.com/goark/gocli/rwi"
)

//go:generate go-assets-builder -p report -s="/report/assets" -o report/assets.go report/assets/
Expand Down
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"strconv"
"time"

"github.com/spiegel-im-spiegel/errs"
"github.com/spiegel-im-spiegel/fetch"
"github.com/goark/errs"
"github.com/goark/fetch"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion entity-book.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"

"github.com/spiegel-im-spiegel/errs"
"github.com/goark/errs"
)

//Author is entity class of author and translator info.
Expand Down
2 changes: 1 addition & 1 deletion entity-person.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"

"github.com/spiegel-im-spiegel/errs"
"github.com/goark/errs"
)

//Person is entity class of person info.
Expand Down
2 changes: 1 addition & 1 deletion entity-ranking.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"

"github.com/spiegel-im-spiegel/errs"
"github.com/goark/errs"
)

//Ranking is entity class of ranking info.
Expand Down
2 changes: 1 addition & 1 deletion entity-worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"

"github.com/spiegel-im-spiegel/errs"
"github.com/goark/errs"
)

//Worker is entity class of worker info.
Expand Down
14 changes: 7 additions & 7 deletions entity-worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

var inputWorkerJSON = `{"id":845,"name":"雪森"}`
var inputWorkersJSON = "[" + inputWorkerJSON + "]"
var respWorkerJSON = `{"id":845,"name":"雪森"}`
var respWorkersJSON = "[" + respWorkerJSON + "]"
var responseWorkerJSON = `{"id":845,"name":"雪森"}`
var responseWorkersJSON = "[" + responseWorkerJSON + "]"

func TestDecodeWorker(t *testing.T) {
worker, err := DecodeWorker([]byte(inputWorkerJSON))
Expand All @@ -16,8 +16,8 @@ func TestDecodeWorker(t *testing.T) {
return
}
str := worker.String()
if str != respWorkerJSON {
t.Errorf("EncodeWorker() = \"%v\", want \"%v\".", str, respWorkerJSON)
if str != responseWorkerJSON {
t.Errorf("EncodeWorker() = \"%v\", want \"%v\".", str, responseWorkerJSON)
}
}

Expand All @@ -33,12 +33,12 @@ func TestDecodeWorkers(t *testing.T) {
return
}
str := string(b)
if str != respWorkersJSON {
t.Errorf("EncodeWorkers() = \"%v\", want \"%v\".", str, respWorkersJSON)
if str != responseWorkersJSON {
t.Errorf("EncodeWorkers() = \"%v\", want \"%v\".", str, responseWorkersJSON)
}
}

/* Copyright 2019 Spiegel
/* Copyright 2019-2022 Spiegel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
52 changes: 18 additions & 34 deletions error.go
Original file line number Diff line number Diff line change
@@ -1,40 +1,24 @@
package aozora

import "fmt"
import "errors"

//Error is error codes for books-data
type Error int

const (
ErrNullPointer Error = iota + 1
ErrHTTPStatus
ErrNoData
var (
ErrNullPointer = errors.New("Null reference instance")
ErrHTTPStatus = errors.New("Bad HTTP status")
ErrNoData = errors.New("No response data")
)

var errMessages = map[Error]string{
ErrNullPointer: "Null reference instance",
ErrHTTPStatus: "Bad HTTP status",
ErrNoData: "No response data",
}

func (e Error) Error() string {
if s, ok := errMessages[e]; ok {
return s
}
return fmt.Sprintf("unknown error (%d)", int(e))
}

/* Copyright 2019 Spiegel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
/* Copyright 2019-2022 Spiegel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

0 comments on commit ee8eeb5

Please sign in to comment.