a5er

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

README

a5er-dictionary

Apache-2.0 license

A5:Mk-2専用 論物変換スクリプトです。

使い方

チュートリアル

1.辞書ファイル(CSV形式)の用意

  • dict/dict.txtで辞書ファイルを用意する。
  • 下記のように論理名・物理名の順に定義する。
ID,id
記事,article
ヘッダ,header
タイトル,title
内容,content

2.A5:Mk-2のa5erを用意

3.変換ツールのインストール

4.コマンド実行

変換に失敗した場合は XXX と表示されます。表示がなくなるまで、辞書ファイルに追加します。

オプション
ERD_PATH=xxx(必須)

a5erファイルのパスを指定する。

DICT_PATH=xxx

辞書ファイルの位置を指定する。デフォルトはdict/dict.txtになる。

OUTPUT_PATH=xxx

物理名を付与したa5erファイルの保存先を指定する。

TABLE_PLURAL=(true|false)

テーブル名を複数形にするかどうかを指定する。デフォルトはtrue。 Rails採用の場合はtrue、それ以外の場合はfalseになるのが一般的。

インストール

$ go install github.com/future-architect/a5er-dictionary/cmd/a5er-dictionary@latest

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, c *Config) error

Types

type Config

type Config struct {
	// input
	InputA5erFilePath       string
	InputDictionaryFilePath string

	// output
	OutputA5erFilePath string

	// plural
	TablePlural  bool
	PluralClient *pluralize.Client
}

Config holds information about the configuration of a5er-dictionary.

type Convertor

type Convertor struct {
	// contains filtered or unexported fields
}

func NewConvertor

func NewConvertor() *Convertor

func (*Convertor) IsConverted

func (c *Convertor) IsConverted(logicalName string, dict *Dictionary) bool

IsConverted はlogicalNameがすでに論物変換済かどうか判定します

func (*Convertor) Logical2Physical

func (c *Convertor) Logical2Physical(logicalName string, dict *Dictionary) (string, bool)

type Dictionary

type Dictionary []*dict

func (*Dictionary) LoadCSV

func (d *Dictionary) LoadCSV(filepath string) error

func (*Dictionary) LoadMap added in v0.3.0

func (d *Dictionary) LoadMap(words map[string]string)

func (Dictionary) String

func (d Dictionary) String() string

type Entity

type Entity struct {
	// contains filtered or unexported fields
}

func NewEntity

func NewEntity(section *ini.Section) *Entity

本来全部のキーを取得する必要はないが、 gopkg.in/ini.v1 の仕様上、複数項目存在する同一キー(Field)に対して 想定している更新ができないため、全項目を取得して、本ツールで書き換える

func (*Entity) Convert

func (e *Entity) Convert(c *Config, conv *Convertor, dict *Dictionary)

type Field

type Field struct {
	// contains filtered or unexported fields
}

func (Field) String

func (f Field) String() string

type Relation

type Relation struct {
	// contains filtered or unexported fields
}

func NewRelation

func NewRelation(section *ini.Section) *Relation

func (*Relation) Convert

func (r *Relation) Convert(c *Config, conv *Convertor, dict *Dictionary)

Directories

Path Synopsis
cmd
internal
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL