From 937731930b945bc06ef5b0a970fae549ed9338ed Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Sun, 30 Jun 2024 20:46:04 +0900 Subject: [PATCH 01/32] =?UTF-8?q?add:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`repository`=E3=82=AF?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 1 + repository/Cargo.toml | 12 ++++++++++++ repository/src/lib.rs | 0 3 files changed, 13 insertions(+) create mode 100644 repository/Cargo.toml create mode 100644 repository/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 93c5c648..b3a32df1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ members = [ "tests", "domain", "service", + "repository", ] resolver = "2" diff --git a/repository/Cargo.toml b/repository/Cargo.toml new file mode 100644 index 00000000..48233c03 --- /dev/null +++ b/repository/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "repository" +version.workspace = true +edition.workspace = true +description.workspace = true +repository.workspace = true +authors.workspace = true +license.workspace = true +keywords.workspace = true +categories.workspace = true + +[dependencies] diff --git a/repository/src/lib.rs b/repository/src/lib.rs new file mode 100644 index 00000000..e69de29b From bbf30e3e63c04ae65527e307bc8910c7289ffb23 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Tue, 2 Jul 2024 22:52:34 +0900 Subject: [PATCH 02/32] =?UTF-8?q?add:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`domain`=E3=82=AF?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit エンティティやエラーを表す構造体などを格納する --- Cargo.toml | 1 + domain/Cargo.toml | 12 ++++++++++++ domain/src/lib.rs | 1 + 3 files changed, 14 insertions(+) create mode 100644 domain/Cargo.toml create mode 100644 domain/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index f74ebbde..5f2a4004 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = [ "wasm", "python", "tests", + "domain", ] resolver = "2" diff --git a/domain/Cargo.toml b/domain/Cargo.toml new file mode 100644 index 00000000..4dc9a436 --- /dev/null +++ b/domain/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "domain" +version.workspace = true +edition.workspace = true +description.workspace = true +repository.workspace = true +authors.workspace = true +license.workspace = true +keywords.workspace = true +categories.workspace = true + +[dependencies] diff --git a/domain/src/lib.rs b/domain/src/lib.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/domain/src/lib.rs @@ -0,0 +1 @@ + From 6776f0d70020a9351e15a20e8423602c3edeb801 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Tue, 2 Jul 2024 23:29:18 +0900 Subject: [PATCH 03/32] =?UTF-8?q?add:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`service`=E3=82=AF?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 1 + service/Cargo.toml | 12 ++++++++++++ service/src/lib.rs | 1 + 3 files changed, 14 insertions(+) create mode 100644 service/Cargo.toml create mode 100644 service/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 39206805..623f3143 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ members = [ "python", "tests", "domain", + "service", ] resolver = "2" diff --git a/service/Cargo.toml b/service/Cargo.toml new file mode 100644 index 00000000..38d68e4b --- /dev/null +++ b/service/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "service" +version.workspace = true +edition.workspace = true +description.workspace = true +repository.workspace = true +authors.workspace = true +license.workspace = true +keywords.workspace = true +categories.workspace = true + +[dependencies] diff --git a/service/src/lib.rs b/service/src/lib.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/service/src/lib.rs @@ -0,0 +1 @@ + From 100accf7084f8f4328c6194afcbec6f2ac8ebe27 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 17:59:06 +0900 Subject: [PATCH 04/32] =?UTF-8?q?add:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`repository`=E3=82=AF?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=81=AB`geolonia`=E3=83=A2?= =?UTF-8?q?=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- repository/src/geolonia.rs | 1 + repository/src/lib.rs | 1 + 2 files changed, 2 insertions(+) create mode 100644 repository/src/geolonia.rs diff --git a/repository/src/geolonia.rs b/repository/src/geolonia.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/repository/src/geolonia.rs @@ -0,0 +1 @@ + diff --git a/repository/src/lib.rs b/repository/src/lib.rs index e69de29b..bb3a487a 100644 --- a/repository/src/lib.rs +++ b/repository/src/lib.rs @@ -0,0 +1 @@ +pub mod geolonia; From 8a10b1b64fcb7b072331fa5cc58ed54b4b0886a7 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 18:01:20 +0900 Subject: [PATCH 05/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`core`=E3=82=AF?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=81=AB`repository`=E3=82=AF?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=81=B8=E3=81=AE=E4=BE=9D=E5=AD=98?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Cargo.toml b/core/Cargo.toml index 753f9f8e..1c073412 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -21,6 +21,7 @@ blocking = ["service/blocking"] [dependencies] domain = { path = "../domain" } service = { path = "../service" } +repository = { path = "../repository" } itertools = "0.13.0" js-sys = "0.3.67" nom = "7.1.3" From 9e95a529aba8466b5eed8c9849602000803c2760 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 18:25:01 +0900 Subject: [PATCH 06/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`core`=E3=82=AF?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=81=AB`domain`=E3=82=AF=E3=83=AC?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=81=B8=E3=81=AE=E4=BE=9D=E5=AD=98=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Cargo.toml b/core/Cargo.toml index 59ae7dec..8a7e205b 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -19,6 +19,7 @@ default = [] blocking = [] [dependencies] +domain = { path = "../domain" } itertools = "0.13.0" js-sys = "0.3.67" nom = "7.1.3" From d3c4a4e71bbb5bfea0377c79cadbe4b8c309d01b Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 18:30:21 +0900 Subject: [PATCH 07/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`core`=E3=82=AF?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=81=AE`err.rs`=E3=82=92`domain`?= =?UTF-8?q?=E3=82=AF=E3=83=AC=E3=83=BC=E3=83=88=E3=81=AE`geolonia`?= =?UTF-8?q?=E3=83=A2=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB=E3=81=AB=E7=A7=BB?= =?UTF-8?q?=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 1 + core/Cargo.toml | 2 +- core/src/api.rs | 2 +- core/src/api/city_master_api.rs | 2 +- core/src/api/prefecture_master_api.rs | 2 +- core/src/entity.rs | 2 +- core/src/lib.rs | 1 - core/src/parser.rs | 6 +++--- domain/Cargo.toml | 1 + domain/src/geolonia.rs | 1 + core/src/err.rs => domain/src/geolonia/error.rs | 0 domain/src/lib.rs | 2 +- 12 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 domain/src/geolonia.rs rename core/src/err.rs => domain/src/geolonia/error.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 5f2a4004..39206805 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ keywords = ["parser", "geo", "wasm"] categories = ["parser-implementations", "wasm"] [workspace.dependencies] +serde = { version = "1.0.192", features = ["derive"] } wasm-bindgen = "0.2.92" wasm-bindgen-futures = "0.4.42" wasm-bindgen-test = "0.3.42" diff --git a/core/Cargo.toml b/core/Cargo.toml index 8a7e205b..7f5127cd 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -26,7 +26,7 @@ nom = "7.1.3" rapidfuzz = "0.5.0" regex = "1.10.2" reqwest = { version = "0.12.3", default-features = false, features = ["json", "rustls-tls", "blocking"] } -serde = { version = "1.0.192", features = ["derive"] } +serde.workspace = true [dev-dependencies] tokio = { version = "1.38.0", features = ["rt", "macros"] } diff --git a/core/src/api.rs b/core/src/api.rs index dde47a9b..96aadbf3 100644 --- a/core/src/api.rs +++ b/core/src/api.rs @@ -4,7 +4,7 @@ pub mod prefecture_master_api; use crate::api::city_master_api::CityMasterApi; use crate::api::prefecture_master_api::PrefectureMasterApi; use crate::entity::{City, Prefecture}; -use crate::err::Error; +use domain::geolonia::error::Error; #[derive(Default)] pub struct AsyncApi { diff --git a/core/src/api/city_master_api.rs b/core/src/api/city_master_api.rs index 705a5ad1..8affc583 100644 --- a/core/src/api/city_master_api.rs +++ b/core/src/api/city_master_api.rs @@ -1,5 +1,5 @@ use crate::entity::{City, Town}; -use crate::err::{ApiErrorKind, Error}; +use domain::geolonia::error::{ApiErrorKind, Error}; pub struct CityMasterApi { pub server_url: &'static str, diff --git a/core/src/api/prefecture_master_api.rs b/core/src/api/prefecture_master_api.rs index c6bea9b3..31e67bcf 100644 --- a/core/src/api/prefecture_master_api.rs +++ b/core/src/api/prefecture_master_api.rs @@ -1,5 +1,5 @@ use crate::entity::Prefecture; -use crate::err::{ApiErrorKind, Error}; +use domain::geolonia::error::{ApiErrorKind, Error}; pub struct PrefectureMasterApi { pub server_url: &'static str, diff --git a/core/src/entity.rs b/core/src/entity.rs index ed163234..d9d54837 100644 --- a/core/src/entity.rs +++ b/core/src/entity.rs @@ -1,4 +1,4 @@ -use crate::err::Error; +use domain::geolonia::error::Error; use serde::{Deserialize, Serialize}; #[derive(Deserialize, PartialEq, Debug)] diff --git a/core/src/lib.rs b/core/src/lib.rs index 0f20c837..f42d1cf3 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -5,7 +5,6 @@ compile_error! { pub mod api; pub mod entity; -mod err; pub mod parser; mod tokenizer; mod util; diff --git a/core/src/parser.rs b/core/src/parser.rs index 2fd29b47..c5f3aba1 100644 --- a/core/src/parser.rs +++ b/core/src/parser.rs @@ -4,8 +4,8 @@ use crate::api::AsyncApi; #[cfg(feature = "blocking")] use crate::api::BlockingApi; use crate::entity::{Address, ParseResult}; -use crate::err::{Error, ParseErrorKind}; use crate::tokenizer::Tokenizer; +use domain::geolonia::error::{Error, ParseErrorKind}; pub(crate) mod adapter; pub(crate) mod filter; @@ -139,8 +139,8 @@ mod tests { use crate::api::city_master_api::CityMasterApi; use crate::api::prefecture_master_api::PrefectureMasterApi; use crate::api::AsyncApi; - use crate::err::ParseErrorKind; use crate::parser::parse; + use domain::geolonia::error::ParseErrorKind; use wasm_bindgen_test::{wasm_bindgen_test, wasm_bindgen_test_configure}; #[tokio::test] @@ -288,8 +288,8 @@ pub fn parse_blocking(api: Arc, input: &str) -> ParseResult { #[cfg(all(test, feature = "blocking"))] mod blocking_tests { use crate::api::BlockingApi; - use crate::err::ParseErrorKind; use crate::parser::parse_blocking; + use domain::geolonia::error::ParseErrorKind; #[test] fn parse_blocking_success_埼玉県秩父市熊木町8番15号() { diff --git a/domain/Cargo.toml b/domain/Cargo.toml index 4dc9a436..0d51c1ca 100644 --- a/domain/Cargo.toml +++ b/domain/Cargo.toml @@ -10,3 +10,4 @@ keywords.workspace = true categories.workspace = true [dependencies] +serde.workspace = true diff --git a/domain/src/geolonia.rs b/domain/src/geolonia.rs new file mode 100644 index 00000000..a91e7351 --- /dev/null +++ b/domain/src/geolonia.rs @@ -0,0 +1 @@ +pub mod error; diff --git a/core/src/err.rs b/domain/src/geolonia/error.rs similarity index 100% rename from core/src/err.rs rename to domain/src/geolonia/error.rs diff --git a/domain/src/lib.rs b/domain/src/lib.rs index 8b137891..bb3a487a 100644 --- a/domain/src/lib.rs +++ b/domain/src/lib.rs @@ -1 +1 @@ - +pub mod geolonia; From edda33ffa444ad4fe5394471baf041e75438d222 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 18:50:01 +0900 Subject: [PATCH 08/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`core/src/entity.rs`?= =?UTF-8?q?=E3=81=AE`ParseResult`=E3=82=92`core/src/parser.rs`=E3=81=AB?= =?UTF-8?q?=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/entity.rs | 7 ------- core/src/parser.rs | 9 ++++++++- python/src/lib.rs | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/src/entity.rs b/core/src/entity.rs index d9d54837..35d7ef51 100644 --- a/core/src/entity.rs +++ b/core/src/entity.rs @@ -1,4 +1,3 @@ -use domain::geolonia::error::Error; use serde::{Deserialize, Serialize}; #[derive(Deserialize, PartialEq, Debug)] @@ -63,9 +62,3 @@ impl Address { } } } - -#[derive(Serialize, PartialEq, Debug)] -pub struct ParseResult { - pub address: Address, - pub error: Option, -} diff --git a/core/src/parser.rs b/core/src/parser.rs index c5f3aba1..d3289f83 100644 --- a/core/src/parser.rs +++ b/core/src/parser.rs @@ -3,9 +3,10 @@ use std::sync::Arc; use crate::api::AsyncApi; #[cfg(feature = "blocking")] use crate::api::BlockingApi; -use crate::entity::{Address, ParseResult}; +use crate::entity::Address; use crate::tokenizer::Tokenizer; use domain::geolonia::error::{Error, ParseErrorKind}; +use serde::Serialize; pub(crate) mod adapter; pub(crate) mod filter; @@ -316,3 +317,9 @@ mod blocking_tests { ); } } + +#[derive(Serialize, PartialEq, Debug)] +pub struct ParseResult { + pub address: Address, + pub error: Option, +} diff --git a/python/src/lib.rs b/python/src/lib.rs index 380f72c1..052c5bfd 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use pyo3::prelude::*; -use japanese_address_parser::entity::ParseResult; +use japanese_address_parser::parser::ParseResult; use japanese_address_parser::parser::Parser; #[pyclass(name = "ParseResult")] From 39f395c23568e28995ce62990168b23569f88e3e Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 18:55:58 +0900 Subject: [PATCH 09/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E7=94=A8=E3=81=AE=E3=83=87=E3=83=BC=E3=82=BF=E3=82=92?= =?UTF-8?q?=E7=94=9F=E6=88=90=E3=81=99=E3=82=8B=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=E3=82=92`src/entity.rs`=E3=81=AB=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/entity.rs | 141 ++++++++++++++++++ .../adapter/vague_expression_adapter.rs | 82 +--------- core/src/util/sequence_matcher.rs | 69 --------- 3 files changed, 147 insertions(+), 145 deletions(-) diff --git a/core/src/entity.rs b/core/src/entity.rs index 35d7ef51..56db28c9 100644 --- a/core/src/entity.rs +++ b/core/src/entity.rs @@ -62,3 +62,144 @@ impl Address { } } } + +#[cfg(test)] +impl Prefecture { + /// only for testing + pub fn yamagata() -> Self { + Prefecture { + name: "山形県".to_string(), + cities: vec![ + "山形市".to_string(), + "米沢市".to_string(), + "鶴岡市".to_string(), + "酒田市".to_string(), + "新庄市".to_string(), + "寒河江市".to_string(), + "上山市".to_string(), + "村山市".to_string(), + "長井市".to_string(), + "天童市".to_string(), + "東根市".to_string(), + "尾花沢市".to_string(), + "南陽市".to_string(), + "東村山郡山辺町".to_string(), + "東村山郡中山町".to_string(), + "西村山郡河北町".to_string(), + "西村山郡西川町".to_string(), + "西村山郡朝日町".to_string(), + "西村山郡大江町".to_string(), + "北村山郡大石田町".to_string(), + "最上郡金山町".to_string(), + "最上郡最上町".to_string(), + "最上郡舟形町".to_string(), + "最上郡真室川町".to_string(), + "最上郡大蔵村".to_string(), + "最上郡鮭川村".to_string(), + "最上郡戸沢村".to_string(), + "東置賜郡高畠町".to_string(), + "東置賜郡川西町".to_string(), + "西置賜郡小国町".to_string(), + "西置賜郡白鷹町".to_string(), + "西置賜郡飯豊町".to_string(), + "東田川郡三川町".to_string(), + "東田川郡庄内町".to_string(), + "飽海郡遊佐町".to_string(), + ], + } + } + + /// only for testing + pub fn fukushima() -> Self { + Prefecture { + name: "福島県".to_string(), + cities: vec![ + "福島市".to_string(), + "会津若松市".to_string(), + "郡山市".to_string(), + "いわき市".to_string(), + "白河市".to_string(), + "須賀川市".to_string(), + "喜多方市".to_string(), + "相馬市".to_string(), + "二本松市".to_string(), + "田村市".to_string(), + "南相馬市".to_string(), + "伊達市".to_string(), + "本宮市".to_string(), + "伊達郡桑折町".to_string(), + "伊達郡国見町".to_string(), + "伊達郡川俣町".to_string(), + "安達郡大玉村".to_string(), + "岩瀬郡鏡石町".to_string(), + "岩瀬郡天栄村".to_string(), + "南会津郡下郷町".to_string(), + "南会津郡檜枝岐村".to_string(), + "南会津郡只見町".to_string(), + "南会津郡南会津町".to_string(), + "耶麻郡北塩原村".to_string(), + "耶麻郡西会津町".to_string(), + "耶麻郡磐梯町".to_string(), + "耶麻郡猪苗代町".to_string(), + "河沼郡会津坂下町".to_string(), + "河沼郡湯川村".to_string(), + "河沼郡柳津町".to_string(), + "大沼郡三島町".to_string(), + "大沼郡金山町".to_string(), + "大沼郡昭和村".to_string(), + "大沼郡会津美里町".to_string(), + "西白河郡西郷村".to_string(), + "西白河郡泉崎村".to_string(), + "西白河郡中島村".to_string(), + "西白河郡矢吹町".to_string(), + "東白川郡棚倉町".to_string(), + "東白川郡矢祭町".to_string(), + "東白川郡塙町".to_string(), + "東白川郡鮫川村".to_string(), + "石川郡石川町".to_string(), + "石川郡玉川村".to_string(), + "石川郡平田村".to_string(), + "石川郡浅川町".to_string(), + "石川郡古殿町".to_string(), + "田村郡三春町".to_string(), + "田村郡小野町".to_string(), + "双葉郡広野町".to_string(), + "双葉郡楢葉町".to_string(), + "双葉郡富岡町".to_string(), + "双葉郡川内村".to_string(), + "双葉郡大熊町".to_string(), + "双葉郡双葉町".to_string(), + "双葉郡浪江町".to_string(), + "双葉郡葛尾村".to_string(), + "相馬郡新地町".to_string(), + "相馬郡飯舘村".to_string(), + ], + } + } + + /// only for testing + pub fn fukui() -> Self { + Prefecture { + name: "福井県".to_string(), + cities: vec![ + "福井市".to_string(), + "敦賀市".to_string(), + "小浜市".to_string(), + "大野市".to_string(), + "勝山市".to_string(), + "鯖江市".to_string(), + "あわら市".to_string(), + "越前市".to_string(), + "坂井市".to_string(), + "吉田郡永平寺町".to_string(), + "今立郡池田町".to_string(), + "南条郡南越前町".to_string(), + "丹生郡越前町".to_string(), + "三方郡美浜町".to_string(), + "大飯郡高浜町".to_string(), + "大飯郡おおい町".to_string(), + "三方上中郡若狭町".to_string(), + ], + } + } +} diff --git a/core/src/parser/adapter/vague_expression_adapter.rs b/core/src/parser/adapter/vague_expression_adapter.rs index 1ff93c10..910e7f32 100644 --- a/core/src/parser/adapter/vague_expression_adapter.rs +++ b/core/src/parser/adapter/vague_expression_adapter.rs @@ -31,9 +31,9 @@ mod tests { #[test] fn 郡名が省略されている場合_吉田郡永平寺町() { - let hukui = Prefecture::hukui(); + let fukui = Prefecture::fukui(); let (rest, city_name) = VagueExpressionAdapter {} - .apply("永平寺町志比5-5", &hukui.cities) + .apply("永平寺町志比5-5", &fukui.cities) .unwrap(); assert_eq!(rest, "志比5-5"); assert_eq!(city_name, "吉田郡永平寺町"); @@ -41,9 +41,9 @@ mod tests { #[test] fn 郡名が省略されている場合_今立郡池田町() { - let hukui = Prefecture::hukui(); + let fukui = Prefecture::fukui(); let (rest, city_name) = VagueExpressionAdapter {} - .apply("池田町稲荷28-7", &hukui.cities) + .apply("池田町稲荷28-7", &fukui.cities) .unwrap(); assert_eq!(rest, "稲荷28-7"); assert_eq!(city_name, "今立郡池田町"); @@ -51,9 +51,9 @@ mod tests { #[test] fn 郡名が省略されている場合_南条郡南越前町() { - let hukui = Prefecture::hukui(); + let fukui = Prefecture::fukui(); let (rest, city_name) = VagueExpressionAdapter {} - .apply("南越前町今庄74-7-1", &hukui.cities) + .apply("南越前町今庄74-7-1", &fukui.cities) .unwrap(); assert_eq!(rest, "今庄74-7-1"); assert_eq!(city_name, "南条郡南越前町"); @@ -78,74 +78,4 @@ mod tests { assert_eq!(rest, "法田2672-2"); assert_eq!(city_name, "最上郡最上町"); } - - impl Prefecture { - fn yamagata() -> Self { - Prefecture { - name: "山形県".to_string(), - cities: vec![ - "山形市".to_string(), - "米沢市".to_string(), - "鶴岡市".to_string(), - "酒田市".to_string(), - "新庄市".to_string(), - "寒河江市".to_string(), - "上山市".to_string(), - "村山市".to_string(), - "長井市".to_string(), - "天童市".to_string(), - "東根市".to_string(), - "尾花沢市".to_string(), - "南陽市".to_string(), - "東村山郡山辺町".to_string(), - "東村山郡中山町".to_string(), - "西村山郡河北町".to_string(), - "西村山郡西川町".to_string(), - "西村山郡朝日町".to_string(), - "西村山郡大江町".to_string(), - "北村山郡大石田町".to_string(), - "最上郡金山町".to_string(), - "最上郡最上町".to_string(), - "最上郡舟形町".to_string(), - "最上郡真室川町".to_string(), - "最上郡大蔵村".to_string(), - "最上郡鮭川村".to_string(), - "最上郡戸沢村".to_string(), - "東置賜郡高畠町".to_string(), - "東置賜郡川西町".to_string(), - "西置賜郡小国町".to_string(), - "西置賜郡白鷹町".to_string(), - "西置賜郡飯豊町".to_string(), - "東田川郡三川町".to_string(), - "東田川郡庄内町".to_string(), - "飽海郡遊佐町".to_string(), - ], - } - } - - fn hukui() -> Self { - Prefecture { - name: "福井県".to_string(), - cities: vec![ - "福井市".to_string(), - "敦賀市".to_string(), - "小浜市".to_string(), - "大野市".to_string(), - "勝山市".to_string(), - "鯖江市".to_string(), - "あわら市".to_string(), - "越前市".to_string(), - "坂井市".to_string(), - "吉田郡永平寺町".to_string(), - "今立郡池田町".to_string(), - "南条郡南越前町".to_string(), - "丹生郡越前町".to_string(), - "三方郡美浜町".to_string(), - "大飯郡高浜町".to_string(), - "大飯郡おおい町".to_string(), - "三方上中郡若狭町".to_string(), - ], - } - } - } } diff --git a/core/src/util/sequence_matcher.rs b/core/src/util/sequence_matcher.rs index b5c59e30..7e01dd46 100644 --- a/core/src/util/sequence_matcher.rs +++ b/core/src/util/sequence_matcher.rs @@ -201,73 +201,4 @@ mod tests { assert!(result.is_err()); assert_eq!(result.err().unwrap(), NoCandidateExist); } - - impl Prefecture { - fn fukushima() -> Self { - Prefecture { - name: "福島県".to_string(), - cities: vec![ - "福島市".to_string(), - "会津若松市".to_string(), - "郡山市".to_string(), - "いわき市".to_string(), - "白河市".to_string(), - "須賀川市".to_string(), - "喜多方市".to_string(), - "相馬市".to_string(), - "二本松市".to_string(), - "田村市".to_string(), - "南相馬市".to_string(), - "伊達市".to_string(), - "本宮市".to_string(), - "伊達郡桑折町".to_string(), - "伊達郡国見町".to_string(), - "伊達郡川俣町".to_string(), - "安達郡大玉村".to_string(), - "岩瀬郡鏡石町".to_string(), - "岩瀬郡天栄村".to_string(), - "南会津郡下郷町".to_string(), - "南会津郡檜枝岐村".to_string(), - "南会津郡只見町".to_string(), - "南会津郡南会津町".to_string(), - "耶麻郡北塩原村".to_string(), - "耶麻郡西会津町".to_string(), - "耶麻郡磐梯町".to_string(), - "耶麻郡猪苗代町".to_string(), - "河沼郡会津坂下町".to_string(), - "河沼郡湯川村".to_string(), - "河沼郡柳津町".to_string(), - "大沼郡三島町".to_string(), - "大沼郡金山町".to_string(), - "大沼郡昭和村".to_string(), - "大沼郡会津美里町".to_string(), - "西白河郡西郷村".to_string(), - "西白河郡泉崎村".to_string(), - "西白河郡中島村".to_string(), - "西白河郡矢吹町".to_string(), - "東白川郡棚倉町".to_string(), - "東白川郡矢祭町".to_string(), - "東白川郡塙町".to_string(), - "東白川郡鮫川村".to_string(), - "石川郡石川町".to_string(), - "石川郡玉川村".to_string(), - "石川郡平田村".to_string(), - "石川郡浅川町".to_string(), - "石川郡古殿町".to_string(), - "田村郡三春町".to_string(), - "田村郡小野町".to_string(), - "双葉郡広野町".to_string(), - "双葉郡楢葉町".to_string(), - "双葉郡富岡町".to_string(), - "双葉郡川内村".to_string(), - "双葉郡大熊町".to_string(), - "双葉郡双葉町".to_string(), - "双葉郡浪江町".to_string(), - "双葉郡葛尾村".to_string(), - "相馬郡新地町".to_string(), - "相馬郡飯舘村".to_string(), - ], - } - } - } } From 1891d860ca154dc29ebbbbed0d23da84ad7b8a64 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 18:57:51 +0900 Subject: [PATCH 10/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`core`=E3=82=AF?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=81=AE`entity.rs`=E3=82=92`domain?= =?UTF-8?q?`=E3=83=A2=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB=E3=81=AE`geoloni?= =?UTF-8?q?a`=E3=83=A2=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB=E3=81=AB?= =?UTF-8?q?=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/api.rs | 2 +- core/src/api/city_master_api.rs | 6 +++--- core/src/api/prefecture_master_api.rs | 2 +- core/src/lib.rs | 1 - core/src/parser.rs | 2 +- core/src/parser/adapter/vague_expression_adapter.rs | 2 +- core/src/util/sequence_matcher.rs | 2 +- domain/src/geolonia.rs | 1 + {core/src => domain/src/geolonia}/entity.rs | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) rename {core/src => domain/src/geolonia}/entity.rs (99%) diff --git a/core/src/api.rs b/core/src/api.rs index 96aadbf3..43a09255 100644 --- a/core/src/api.rs +++ b/core/src/api.rs @@ -3,7 +3,7 @@ pub mod prefecture_master_api; use crate::api::city_master_api::CityMasterApi; use crate::api::prefecture_master_api::PrefectureMasterApi; -use crate::entity::{City, Prefecture}; +use domain::geolonia::entity::{City, Prefecture}; use domain::geolonia::error::Error; #[derive(Default)] diff --git a/core/src/api/city_master_api.rs b/core/src/api/city_master_api.rs index 8affc583..30acec26 100644 --- a/core/src/api/city_master_api.rs +++ b/core/src/api/city_master_api.rs @@ -1,4 +1,4 @@ -use crate::entity::{City, Town}; +use domain::geolonia::entity::{City, Town}; use domain::geolonia::error::{ApiErrorKind, Error}; pub struct CityMasterApi { @@ -56,7 +56,7 @@ impl CityMasterApi { #[cfg(all(test, not(feature = "blocking")))] mod tests { use crate::api::city_master_api::CityMasterApi; - use crate::entity::Town; + use domain::geolonia::entity::Town; #[tokio::test] async fn 非同期_石川県羽咋郡志賀町_成功() { @@ -91,7 +91,7 @@ mod tests { #[cfg(all(test, feature = "blocking"))] mod blocking_tests { use crate::api::city_master_api::CityMasterApi; - use crate::entity::Town; + use domain::geolonia::entity::Town; #[test] fn 同期_石川県羽咋郡志賀町_成功() { diff --git a/core/src/api/prefecture_master_api.rs b/core/src/api/prefecture_master_api.rs index 31e67bcf..fc9a9980 100644 --- a/core/src/api/prefecture_master_api.rs +++ b/core/src/api/prefecture_master_api.rs @@ -1,4 +1,4 @@ -use crate::entity::Prefecture; +use domain::geolonia::entity::Prefecture; use domain::geolonia::error::{ApiErrorKind, Error}; pub struct PrefectureMasterApi { diff --git a/core/src/lib.rs b/core/src/lib.rs index f42d1cf3..5090f731 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -4,7 +4,6 @@ compile_error! { } pub mod api; -pub mod entity; pub mod parser; mod tokenizer; mod util; diff --git a/core/src/parser.rs b/core/src/parser.rs index d3289f83..f7f08150 100644 --- a/core/src/parser.rs +++ b/core/src/parser.rs @@ -3,8 +3,8 @@ use std::sync::Arc; use crate::api::AsyncApi; #[cfg(feature = "blocking")] use crate::api::BlockingApi; -use crate::entity::Address; use crate::tokenizer::Tokenizer; +use domain::geolonia::entity::Address; use domain::geolonia::error::{Error, ParseErrorKind}; use serde::Serialize; diff --git a/core/src/parser/adapter/vague_expression_adapter.rs b/core/src/parser/adapter/vague_expression_adapter.rs index 910e7f32..fe560419 100644 --- a/core/src/parser/adapter/vague_expression_adapter.rs +++ b/core/src/parser/adapter/vague_expression_adapter.rs @@ -26,8 +26,8 @@ impl VagueExpressionAdapter { #[cfg(test)] mod tests { - use crate::entity::Prefecture; use crate::parser::adapter::vague_expression_adapter::VagueExpressionAdapter; + use domain::geolonia::entity::Prefecture; #[test] fn 郡名が省略されている場合_吉田郡永平寺町() { diff --git a/core/src/util/sequence_matcher.rs b/core/src/util/sequence_matcher.rs index 7e01dd46..6c263833 100644 --- a/core/src/util/sequence_matcher.rs +++ b/core/src/util/sequence_matcher.rs @@ -102,9 +102,9 @@ impl SequenceMatcher { #[cfg(test)] mod tests { - use crate::entity::Prefecture; use crate::util::sequence_matcher::Error::{MoreThanOneCandidateExist, NoCandidateExist}; use crate::util::sequence_matcher::SequenceMatcher; + use domain::geolonia::entity::Prefecture; #[test] fn get_length_of_longest_one() { diff --git a/domain/src/geolonia.rs b/domain/src/geolonia.rs index a91e7351..c5cd99ae 100644 --- a/domain/src/geolonia.rs +++ b/domain/src/geolonia.rs @@ -1 +1,2 @@ +pub mod entity; pub mod error; diff --git a/core/src/entity.rs b/domain/src/geolonia/entity.rs similarity index 99% rename from core/src/entity.rs rename to domain/src/geolonia/entity.rs index 56db28c9..b498c18c 100644 --- a/core/src/entity.rs +++ b/domain/src/geolonia/entity.rs @@ -63,7 +63,7 @@ impl Address { } } -#[cfg(test)] +#[doc(hidden)] impl Prefecture { /// only for testing pub fn yamagata() -> Self { From 339e7199359e8a27998fee6ab06de10d39c1a202 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 19:40:31 +0900 Subject: [PATCH 11/32] =?UTF-8?q?add:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`service`=E3=82=AF?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=81=AB`GeoloniaApiService`?= =?UTF-8?q?=E3=82=92=E4=BD=9C=E6=88=90=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/Cargo.toml | 3 +++ service/src/geolonia.rs | 41 +++++++++++++++++++++++++++++++++++++++++ service/src/lib.rs | 2 +- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 service/src/geolonia.rs diff --git a/service/Cargo.toml b/service/Cargo.toml index 38d68e4b..0bac9e61 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -10,3 +10,6 @@ keywords.workspace = true categories.workspace = true [dependencies] +domain = { path = "../domain" } +reqwest = { version = "0.12.5", default-features = false, features = ["json", "rustls-tls", "blocking"] } +serde.workspace = true diff --git a/service/src/geolonia.rs b/service/src/geolonia.rs new file mode 100644 index 00000000..2b47cf04 --- /dev/null +++ b/service/src/geolonia.rs @@ -0,0 +1,41 @@ +use domain::geolonia::error::{ApiErrorKind, Error}; +use reqwest::StatusCode; +use serde::de::DeserializeOwned; + +pub struct GeoloniaApiService {} + +impl GeoloniaApiService { + pub async fn get(&self, url: &str) -> Result + where + T: DeserializeOwned, + { + let response = reqwest::get(url) + .await + .map_err(|_| Error::new_api_error(ApiErrorKind::Fetch(url.to_string())))?; + if response.status() == StatusCode::OK { + let json = response + .json::() + .await + .map_err(|_| Error::new_api_error(ApiErrorKind::Deserialize(url.to_string())))?; + return Ok(json); + } + Err(Error::new_api_error(ApiErrorKind::Fetch(url.to_string()))) + } +} + +impl GeoloniaApiService { + pub fn get_blocking(&self, url: &str) -> Result + where + T: DeserializeOwned, + { + let response = reqwest::blocking::get(url) + .map_err(|_| Error::new_api_error(ApiErrorKind::Fetch(url.to_string())))?; + if response.status() == StatusCode::OK { + let json = response + .json::() + .map_err(|_| Error::new_api_error(ApiErrorKind::Deserialize(url.to_string())))?; + return Ok(json); + } + Err(Error::new_api_error(ApiErrorKind::Fetch(url.to_string()))) + } +} diff --git a/service/src/lib.rs b/service/src/lib.rs index 8b137891..bb3a487a 100644 --- a/service/src/lib.rs +++ b/service/src/lib.rs @@ -1 +1 @@ - +pub mod geolonia; From d54c5b8759acf5b81a9fd4acf3c70a5c1092dd5d Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 20:34:50 +0900 Subject: [PATCH 12/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`GeoloniaApiService`?= =?UTF-8?q?=E3=81=AB=E5=AF=BE=E3=81=97=E3=81=A6=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 1 + core/Cargo.toml | 2 +- service/Cargo.toml | 4 + service/src/geolonia.rs | 282 +++++++++++++++++++++++++++++++++++++++- tests/Cargo.toml | 2 +- 5 files changed, 288 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 623f3143..93c5c648 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ categories = ["parser-implementations", "wasm"] [workspace.dependencies] serde = { version = "1.0.192", features = ["derive"] } +tokio = { version = "1.38.0", features = ["rt", "macros"] } wasm-bindgen = "0.2.92" wasm-bindgen-futures = "0.4.42" wasm-bindgen-test = "0.3.42" diff --git a/core/Cargo.toml b/core/Cargo.toml index 7f5127cd..81f6a859 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -29,5 +29,5 @@ reqwest = { version = "0.12.3", default-features = false, features = ["json", "r serde.workspace = true [dev-dependencies] -tokio = { version = "1.38.0", features = ["rt", "macros"] } +tokio.workspace = true wasm-bindgen-test = { workspace = true } diff --git a/service/Cargo.toml b/service/Cargo.toml index 0bac9e61..8d654c1b 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -13,3 +13,7 @@ categories.workspace = true domain = { path = "../domain" } reqwest = { version = "0.12.5", default-features = false, features = ["json", "rustls-tls", "blocking"] } serde.workspace = true + +[dev-dependencies] +mockito = "1.4.0" +tokio.workspace = true diff --git a/service/src/geolonia.rs b/service/src/geolonia.rs index 2b47cf04..69ea22a6 100644 --- a/service/src/geolonia.rs +++ b/service/src/geolonia.rs @@ -1,7 +1,8 @@ -use domain::geolonia::error::{ApiErrorKind, Error}; use reqwest::StatusCode; use serde::de::DeserializeOwned; +use domain::geolonia::error::{ApiErrorKind, Error}; + pub struct GeoloniaApiService {} impl GeoloniaApiService { @@ -23,6 +24,149 @@ impl GeoloniaApiService { } } +#[cfg(test)] +mod async_tests { + use domain::geolonia::entity::{Prefecture, Town}; + use domain::geolonia::error::{ApiErrorKind, Error}; + + use crate::geolonia::GeoloniaApiService; + + #[tokio::test] + async fn 失敗_ネットワークエラー() { + let invalid_url = + "htttps://yuukitoriyama.github.io/geolonia-japanese-addresses-accompanist/"; + let api_service = GeoloniaApiService {}; + + let result = api_service.get::(invalid_url).await; + assert!(result.is_err()); + let error = result.unwrap_err(); + assert_eq!( + error, + Error::new_api_error(ApiErrorKind::Fetch(invalid_url.to_string())) + ); + } + + #[tokio::test] + async fn 失敗_404エラー() { + let mut server = mockito::Server::new_async().await; + let url = format!("{}/master.json", &server.url()); + let mock = server + .mock("GET", "/master.json") + .with_status(404) + .create_async() + .await; + + let api_service = GeoloniaApiService {}; + + let result = api_service.get::(&url).await; + assert!(result.is_err()); + let error = result.unwrap_err(); + assert_eq!(error, Error::new_api_error(ApiErrorKind::Fetch(url))); + + mock.assert_async().await; + } + + #[tokio::test] + async fn 失敗_パースエラー() { + let mut server = mockito::Server::new_async().await; + let url = format!("{}/master.json", &server.url()); + let mock = server + .mock("GET", "/master.json") + .with_status(200) + .with_header("content-type", "application/json") + .with_body(r#"{"hoge": true, "piyo": 100}"#) + .create_async() + .await; + + let api_service = GeoloniaApiService {}; + + let result = api_service.get::(&url).await; + assert!(result.is_err()); + let error = result.unwrap_err(); + assert_eq!(error, Error::new_api_error(ApiErrorKind::Deserialize(url))); + + mock.assert_async().await; + } + + #[tokio::test] + async fn 成功_都道府県マスタ() { + let mut server = mockito::Server::new_async().await; + let url = format!("{}/master.json", &server.url()); + let mock = server + .mock("GET", "/master.json") + .with_status(200) + .with_header("content-type", "application/json") + .with_body( + r#"{"name": "京都府", "cities": ["京都市北区", "京都市上京区", "京都市左京区"]}"#, + ) + .create_async() + .await; + + let api_service = GeoloniaApiService {}; + + let result = api_service.get::(&url).await; + assert!(result.is_ok()); + let entity = result.unwrap(); + assert_eq!(entity.name, "京都府"); + assert_eq!( + entity.cities, + vec!["京都市北区", "京都市上京区", "京都市左京区"] + ); + + mock.assert_async().await; + } + + #[tokio::test] + async fn 成功_市区町村マスタ() { + let mut server = mockito::Server::new_async().await; + let url = format!("{}/master.json", &server.url()); + let mock = server + .mock("GET", "/master.json") + .with_status(200) + .with_header("content-type", "application/json") + .with_body( + r#"[{"town":"上賀茂茨谷町","koaza":"","lat":35.075936,"lng":135.747963},{"town":"中川奥山","koaza":"","lat":35.090298,"lng":135.675356},{"town":"中川水谷","koaza":"","lat":35.097157,"lng":135.668432}]"#, + ) + .create_async() + .await; + + let api_service = GeoloniaApiService {}; + + let result = api_service.get::>(&url).await; + assert!(result.is_ok()); + let entity: Vec = result.unwrap(); + assert_eq!( + entity[0], + Town { + name: "上賀茂茨谷町".to_string(), + koaza: "".to_string(), + lat: Some(35.075936), + lng: Some(135.747963), + } + ); + assert_eq!( + entity[1], + Town { + name: "中川奥山".to_string(), + koaza: "".to_string(), + lat: Some(35.090298), + lng: Some(135.675356), + } + ); + assert_eq!( + entity[2], + Town { + name: "中川水谷".to_string(), + koaza: "".to_string(), + lat: Some(35.097157), + lng: Some(135.668432), + } + ); + + mock.assert_async().await; + } +} + impl GeoloniaApiService { pub fn get_blocking(&self, url: &str) -> Result where @@ -39,3 +183,139 @@ impl GeoloniaApiService { Err(Error::new_api_error(ApiErrorKind::Fetch(url.to_string()))) } } + +#[cfg(test)] +mod blocking_tests { + use domain::geolonia::entity::{Prefecture, Town}; + use domain::geolonia::error::{ApiErrorKind, Error}; + + use crate::geolonia::GeoloniaApiService; + + #[test] + fn 失敗_ネットワークエラー() { + let invalid_url = + "htttps://yuukitoriyama.github.io/geolonia-japanese-addresses-accompanist/"; + let api_service = GeoloniaApiService {}; + + let result = api_service.get_blocking::(invalid_url); + assert!(result.is_err()); + let error = result.unwrap_err(); + assert_eq!( + error, + Error::new_api_error(ApiErrorKind::Fetch(invalid_url.to_string())) + ); + } + + #[test] + fn 失敗_404エラー() { + let mut server = mockito::Server::new(); + let url = format!("{}/master.json", &server.url()); + let mock = server.mock("GET", "/master.json").with_status(404).create(); + + let api_service = GeoloniaApiService {}; + + let result = api_service.get_blocking::(&url); + assert!(result.is_err()); + let error = result.unwrap_err(); + assert_eq!(error, Error::new_api_error(ApiErrorKind::Fetch(url))); + + mock.assert(); + } + + #[test] + fn 失敗_パースエラー() { + let mut server = mockito::Server::new(); + let url = format!("{}/master.json", &server.url()); + let mock = server + .mock("GET", "/master.json") + .with_status(200) + .with_header("content-type", "application/json") + .with_body(r#"{"hoge": true, "piyo": 100}"#) + .create(); + + let api_service = GeoloniaApiService {}; + + let result = api_service.get_blocking::(&url); + assert!(result.is_err()); + let error = result.unwrap_err(); + assert_eq!(error, Error::new_api_error(ApiErrorKind::Deserialize(url))); + + mock.assert(); + } + + #[test] + fn 成功_都道府県マスタ() { + let mut server = mockito::Server::new(); + let url = format!("{}/master.json", &server.url()); + let mock = server + .mock("GET", "/master.json") + .with_status(200) + .with_header("content-type", "application/json") + .with_body( + r#"{"name": "京都府", "cities": ["京都市北区", "京都市上京区", "京都市左京区"]}"#, + ) + .create(); + + let api_service = GeoloniaApiService {}; + + let result = api_service.get_blocking::(&url); + assert!(result.is_ok()); + let entity = result.unwrap(); + assert_eq!(entity.name, "京都府"); + assert_eq!( + entity.cities, + vec!["京都市北区", "京都市上京区", "京都市左京区"] + ); + + mock.assert(); + } + + #[test] + fn 成功_市区町村マスタ() { + let mut server = mockito::Server::new(); + let url = format!("{}/master.json", &server.url()); + let mock = server + .mock("GET", "/master.json") + .with_status(200) + .with_header("content-type", "application/json") + .with_body( + r#"[{"town":"上賀茂茨谷町","koaza":"","lat":35.075936,"lng":135.747963},{"town":"中川奥山","koaza":"","lat":35.090298,"lng":135.675356},{"town":"中川水谷","koaza":"","lat":35.097157,"lng":135.668432}]"#, + ) + .create(); + + let api_service = GeoloniaApiService {}; + + let result = api_service.get_blocking::>(&url); + assert!(result.is_ok()); + let entity: Vec = result.unwrap(); + assert_eq!( + entity[0], + Town { + name: "上賀茂茨谷町".to_string(), + koaza: "".to_string(), + lat: Some(35.075936), + lng: Some(135.747963), + } + ); + assert_eq!( + entity[1], + Town { + name: "中川奥山".to_string(), + koaza: "".to_string(), + lat: Some(35.090298), + lng: Some(135.675356), + } + ); + assert_eq!( + entity[2], + Town { + name: "中川水谷".to_string(), + koaza: "".to_string(), + lat: Some(35.097157), + lng: Some(135.668432), + } + ); + + mock.assert(); + } +} diff --git a/tests/Cargo.toml b/tests/Cargo.toml index d228b3aa..3a572731 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -13,4 +13,4 @@ path = "integration_tests.rs" csv = "1.3.0" japanese-address-parser = { path = "../core" } serde = { version = "1.0.197", features = ["derive"] } -tokio = { version = "1.38.0", features = ["rt", "macros"] } +tokio.workspace = true From 8def6ff8644bb700f20a2ef1bb1a9a1850eb9301 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 21:10:04 +0900 Subject: [PATCH 13/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`core`=E3=83=A2?= =?UTF-8?q?=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB=E3=81=AE`CityMasterApi`?= =?UTF-8?q?=E3=81=AE=E5=AE=9F=E8=A3=85=E3=82=92`GeoloniaApiService`?= =?UTF-8?q?=E3=83=99=E3=83=BC=E3=82=B9=E3=81=AB=E3=81=AA=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Cargo.toml | 1 + core/src/api/city_master_api.rs | 51 ++++++++++++--------------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 81f6a859..2c812484 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -20,6 +20,7 @@ blocking = [] [dependencies] domain = { path = "../domain" } +service = { path = "../service" } itertools = "0.13.0" js-sys = "0.3.67" nom = "7.1.3" diff --git a/core/src/api/city_master_api.rs b/core/src/api/city_master_api.rs index 30acec26..07754eec 100644 --- a/core/src/api/city_master_api.rs +++ b/core/src/api/city_master_api.rs @@ -1,5 +1,6 @@ use domain::geolonia::entity::{City, Town}; -use domain::geolonia::error::{ApiErrorKind, Error}; +use domain::geolonia::error::Error; +use service::geolonia::GeoloniaApiService; pub struct CityMasterApi { pub server_url: &'static str, @@ -16,48 +17,31 @@ impl Default for CityMasterApi { impl CityMasterApi { pub async fn get(&self, prefecture_name: &str, city_name: &str) -> Result { let endpoint = format!("{}/{}/{}.json", self.server_url, prefecture_name, city_name); - let response = match reqwest::get(&endpoint).await { - Ok(result) => result, - Err(_) => return Err(Error::new_api_error(ApiErrorKind::Deserialize(endpoint))), - }; - if response.status() == 200 { - match response.json::>().await { - Ok(result) => Ok(City { - name: city_name.to_string(), - towns: result, - }), - Err(_) => Err(Error::new_api_error(ApiErrorKind::Deserialize(endpoint))), - } - } else { - Err(Error::new_api_error(ApiErrorKind::Fetch(endpoint))) - } + let api_service = GeoloniaApiService {}; + let towns = api_service.get::>(&endpoint).await?; + Ok(City { + name: city_name.to_string(), + towns, + }) } #[cfg(feature = "blocking")] pub fn get_blocking(&self, prefecture_name: &str, city_name: &str) -> Result { let endpoint = format!("{}/{}/{}.json", self.server_url, prefecture_name, city_name); - let response = match reqwest::blocking::get(&endpoint) { - Ok(result) => result, - Err(_) => return Err(Error::new_api_error(ApiErrorKind::Fetch(endpoint))), - }; - if response.status() == 200 { - match response.json::>() { - Ok(result) => Ok(City { - name: city_name.to_string(), - towns: result, - }), - Err(_) => Err(Error::new_api_error(ApiErrorKind::Deserialize(endpoint))), - } - } else { - Err(Error::new_api_error(ApiErrorKind::Fetch(endpoint))) - } + let api_service = GeoloniaApiService {}; + let towns = api_service.get_blocking::>(&endpoint)?; + Ok(City { + name: city_name.to_string(), + towns, + }) } } #[cfg(all(test, not(feature = "blocking")))] mod tests { - use crate::api::city_master_api::CityMasterApi; use domain::geolonia::entity::Town; + use crate::api::city_master_api::CityMasterApi; + #[tokio::test] async fn 非同期_石川県羽咋郡志賀町_成功() { let city_master_api: CityMasterApi = Default::default(); @@ -90,9 +74,10 @@ mod tests { #[cfg(all(test, feature = "blocking"))] mod blocking_tests { - use crate::api::city_master_api::CityMasterApi; use domain::geolonia::entity::Town; + use crate::api::city_master_api::CityMasterApi; + #[test] fn 同期_石川県羽咋郡志賀町_成功() { let city_master_api: CityMasterApi = Default::default(); From 4ad2c268dc5393f1b5da5548524b92da922407f5 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 21:14:50 +0900 Subject: [PATCH 14/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`core`=E3=83=A2?= =?UTF-8?q?=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB=E3=81=AE`PrefectureMasterA?= =?UTF-8?q?pi`=E3=81=AE=E5=AE=9F=E8=A3=85=E3=82=92`GeoloniaApiService`?= =?UTF-8?q?=E3=83=99=E3=83=BC=E3=82=B9=E3=81=AB=E3=81=AA=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/api/prefecture_master_api.rs | 31 ++++++--------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/core/src/api/prefecture_master_api.rs b/core/src/api/prefecture_master_api.rs index fc9a9980..aae07c3f 100644 --- a/core/src/api/prefecture_master_api.rs +++ b/core/src/api/prefecture_master_api.rs @@ -1,5 +1,6 @@ use domain::geolonia::entity::Prefecture; -use domain::geolonia::error::{ApiErrorKind, Error}; +use domain::geolonia::error::Error; +use service::geolonia::GeoloniaApiService; pub struct PrefectureMasterApi { pub server_url: &'static str, @@ -16,34 +17,14 @@ impl Default for PrefectureMasterApi { impl PrefectureMasterApi { pub async fn get(&self, prefecture_name: &str) -> Result { let endpoint = format!("{}/{}/master.json", self.server_url, prefecture_name); - let response = match reqwest::get(&endpoint).await { - Ok(result) => result, - Err(_) => return Err(Error::new_api_error(ApiErrorKind::Fetch(endpoint))), - }; - if response.status() == 200 { - match response.json::().await { - Ok(result) => Ok(result), - Err(_) => Err(Error::new_api_error(ApiErrorKind::Deserialize(endpoint))), - } - } else { - Err(Error::new_api_error(ApiErrorKind::Fetch(endpoint))) - } + let api_service = GeoloniaApiService {}; + api_service.get::(&endpoint).await } #[cfg(feature = "blocking")] pub fn get_blocking(&self, prefecture_name: &str) -> Result { let endpoint = format!("{}/{}/master.json", self.server_url, prefecture_name); - let response = match reqwest::blocking::get(&endpoint) { - Ok(result) => result, - Err(_) => return Err(Error::new_api_error(ApiErrorKind::Fetch(endpoint))), - }; - if response.status() == 200 { - match response.json::() { - Ok(result) => Ok(result), - Err(_) => Err(Error::new_api_error(ApiErrorKind::Deserialize(endpoint))), - } - } else { - Err(Error::new_api_error(ApiErrorKind::Fetch(endpoint))) - } + let api_service = GeoloniaApiService {}; + api_service.get_blocking::(&endpoint) } } From 5cbb4af2851321c84f3d0db42a985c1bbc90fa43 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 21:29:00 +0900 Subject: [PATCH 15/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`core/src/api/prefectur?= =?UTF-8?q?e=5Fmaster=5Fapi.rs`=E3=82=92`repository`=E3=82=AF=E3=83=AC?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=81=AE`geolonia`=E3=83=A2=E3=82=B8?= =?UTF-8?q?=E3=83=A5=E3=83=BC=E3=83=AB=E3=81=AB=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/api.rs | 4 ++-- core/src/parser.rs | 2 +- repository/Cargo.toml | 2 ++ repository/src/geolonia.rs | 2 +- .../api => repository/src/geolonia}/prefecture_master_api.rs | 4 ++-- 5 files changed, 8 insertions(+), 6 deletions(-) rename {core/src/api => repository/src/geolonia}/prefecture_master_api.rs (96%) diff --git a/core/src/api.rs b/core/src/api.rs index 43a09255..35c0ad73 100644 --- a/core/src/api.rs +++ b/core/src/api.rs @@ -1,10 +1,10 @@ pub mod city_master_api; -pub mod prefecture_master_api; +pub use repository::geolonia::prefecture_master_api; use crate::api::city_master_api::CityMasterApi; -use crate::api::prefecture_master_api::PrefectureMasterApi; use domain::geolonia::entity::{City, Prefecture}; use domain::geolonia::error::Error; +use repository::geolonia::prefecture_master_api::PrefectureMasterApi; #[derive(Default)] pub struct AsyncApi { diff --git a/core/src/parser.rs b/core/src/parser.rs index f7f08150..2c9023a4 100644 --- a/core/src/parser.rs +++ b/core/src/parser.rs @@ -138,10 +138,10 @@ pub async fn parse(api: Arc, input: &str) -> ParseResult { #[cfg(all(test, not(feature = "blocking")))] mod tests { use crate::api::city_master_api::CityMasterApi; - use crate::api::prefecture_master_api::PrefectureMasterApi; use crate::api::AsyncApi; use crate::parser::parse; use domain::geolonia::error::ParseErrorKind; + use repository::geolonia::prefecture_master_api::PrefectureMasterApi; use wasm_bindgen_test::{wasm_bindgen_test, wasm_bindgen_test_configure}; #[tokio::test] diff --git a/repository/Cargo.toml b/repository/Cargo.toml index 48233c03..09102222 100644 --- a/repository/Cargo.toml +++ b/repository/Cargo.toml @@ -10,3 +10,5 @@ keywords.workspace = true categories.workspace = true [dependencies] +domain = { path = "../domain" } +service = { path = "../service" } diff --git a/repository/src/geolonia.rs b/repository/src/geolonia.rs index 8b137891..2954d62c 100644 --- a/repository/src/geolonia.rs +++ b/repository/src/geolonia.rs @@ -1 +1 @@ - +pub mod prefecture_master_api; diff --git a/core/src/api/prefecture_master_api.rs b/repository/src/geolonia/prefecture_master_api.rs similarity index 96% rename from core/src/api/prefecture_master_api.rs rename to repository/src/geolonia/prefecture_master_api.rs index aae07c3f..6b0772a8 100644 --- a/core/src/api/prefecture_master_api.rs +++ b/repository/src/geolonia/prefecture_master_api.rs @@ -30,7 +30,7 @@ impl PrefectureMasterApi { #[cfg(all(test, not(feature = "blocking")))] mod tests { - use crate::api::prefecture_master_api::PrefectureMasterApi; + use crate::geolonia::prefecture_master_api::PrefectureMasterApi; #[tokio::test] async fn 非同期_富山県_成功() { @@ -77,7 +77,7 @@ mod tests { #[cfg(all(test, feature = "blocking"))] mod blocking_tests { - use crate::api::prefecture_master_api::PrefectureMasterApi; + use crate::geolonia::prefecture_master_api::PrefectureMasterApi; #[test] fn 同期_富山県_成功() { From 4ea9220b30a6b278f5075eafa1daef2775c6e438 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 21:31:54 +0900 Subject: [PATCH 16/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`core/src/api/city=5Fma?= =?UTF-8?q?ster=5Fapi.rs`=E3=82=92`repository`=E3=82=AF=E3=83=AC=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=81=AE`geolonia`=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E3=81=AB=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/api.rs | 4 ++-- core/src/parser.rs | 2 +- repository/src/geolonia.rs | 1 + {core/src/api => repository/src/geolonia}/city_master_api.rs | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) rename {core/src/api => repository/src/geolonia}/city_master_api.rs (96%) diff --git a/core/src/api.rs b/core/src/api.rs index 35c0ad73..a1476f7a 100644 --- a/core/src/api.rs +++ b/core/src/api.rs @@ -1,9 +1,9 @@ -pub mod city_master_api; +pub use repository::geolonia::city_master_api; pub use repository::geolonia::prefecture_master_api; -use crate::api::city_master_api::CityMasterApi; use domain::geolonia::entity::{City, Prefecture}; use domain::geolonia::error::Error; +use repository::geolonia::city_master_api::CityMasterApi; use repository::geolonia::prefecture_master_api::PrefectureMasterApi; #[derive(Default)] diff --git a/core/src/parser.rs b/core/src/parser.rs index 2c9023a4..11aa051c 100644 --- a/core/src/parser.rs +++ b/core/src/parser.rs @@ -137,10 +137,10 @@ pub async fn parse(api: Arc, input: &str) -> ParseResult { #[cfg(all(test, not(feature = "blocking")))] mod tests { - use crate::api::city_master_api::CityMasterApi; use crate::api::AsyncApi; use crate::parser::parse; use domain::geolonia::error::ParseErrorKind; + use repository::geolonia::city_master_api::CityMasterApi; use repository::geolonia::prefecture_master_api::PrefectureMasterApi; use wasm_bindgen_test::{wasm_bindgen_test, wasm_bindgen_test_configure}; diff --git a/repository/src/geolonia.rs b/repository/src/geolonia.rs index 2954d62c..0c2dceda 100644 --- a/repository/src/geolonia.rs +++ b/repository/src/geolonia.rs @@ -1 +1,2 @@ +pub mod city_master_api; pub mod prefecture_master_api; diff --git a/core/src/api/city_master_api.rs b/repository/src/geolonia/city_master_api.rs similarity index 96% rename from core/src/api/city_master_api.rs rename to repository/src/geolonia/city_master_api.rs index 07754eec..f13fbb8b 100644 --- a/core/src/api/city_master_api.rs +++ b/repository/src/geolonia/city_master_api.rs @@ -40,7 +40,7 @@ impl CityMasterApi { mod tests { use domain::geolonia::entity::Town; - use crate::api::city_master_api::CityMasterApi; + use crate::geolonia::city_master_api::CityMasterApi; #[tokio::test] async fn 非同期_石川県羽咋郡志賀町_成功() { @@ -76,7 +76,7 @@ mod tests { mod blocking_tests { use domain::geolonia::entity::Town; - use crate::api::city_master_api::CityMasterApi; + use crate::geolonia::city_master_api::CityMasterApi; #[test] fn 同期_石川県羽咋郡志賀町_成功() { From f8ba7e45924284907aec7856d6c2443b55b2c725 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 21:38:05 +0900 Subject: [PATCH 17/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`repository`=E3=82=AF?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=81=AB`blocking`=E3=83=95?= =?UTF-8?q?=E3=82=A3=E3=83=BC=E3=83=81=E3=83=A3=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Cargo.toml | 2 +- repository/Cargo.toml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 1c073412..0e645079 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -16,7 +16,7 @@ crate-type = ["rlib", "cdylib"] [features] default = [] -blocking = ["service/blocking"] +blocking = ["repository/blocking"] [dependencies] domain = { path = "../domain" } diff --git a/repository/Cargo.toml b/repository/Cargo.toml index 09102222..75f24aaf 100644 --- a/repository/Cargo.toml +++ b/repository/Cargo.toml @@ -9,6 +9,9 @@ license.workspace = true keywords.workspace = true categories.workspace = true +[features] +blocking = ["service/blocking"] + [dependencies] domain = { path = "../domain" } service = { path = "../service" } From 0558c1f0db0c60dc7c971a8f0f525171b7bb03b8 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 21:38:05 +0900 Subject: [PATCH 18/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`service`=E3=82=AF?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=81=AB`blocking`=E3=83=95?= =?UTF-8?q?=E3=82=A3=E3=83=BC=E3=83=81=E3=83=A3=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Cargo.toml | 2 +- service/Cargo.toml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 2c812484..0b6b70bf 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -16,7 +16,7 @@ crate-type = ["rlib", "cdylib"] [features] default = [] -blocking = [] +blocking = ["service/blocking"] [dependencies] domain = { path = "../domain" } diff --git a/service/Cargo.toml b/service/Cargo.toml index 8d654c1b..1f877b39 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -9,9 +9,12 @@ license.workspace = true keywords.workspace = true categories.workspace = true +[features] +blocking = ["reqwest/blocking"] + [dependencies] domain = { path = "../domain" } -reqwest = { version = "0.12.5", default-features = false, features = ["json", "rustls-tls", "blocking"] } +reqwest = { version = "0.12.5", default-features = false, features = ["json", "rustls-tls"] } serde.workspace = true [dev-dependencies] From f1de0d3d91ff3099235971a95ab248beddd05a98 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 21:51:11 +0900 Subject: [PATCH 19/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`core`=E3=81=8B?= =?UTF-8?q?=E3=82=89`service`=E3=81=B8=E3=81=AE=E4=BE=9D=E5=AD=98=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `service`に直接依存するのではなく`repository`に依存する方が良いため --- core/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 0e645079..984f6616 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -20,7 +20,6 @@ blocking = ["repository/blocking"] [dependencies] domain = { path = "../domain" } -service = { path = "../service" } repository = { path = "../repository" } itertools = "0.13.0" js-sys = "0.3.67" From f5371e13283f25f835634f26566ccff99998ee63 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 22:10:38 +0900 Subject: [PATCH 20/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`service`=E3=82=AF?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=81=AE`reqwest::blocking::*`?= =?UTF-8?q?=E3=82=92=E4=BD=BF=E7=94=A8=E3=81=97=E3=81=A6=E3=81=84=E3=82=8B?= =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=81=AF`blocking`?= =?UTF-8?q?=E3=83=95=E3=82=A3=E3=83=BC=E3=83=81=E3=83=A3=E3=82=92=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E3=81=97=E3=81=A6=E3=81=84=E3=82=8B=E6=99=82=E3=81=AE?= =?UTF-8?q?=E3=81=BF=E3=83=93=E3=83=AB=E3=83=89=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wasm-pack buildが失敗するため --- service/src/geolonia.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/service/src/geolonia.rs b/service/src/geolonia.rs index 69ea22a6..e5af4430 100644 --- a/service/src/geolonia.rs +++ b/service/src/geolonia.rs @@ -167,6 +167,7 @@ mod async_tests { } } +#[cfg(feature = "blocking")] impl GeoloniaApiService { pub fn get_blocking(&self, url: &str) -> Result where @@ -184,7 +185,7 @@ impl GeoloniaApiService { } } -#[cfg(test)] +#[cfg(all(test, feature = "blocking"))] mod blocking_tests { use domain::geolonia::entity::{Prefecture, Town}; use domain::geolonia::error::{ApiErrorKind, Error}; From 2ed035f06426240a83449c10153a6b206ca172f8 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Thu, 4 Jul 2024 22:20:48 +0900 Subject: [PATCH 21/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`core`=E3=83=A2?= =?UTF-8?q?=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB=E3=81=8B=E3=82=89`reqwest`?= =?UTF-8?q?=E3=81=AE=E4=BE=9D=E5=AD=98=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ネットワークアクセスは`service`クレートの責務であり、`core`では使用されなくなったため --- core/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 0b6b70bf..753f9f8e 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -26,7 +26,6 @@ js-sys = "0.3.67" nom = "7.1.3" rapidfuzz = "0.5.0" regex = "1.10.2" -reqwest = { version = "0.12.3", default-features = false, features = ["json", "rustls-tls", "blocking"] } serde.workspace = true [dev-dependencies] From 76e61950209e9a72d9a83560275767067dcbe1e1 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Sat, 6 Jul 2024 00:42:08 +0900 Subject: [PATCH 22/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20CI=E3=81=AE=E6=95=B4?= =?UTF-8?q?=E5=82=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新しく定義したクレートに対してもテストが走るように設定を修正。 併せて、テストの順序の変更や、ワークフローの分割などを行なった。 c.f. edb5518 eed76109 258601a8 --- .github/workflows/code-check.yaml | 42 --------------- .github/workflows/code-quality-check.yaml | 23 +++++++++ .github/workflows/run-test.yaml | 62 +++++++++++++++++++++++ .github/workflows/wasm-pack-test.yaml | 27 ---------- 4 files changed, 85 insertions(+), 69 deletions(-) delete mode 100644 .github/workflows/code-check.yaml create mode 100644 .github/workflows/code-quality-check.yaml create mode 100644 .github/workflows/run-test.yaml delete mode 100644 .github/workflows/wasm-pack-test.yaml diff --git a/.github/workflows/code-check.yaml b/.github/workflows/code-check.yaml deleted file mode 100644 index 07d9b88b..00000000 --- a/.github/workflows/code-check.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: Unit test & Code check - -on: - push: - branches: [ "main" ] - pull_request: - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 - with: - cache-all-crates: true - shared-key: 'test-on-pr' - key: 'main' - save-if: ${{ github.ref == 'refs/heads/main' }} # mainブランチにコミットが追加された時のみキャッシュを保存する - cache-provider: 'github' - - name: Set up clippy - run: rustup component add clippy - - name: Code review with clippy - uses: giraffate/clippy-action@v1 - with: - reporter: 'github-pr-review' - filter_mode: 'nofilter' - github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Build check - run: cargo build --verbose - - name: Unit Testing - working-directory: core - run: | - cargo test - cargo test --features blocking - - name: Integration Testing - working-directory: tests - run: cargo test diff --git a/.github/workflows/code-quality-check.yaml b/.github/workflows/code-quality-check.yaml new file mode 100644 index 00000000..936a7f5f --- /dev/null +++ b/.github/workflows/code-quality-check.yaml @@ -0,0 +1,23 @@ +name: Code quality check + +on: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + with: + cache-all-crates: true + shared-key: 'code-quality' + cache-provider: 'github' + - name: Setup clippy + run: rustup component add clippy + - name: Code review with clippy + uses: giraffate/clippy-action@v1 + with: + reporter: 'github-pr-review' + filter_mode: 'nofilter' + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/run-test.yaml b/.github/workflows/run-test.yaml new file mode 100644 index 00000000..65a30e47 --- /dev/null +++ b/.github/workflows/run-test.yaml @@ -0,0 +1,62 @@ +name: Unit test & Integration test + +on: + pull_request: + push: + branches: [ 'main' ] + +env: + CARGO_TERM_COLOR: always + +jobs: + run-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + with: + cache-all-crates: true + shared-key: 'test-on-pr' + key: 'main' + save-if: ${{ github.ref == 'refs/heads/main' }} # mainブランチにコミットが追加された時のみキャッシュを保存する + - name: Test domain + working-directory: domain + run: cargo test + - name: Test service + working-directory: service + run: | + cargo test + cargo test --features=blocking + - name: Test repository + working-directory: repository + run: | + cargo test + cargo test --features=blocking + - name: Test core + working-directory: core + run: | + cargo test + cargo test --features=blocking + - name: Integration test + working-directory: tests + run: cargo test + + run-tests-wasm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + with: + cache-all-crates: true + shared-key: 'wasm-pack' + key: 'main' + save-if: ${{ github.ref == 'refs/heads/main' }} # mainブランチにコミットが追加された時のみキャッシュを保存する + cache-provider: 'github' + - name: Install wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + - name: Run wasm-pack test for core(japanese-address-parser) + working-directory: core + run: wasm-pack test --firefox --headless + - name: Build check for wasm crate + working-directory: wasm + run: wasm-pack build --target web --scope toriyama diff --git a/.github/workflows/wasm-pack-test.yaml b/.github/workflows/wasm-pack-test.yaml deleted file mode 100644 index 08c641f1..00000000 --- a/.github/workflows/wasm-pack-test.yaml +++ /dev/null @@ -1,27 +0,0 @@ -name: wasm-pack build & wasm-pack test - -on: - push: - branches: [ "main" ] - pull_request: - -jobs: - wasm-pack: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 - with: - cache-all-crates: true - shared-key: 'wasm-pack' - key: 'main' - save-if: ${{ github.ref == 'refs/heads/main' }} # mainブランチにコミットが追加された時のみキャッシュを保存する - cache-provider: 'github' - - name: Install wasm-pack - run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - - name: Unit test for core module - working-directory: core - run: wasm-pack test --firefox --headless - - name: Build test for wasm module - working-directory: wasm - run: wasm-pack build --target web --scope toriyama From ba3e48d880723213ceda79cfdbc8f09add4108a5 Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Sat, 6 Jul 2024 01:09:22 +0900 Subject: [PATCH 23/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20README=E3=81=AB?= =?UTF-8?q?=E8=B2=BC=E3=81=A3=E3=81=A6=E3=81=84=E3=82=8BCI=E3=81=AE?= =?UTF-8?q?=E3=82=B9=E3=83=86=E3=83=BC=E3=82=BF=E3=82=B9=E3=83=90=E3=83=83?= =?UTF-8?q?=E3=83=81=E3=82=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ワークフローが変更になるため --- README.md | 2 +- python/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c7221911..412cc8e1 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Docs](https://docs.rs/japanese-address-parser/badge.svg)](https://docs.rs/japanese-address-parser) [![Crates.io (latest)](https://img.shields.io/crates/v/japanese-address-parser)](https://crates.io/crates/japanese-address-parser) ![Rust Version](https://img.shields.io/badge/rust%20version-%3E%3D1.73.0-orange) -[![Unit test & Code check](https://github.com/YuukiToriyama/japanese-address-parser/actions/workflows/code-check.yaml/badge.svg)](https://github.com/YuukiToriyama/japanese-address-parser/actions/workflows/code-check.yaml) +[![Unit test & Integration test](https://github.com/YuukiToriyama/japanese-address-parser/actions/workflows/run-test.yaml/badge.svg?branch=main)](https://github.com/YuukiToriyama/japanese-address-parser/actions/workflows/run-test.yaml) A Rust Library to parse japanese addresses. diff --git a/python/README.md b/python/README.md index 69ae3209..6ed3cc1d 100644 --- a/python/README.md +++ b/python/README.md @@ -3,7 +3,7 @@ A python toolkit for processing japanese addresses [![PyPI - Version](https://img.shields.io/pypi/v/japanese-address-parser-py)](https://pypi.org/project/japanese-address-parser-py/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/japanese-address-parser-py)](https://pypi.org/project/japanese-address-parser-py/#history) -[![Unit test & Code check](https://github.com/YuukiToriyama/japanese-address-parser/actions/workflows/code-check.yaml/badge.svg)](https://github.com/YuukiToriyama/japanese-address-parser/actions/workflows/code-check.yaml) +[![Unit test & Integration test](https://github.com/YuukiToriyama/japanese-address-parser/actions/workflows/run-test.yaml/badge.svg?branch=main)](https://github.com/YuukiToriyama/japanese-address-parser/actions/workflows/run-test.yaml) ## What is it? **japanese-address-parser-py** is a Python package for parsing japanese addresses. From b6978461c06e22ea4d7c4a65d1c44420bd797cce Mon Sep 17 00:00:00 2001 From: Yuuki Toriyama Date: Sat, 6 Jul 2024 01:42:43 +0900 Subject: [PATCH 24/32] =?UTF-8?q?update:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20=E5=BE=8C=E6=96=B9?= =?UTF-8?q?=E4=BA=92=E6=8F=9B=E6=80=A7=E3=82=92=E4=BF=9D=E3=81=A4=E3=81=9F?= =?UTF-8?q?=E3=82=81=E3=81=AB`domain::geolonia::entity::*`=E3=81=8A?= =?UTF-8?q?=E3=82=88=E3=81=B3`core::parser::ParseResult`=E3=82=92`core/src?= =?UTF-8?q?/entity.rs`=E3=81=A7=E5=86=8D=E5=85=AC=E9=96=8B=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ただし、将来的には削除したいのでDeprecated指定する。 --- core/src/entity.rs | 5 +++++ core/src/lib.rs | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 core/src/entity.rs diff --git a/core/src/entity.rs b/core/src/entity.rs new file mode 100644 index 00000000..ee650638 --- /dev/null +++ b/core/src/entity.rs @@ -0,0 +1,5 @@ +pub use crate::parser::ParseResult; +pub use domain::geolonia::entity::Address; +pub use domain::geolonia::entity::City; +pub use domain::geolonia::entity::Prefecture; +pub use domain::geolonia::entity::Town; diff --git a/core/src/lib.rs b/core/src/lib.rs index 5090f731..b7589be0 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -4,6 +4,8 @@ compile_error! { } pub mod api; +#[deprecated(since = "0.1.6", note = "This module will be deleted in v0.2")] +pub mod entity; pub mod parser; mod tokenizer; mod util; From b620f4a89d22a61b8a97b387169caabafec56b12 Mon Sep 17 00:00:00 2001 From: yuuki toriyama Date: Sun, 28 Jul 2024 01:35:29 +0900 Subject: [PATCH 25/32] =?UTF-8?q?fix:=20=E3=83=A2=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=88=86=E5=89=B2:=20`repository`=E3=82=AF?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=81=AB`tokio`=E3=81=AE=E4=BE=9D?= =?UTF-8?q?=E5=AD=98=E9=96=A2=E4=BF=82=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 非同期テストの実行に必要なため --- repository/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/repository/Cargo.toml b/repository/Cargo.toml index 75f24aaf..347e47e0 100644 --- a/repository/Cargo.toml +++ b/repository/Cargo.toml @@ -15,3 +15,6 @@ blocking = ["service/blocking"] [dependencies] domain = { path = "../domain" } service = { path = "../service" } + +[dev-dependencies] +tokio.workspace = true \ No newline at end of file From 0871472713bba9e1b4d0ece77f2572ad062db1da Mon Sep 17 00:00:00 2001 From: yuuki toriyama Date: Sun, 28 Jul 2024 10:20:41 +0900 Subject: [PATCH 26/32] update-version: 0.1.5 -> 0.1.6 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f74ebbde..e8ee7040 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.1.5" +version = "0.1.6" edition = "2021" description = "A Rust Library to parse japanese addresses." repository = "https://github.com/YuukiToriyama/japanese-address-parser" From f5d5cfc6142651af8cef566478a6097e89063885 Mon Sep 17 00:00:00 2001 From: yuuki toriyama Date: Sun, 11 Aug 2024 14:30:51 +0900 Subject: [PATCH 27/32] =?UTF-8?q?update:=20=E3=83=9E=E3=83=AB=E3=83=81?= =?UTF-8?q?=E3=82=AF=E3=83=AC=E3=83=BC=E3=83=88=E5=8C=96=E3=81=AE=E5=88=87?= =?UTF-8?q?=E3=82=8A=E6=88=BB=E3=81=97:=20`repository`=E3=82=AF=E3=83=AC?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=82=92`core/src/repository`=E3=81=AB?= =?UTF-8?q?=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 1 - core/Cargo.toml | 4 ++-- core/src/api.rs | 8 ++++---- core/src/lib.rs | 1 + core/src/parser.rs | 4 ++-- .../src/lib.rs => core/src/repository.rs | 0 .../src => core/src/repository}/geolonia.rs | 0 .../repository}/geolonia/city_master_api.rs | 3 +-- .../geolonia/prefecture_master_api.rs | 4 ++-- repository/Cargo.toml | 20 ------------------- 10 files changed, 12 insertions(+), 33 deletions(-) rename repository/src/lib.rs => core/src/repository.rs (100%) rename {repository/src => core/src/repository}/geolonia.rs (100%) rename {repository/src => core/src/repository}/geolonia/city_master_api.rs (98%) rename {repository/src => core/src/repository}/geolonia/prefecture_master_api.rs (96%) delete mode 100644 repository/Cargo.toml diff --git a/Cargo.toml b/Cargo.toml index 2c931411..8c29f2a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,6 @@ members = [ "tests", "domain", "service", - "repository", ] resolver = "2" diff --git a/core/Cargo.toml b/core/Cargo.toml index 984f6616..753f9f8e 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -16,11 +16,11 @@ crate-type = ["rlib", "cdylib"] [features] default = [] -blocking = ["repository/blocking"] +blocking = ["service/blocking"] [dependencies] domain = { path = "../domain" } -repository = { path = "../repository" } +service = { path = "../service" } itertools = "0.13.0" js-sys = "0.3.67" nom = "7.1.3" diff --git a/core/src/api.rs b/core/src/api.rs index a1476f7a..fce4ccb9 100644 --- a/core/src/api.rs +++ b/core/src/api.rs @@ -1,10 +1,10 @@ -pub use repository::geolonia::city_master_api; -pub use repository::geolonia::prefecture_master_api; +pub use crate::repository::geolonia::city_master_api; +pub use crate::repository::geolonia::prefecture_master_api; use domain::geolonia::entity::{City, Prefecture}; use domain::geolonia::error::Error; -use repository::geolonia::city_master_api::CityMasterApi; -use repository::geolonia::prefecture_master_api::PrefectureMasterApi; +use crate::repository::geolonia::city_master_api::CityMasterApi; +use crate::repository::geolonia::prefecture_master_api::PrefectureMasterApi; #[derive(Default)] pub struct AsyncApi { diff --git a/core/src/lib.rs b/core/src/lib.rs index b7589be0..d0a351d7 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -7,5 +7,6 @@ pub mod api; #[deprecated(since = "0.1.6", note = "This module will be deleted in v0.2")] pub mod entity; pub mod parser; +mod repository; mod tokenizer; mod util; diff --git a/core/src/parser.rs b/core/src/parser.rs index 11aa051c..459cb6fb 100644 --- a/core/src/parser.rs +++ b/core/src/parser.rs @@ -140,8 +140,8 @@ mod tests { use crate::api::AsyncApi; use crate::parser::parse; use domain::geolonia::error::ParseErrorKind; - use repository::geolonia::city_master_api::CityMasterApi; - use repository::geolonia::prefecture_master_api::PrefectureMasterApi; + use crate::repository::geolonia::city_master_api::CityMasterApi; + use crate::repository::geolonia::prefecture_master_api::PrefectureMasterApi; use wasm_bindgen_test::{wasm_bindgen_test, wasm_bindgen_test_configure}; #[tokio::test] diff --git a/repository/src/lib.rs b/core/src/repository.rs similarity index 100% rename from repository/src/lib.rs rename to core/src/repository.rs diff --git a/repository/src/geolonia.rs b/core/src/repository/geolonia.rs similarity index 100% rename from repository/src/geolonia.rs rename to core/src/repository/geolonia.rs diff --git a/repository/src/geolonia/city_master_api.rs b/core/src/repository/geolonia/city_master_api.rs similarity index 98% rename from repository/src/geolonia/city_master_api.rs rename to core/src/repository/geolonia/city_master_api.rs index f13fbb8b..91d326ca 100644 --- a/repository/src/geolonia/city_master_api.rs +++ b/core/src/repository/geolonia/city_master_api.rs @@ -75,8 +75,7 @@ mod tests { #[cfg(all(test, feature = "blocking"))] mod blocking_tests { use domain::geolonia::entity::Town; - - use crate::geolonia::city_master_api::CityMasterApi; + use crate::repository::geolonia::city_master_api::CityMasterApi; #[test] fn 同期_石川県羽咋郡志賀町_成功() { diff --git a/repository/src/geolonia/prefecture_master_api.rs b/core/src/repository/geolonia/prefecture_master_api.rs similarity index 96% rename from repository/src/geolonia/prefecture_master_api.rs rename to core/src/repository/geolonia/prefecture_master_api.rs index 6b0772a8..e49cb614 100644 --- a/repository/src/geolonia/prefecture_master_api.rs +++ b/core/src/repository/geolonia/prefecture_master_api.rs @@ -30,7 +30,7 @@ impl PrefectureMasterApi { #[cfg(all(test, not(feature = "blocking")))] mod tests { - use crate::geolonia::prefecture_master_api::PrefectureMasterApi; + use crate::repository::geolonia::prefecture_master_api::PrefectureMasterApi; #[tokio::test] async fn 非同期_富山県_成功() { @@ -77,7 +77,7 @@ mod tests { #[cfg(all(test, feature = "blocking"))] mod blocking_tests { - use crate::geolonia::prefecture_master_api::PrefectureMasterApi; + use crate::repository::geolonia::prefecture_master_api::PrefectureMasterApi; #[test] fn 同期_富山県_成功() { diff --git a/repository/Cargo.toml b/repository/Cargo.toml deleted file mode 100644 index 347e47e0..00000000 --- a/repository/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "repository" -version.workspace = true -edition.workspace = true -description.workspace = true -repository.workspace = true -authors.workspace = true -license.workspace = true -keywords.workspace = true -categories.workspace = true - -[features] -blocking = ["service/blocking"] - -[dependencies] -domain = { path = "../domain" } -service = { path = "../service" } - -[dev-dependencies] -tokio.workspace = true \ No newline at end of file From 10903f19cf74701a1193870768753e193af5896e Mon Sep 17 00:00:00 2001 From: yuuki toriyama Date: Sun, 11 Aug 2024 14:43:05 +0900 Subject: [PATCH 28/32] =?UTF-8?q?update:=20=E3=83=9E=E3=83=AB=E3=83=81?= =?UTF-8?q?=E3=82=AF=E3=83=AC=E3=83=BC=E3=83=88=E5=8C=96=E3=81=AE=E5=88=87?= =?UTF-8?q?=E3=82=8A=E6=88=BB=E3=81=97:=20`service`=E3=82=AF=E3=83=AC?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=82=92`core/src/service`=E3=81=AB=E7=A7=BB?= =?UTF-8?q?=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 1 - core/Cargo.toml | 5 +++-- core/src/lib.rs | 1 + .../repository/geolonia/city_master_api.rs | 4 ++-- .../geolonia/prefecture_master_api.rs | 2 +- service/src/lib.rs => core/src/service.rs | 0 {service/src => core/src/service}/geolonia.rs | 4 ++-- service/Cargo.toml | 22 ------------------- 8 files changed, 9 insertions(+), 30 deletions(-) rename service/src/lib.rs => core/src/service.rs (100%) rename {service/src => core/src/service}/geolonia.rs (98%) delete mode 100644 service/Cargo.toml diff --git a/Cargo.toml b/Cargo.toml index 8c29f2a6..148ece0a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ members = [ "python", "tests", "domain", - "service", ] resolver = "2" diff --git a/core/Cargo.toml b/core/Cargo.toml index 753f9f8e..bf46a6c5 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -16,18 +16,19 @@ crate-type = ["rlib", "cdylib"] [features] default = [] -blocking = ["service/blocking"] +blocking = ["reqwest/blocking"] [dependencies] domain = { path = "../domain" } -service = { path = "../service" } itertools = "0.13.0" js-sys = "0.3.67" nom = "7.1.3" rapidfuzz = "0.5.0" regex = "1.10.2" serde.workspace = true +reqwest = { version = "0.12.5", default-features = false, features = ["json", "rustls-tls"] } [dev-dependencies] +mockito = "1.4.0" tokio.workspace = true wasm-bindgen-test = { workspace = true } diff --git a/core/src/lib.rs b/core/src/lib.rs index d0a351d7..ef9bb013 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -8,5 +8,6 @@ pub mod api; pub mod entity; pub mod parser; mod repository; +mod service; mod tokenizer; mod util; diff --git a/core/src/repository/geolonia/city_master_api.rs b/core/src/repository/geolonia/city_master_api.rs index 91d326ca..bd842a9d 100644 --- a/core/src/repository/geolonia/city_master_api.rs +++ b/core/src/repository/geolonia/city_master_api.rs @@ -1,6 +1,6 @@ use domain::geolonia::entity::{City, Town}; use domain::geolonia::error::Error; -use service::geolonia::GeoloniaApiService; +use crate::service::geolonia::GeoloniaApiService; pub struct CityMasterApi { pub server_url: &'static str, @@ -40,7 +40,7 @@ impl CityMasterApi { mod tests { use domain::geolonia::entity::Town; - use crate::geolonia::city_master_api::CityMasterApi; + use crate::repository::geolonia::city_master_api::CityMasterApi; #[tokio::test] async fn 非同期_石川県羽咋郡志賀町_成功() { diff --git a/core/src/repository/geolonia/prefecture_master_api.rs b/core/src/repository/geolonia/prefecture_master_api.rs index e49cb614..ba8d891b 100644 --- a/core/src/repository/geolonia/prefecture_master_api.rs +++ b/core/src/repository/geolonia/prefecture_master_api.rs @@ -1,6 +1,6 @@ use domain::geolonia::entity::Prefecture; use domain::geolonia::error::Error; -use service::geolonia::GeoloniaApiService; +use crate::service::geolonia::GeoloniaApiService; pub struct PrefectureMasterApi { pub server_url: &'static str, diff --git a/service/src/lib.rs b/core/src/service.rs similarity index 100% rename from service/src/lib.rs rename to core/src/service.rs diff --git a/service/src/geolonia.rs b/core/src/service/geolonia.rs similarity index 98% rename from service/src/geolonia.rs rename to core/src/service/geolonia.rs index e5af4430..fd6ce938 100644 --- a/service/src/geolonia.rs +++ b/core/src/service/geolonia.rs @@ -29,7 +29,7 @@ mod async_tests { use domain::geolonia::entity::{Prefecture, Town}; use domain::geolonia::error::{ApiErrorKind, Error}; - use crate::geolonia::GeoloniaApiService; + use crate::service::geolonia::GeoloniaApiService; #[tokio::test] async fn 失敗_ネットワークエラー() { @@ -190,7 +190,7 @@ mod blocking_tests { use domain::geolonia::entity::{Prefecture, Town}; use domain::geolonia::error::{ApiErrorKind, Error}; - use crate::geolonia::GeoloniaApiService; + use crate::service::geolonia::GeoloniaApiService; #[test] fn 失敗_ネットワークエラー() { diff --git a/service/Cargo.toml b/service/Cargo.toml deleted file mode 100644 index 1f877b39..00000000 --- a/service/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "service" -version.workspace = true -edition.workspace = true -description.workspace = true -repository.workspace = true -authors.workspace = true -license.workspace = true -keywords.workspace = true -categories.workspace = true - -[features] -blocking = ["reqwest/blocking"] - -[dependencies] -domain = { path = "../domain" } -reqwest = { version = "0.12.5", default-features = false, features = ["json", "rustls-tls"] } -serde.workspace = true - -[dev-dependencies] -mockito = "1.4.0" -tokio.workspace = true From 66084b42ce5f0ab5451b5eb6a92fe777d5be0a25 Mon Sep 17 00:00:00 2001 From: yuuki toriyama Date: Sun, 11 Aug 2024 14:55:41 +0900 Subject: [PATCH 29/32] =?UTF-8?q?update:=20=E3=83=9E=E3=83=AB=E3=83=81?= =?UTF-8?q?=E3=82=AF=E3=83=AC=E3=83=BC=E3=83=88=E5=8C=96=E3=81=AE=E5=88=87?= =?UTF-8?q?=E3=82=8A=E6=88=BB=E3=81=97:=20`domain`=E3=82=AF=E3=83=AC?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=82=92`core/src/domain`=E3=81=AB=E7=A7=BB?= =?UTF-8?q?=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 1 - core/Cargo.toml | 1 - core/src/api.rs | 4 ++-- domain/src/lib.rs => core/src/domain.rs | 0 {domain/src => core/src/domain}/geolonia.rs | 0 {domain/src => core/src/domain}/geolonia/entity.rs | 0 {domain/src => core/src/domain}/geolonia/error.rs | 0 core/src/entity.rs | 8 ++++---- core/src/lib.rs | 1 + core/src/parser.rs | 8 ++++---- core/src/parser/adapter/vague_expression_adapter.rs | 2 +- core/src/repository/geolonia/city_master_api.rs | 8 ++++---- .../repository/geolonia/prefecture_master_api.rs | 4 ++-- core/src/service/geolonia.rs | 10 +++++----- core/src/util/sequence_matcher.rs | 2 +- domain/Cargo.toml | 13 ------------- 16 files changed, 24 insertions(+), 38 deletions(-) rename domain/src/lib.rs => core/src/domain.rs (100%) rename {domain/src => core/src/domain}/geolonia.rs (100%) rename {domain/src => core/src/domain}/geolonia/entity.rs (100%) rename {domain/src => core/src/domain}/geolonia/error.rs (100%) delete mode 100644 domain/Cargo.toml diff --git a/Cargo.toml b/Cargo.toml index 148ece0a..a3ee488f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,6 @@ members = [ "wasm", "python", "tests", - "domain", ] resolver = "2" diff --git a/core/Cargo.toml b/core/Cargo.toml index bf46a6c5..9b0886d8 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -19,7 +19,6 @@ default = [] blocking = ["reqwest/blocking"] [dependencies] -domain = { path = "../domain" } itertools = "0.13.0" js-sys = "0.3.67" nom = "7.1.3" diff --git a/core/src/api.rs b/core/src/api.rs index fce4ccb9..e364f4bd 100644 --- a/core/src/api.rs +++ b/core/src/api.rs @@ -1,8 +1,8 @@ pub use crate::repository::geolonia::city_master_api; pub use crate::repository::geolonia::prefecture_master_api; -use domain::geolonia::entity::{City, Prefecture}; -use domain::geolonia::error::Error; +use crate::domain::geolonia::entity::{City, Prefecture}; +use crate::domain::geolonia::error::Error; use crate::repository::geolonia::city_master_api::CityMasterApi; use crate::repository::geolonia::prefecture_master_api::PrefectureMasterApi; diff --git a/domain/src/lib.rs b/core/src/domain.rs similarity index 100% rename from domain/src/lib.rs rename to core/src/domain.rs diff --git a/domain/src/geolonia.rs b/core/src/domain/geolonia.rs similarity index 100% rename from domain/src/geolonia.rs rename to core/src/domain/geolonia.rs diff --git a/domain/src/geolonia/entity.rs b/core/src/domain/geolonia/entity.rs similarity index 100% rename from domain/src/geolonia/entity.rs rename to core/src/domain/geolonia/entity.rs diff --git a/domain/src/geolonia/error.rs b/core/src/domain/geolonia/error.rs similarity index 100% rename from domain/src/geolonia/error.rs rename to core/src/domain/geolonia/error.rs diff --git a/core/src/entity.rs b/core/src/entity.rs index ee650638..cdcbf8bb 100644 --- a/core/src/entity.rs +++ b/core/src/entity.rs @@ -1,5 +1,5 @@ +pub use crate::domain::geolonia::entity::Address; +pub use crate::domain::geolonia::entity::City; +pub use crate::domain::geolonia::entity::Prefecture; +pub use crate::domain::geolonia::entity::Town; pub use crate::parser::ParseResult; -pub use domain::geolonia::entity::Address; -pub use domain::geolonia::entity::City; -pub use domain::geolonia::entity::Prefecture; -pub use domain::geolonia::entity::Town; diff --git a/core/src/lib.rs b/core/src/lib.rs index ef9bb013..63fe3cbb 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -4,6 +4,7 @@ compile_error! { } pub mod api; +mod domain; #[deprecated(since = "0.1.6", note = "This module will be deleted in v0.2")] pub mod entity; pub mod parser; diff --git a/core/src/parser.rs b/core/src/parser.rs index 459cb6fb..c51eed3b 100644 --- a/core/src/parser.rs +++ b/core/src/parser.rs @@ -3,9 +3,9 @@ use std::sync::Arc; use crate::api::AsyncApi; #[cfg(feature = "blocking")] use crate::api::BlockingApi; +use crate::domain::geolonia::entity::Address; +use crate::domain::geolonia::error::{Error, ParseErrorKind}; use crate::tokenizer::Tokenizer; -use domain::geolonia::entity::Address; -use domain::geolonia::error::{Error, ParseErrorKind}; use serde::Serialize; pub(crate) mod adapter; @@ -138,8 +138,8 @@ pub async fn parse(api: Arc, input: &str) -> ParseResult { #[cfg(all(test, not(feature = "blocking")))] mod tests { use crate::api::AsyncApi; + use crate::domain::geolonia::error::ParseErrorKind; use crate::parser::parse; - use domain::geolonia::error::ParseErrorKind; use crate::repository::geolonia::city_master_api::CityMasterApi; use crate::repository::geolonia::prefecture_master_api::PrefectureMasterApi; use wasm_bindgen_test::{wasm_bindgen_test, wasm_bindgen_test_configure}; @@ -289,8 +289,8 @@ pub fn parse_blocking(api: Arc, input: &str) -> ParseResult { #[cfg(all(test, feature = "blocking"))] mod blocking_tests { use crate::api::BlockingApi; + use crate::domain::geolonia::error::ParseErrorKind; use crate::parser::parse_blocking; - use domain::geolonia::error::ParseErrorKind; #[test] fn parse_blocking_success_埼玉県秩父市熊木町8番15号() { diff --git a/core/src/parser/adapter/vague_expression_adapter.rs b/core/src/parser/adapter/vague_expression_adapter.rs index fe560419..dc400878 100644 --- a/core/src/parser/adapter/vague_expression_adapter.rs +++ b/core/src/parser/adapter/vague_expression_adapter.rs @@ -26,8 +26,8 @@ impl VagueExpressionAdapter { #[cfg(test)] mod tests { + use crate::domain::geolonia::entity::Prefecture; use crate::parser::adapter::vague_expression_adapter::VagueExpressionAdapter; - use domain::geolonia::entity::Prefecture; #[test] fn 郡名が省略されている場合_吉田郡永平寺町() { diff --git a/core/src/repository/geolonia/city_master_api.rs b/core/src/repository/geolonia/city_master_api.rs index bd842a9d..b00eff84 100644 --- a/core/src/repository/geolonia/city_master_api.rs +++ b/core/src/repository/geolonia/city_master_api.rs @@ -1,5 +1,5 @@ -use domain::geolonia::entity::{City, Town}; -use domain::geolonia::error::Error; +use crate::domain::geolonia::entity::{City, Town}; +use crate::domain::geolonia::error::Error; use crate::service::geolonia::GeoloniaApiService; pub struct CityMasterApi { @@ -38,7 +38,7 @@ impl CityMasterApi { #[cfg(all(test, not(feature = "blocking")))] mod tests { - use domain::geolonia::entity::Town; + use crate::domain::geolonia::entity::Town; use crate::repository::geolonia::city_master_api::CityMasterApi; @@ -74,7 +74,7 @@ mod tests { #[cfg(all(test, feature = "blocking"))] mod blocking_tests { - use domain::geolonia::entity::Town; + use crate::domain::geolonia::entity::Town; use crate::repository::geolonia::city_master_api::CityMasterApi; #[test] diff --git a/core/src/repository/geolonia/prefecture_master_api.rs b/core/src/repository/geolonia/prefecture_master_api.rs index ba8d891b..b98d0929 100644 --- a/core/src/repository/geolonia/prefecture_master_api.rs +++ b/core/src/repository/geolonia/prefecture_master_api.rs @@ -1,5 +1,5 @@ -use domain::geolonia::entity::Prefecture; -use domain::geolonia::error::Error; +use crate::domain::geolonia::entity::Prefecture; +use crate::domain::geolonia::error::Error; use crate::service::geolonia::GeoloniaApiService; pub struct PrefectureMasterApi { diff --git a/core/src/service/geolonia.rs b/core/src/service/geolonia.rs index fd6ce938..9929c519 100644 --- a/core/src/service/geolonia.rs +++ b/core/src/service/geolonia.rs @@ -1,7 +1,7 @@ use reqwest::StatusCode; use serde::de::DeserializeOwned; -use domain::geolonia::error::{ApiErrorKind, Error}; +use crate::domain::geolonia::error::{ApiErrorKind, Error}; pub struct GeoloniaApiService {} @@ -26,8 +26,8 @@ impl GeoloniaApiService { #[cfg(test)] mod async_tests { - use domain::geolonia::entity::{Prefecture, Town}; - use domain::geolonia::error::{ApiErrorKind, Error}; + use crate::domain::geolonia::entity::{Prefecture, Town}; + use crate::domain::geolonia::error::{ApiErrorKind, Error}; use crate::service::geolonia::GeoloniaApiService; @@ -187,8 +187,8 @@ impl GeoloniaApiService { #[cfg(all(test, feature = "blocking"))] mod blocking_tests { - use domain::geolonia::entity::{Prefecture, Town}; - use domain::geolonia::error::{ApiErrorKind, Error}; + use crate::domain::geolonia::entity::{Prefecture, Town}; + use crate::domain::geolonia::error::{ApiErrorKind, Error}; use crate::service::geolonia::GeoloniaApiService; diff --git a/core/src/util/sequence_matcher.rs b/core/src/util/sequence_matcher.rs index 6c263833..8eaeffb1 100644 --- a/core/src/util/sequence_matcher.rs +++ b/core/src/util/sequence_matcher.rs @@ -102,9 +102,9 @@ impl SequenceMatcher { #[cfg(test)] mod tests { + use crate::domain::geolonia::entity::Prefecture; use crate::util::sequence_matcher::Error::{MoreThanOneCandidateExist, NoCandidateExist}; use crate::util::sequence_matcher::SequenceMatcher; - use domain::geolonia::entity::Prefecture; #[test] fn get_length_of_longest_one() { diff --git a/domain/Cargo.toml b/domain/Cargo.toml deleted file mode 100644 index 0d51c1ca..00000000 --- a/domain/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "domain" -version.workspace = true -edition.workspace = true -description.workspace = true -repository.workspace = true -authors.workspace = true -license.workspace = true -keywords.workspace = true -categories.workspace = true - -[dependencies] -serde.workspace = true From 32c0167ad89053674fbae4ec90dea0d035d3148d Mon Sep 17 00:00:00 2001 From: yuuki toriyama Date: Sun, 11 Aug 2024 15:24:28 +0900 Subject: [PATCH 30/32] =?UTF-8?q?update:=20=E3=83=9E=E3=83=AB=E3=83=81?= =?UTF-8?q?=E3=82=AF=E3=83=AC=E3=83=BC=E3=83=88=E5=8C=96=E3=81=AE=E5=88=87?= =?UTF-8?q?=E3=82=8A=E6=88=BB=E3=81=97:=20CI=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `domain`, `service`, `repository`に対するステップを削除 --- .github/workflows/run-test.yaml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/run-test.yaml b/.github/workflows/run-test.yaml index 65a30e47..833272fb 100644 --- a/.github/workflows/run-test.yaml +++ b/.github/workflows/run-test.yaml @@ -19,19 +19,6 @@ jobs: shared-key: 'test-on-pr' key: 'main' save-if: ${{ github.ref == 'refs/heads/main' }} # mainブランチにコミットが追加された時のみキャッシュを保存する - - name: Test domain - working-directory: domain - run: cargo test - - name: Test service - working-directory: service - run: | - cargo test - cargo test --features=blocking - - name: Test repository - working-directory: repository - run: | - cargo test - cargo test --features=blocking - name: Test core working-directory: core run: | From 5496d92c2b35631e98f55de9dce95157fd9c77e7 Mon Sep 17 00:00:00 2001 From: yuuki toriyama Date: Sun, 11 Aug 2024 17:42:51 +0900 Subject: [PATCH 31/32] =?UTF-8?q?fix:=20=E3=83=9E=E3=83=AB=E3=83=81?= =?UTF-8?q?=E3=82=AF=E3=83=AC=E3=83=BC=E3=83=88=E5=8C=96=E3=81=AE=E5=88=87?= =?UTF-8?q?=E3=82=8A=E6=88=BB=E3=81=97:=20mockito=E3=82=92=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E3=81=99=E3=82=8B=E3=83=86=E3=82=B9=E3=83=88=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=81=AE=E5=AE=9F=E8=A1=8C=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `mockito`クレートがwasm32-unknown-unknownに対応しておらず、`wasm-pack test`が失敗するため --- core/Cargo.toml | 4 +++- core/src/service/geolonia.rs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 9b0886d8..00e2f54d 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -28,6 +28,8 @@ serde.workspace = true reqwest = { version = "0.12.5", default-features = false, features = ["json", "rustls-tls"] } [dev-dependencies] -mockito = "1.4.0" tokio.workspace = true wasm-bindgen-test = { workspace = true } + +[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] +mockito = "1.4.0" # mockitoがwasm32に対応していないため diff --git a/core/src/service/geolonia.rs b/core/src/service/geolonia.rs index 9929c519..a1b5111b 100644 --- a/core/src/service/geolonia.rs +++ b/core/src/service/geolonia.rs @@ -24,7 +24,7 @@ impl GeoloniaApiService { } } -#[cfg(test)] +#[cfg(all(test, not(target_arch = "wasm32")))] mod async_tests { use crate::domain::geolonia::entity::{Prefecture, Town}; use crate::domain::geolonia::error::{ApiErrorKind, Error}; @@ -185,7 +185,7 @@ impl GeoloniaApiService { } } -#[cfg(all(test, feature = "blocking"))] +#[cfg(all(test, feature = "blocking", not(target_arch = "wasm32")))] mod blocking_tests { use crate::domain::geolonia::entity::{Prefecture, Town}; use crate::domain::geolonia::error::{ApiErrorKind, Error}; From 9796bad642917b6c777028c6bbdb3c2ed2bfa3da Mon Sep 17 00:00:00 2001 From: yuuki toriyama Date: Sun, 11 Aug 2024 18:02:53 +0900 Subject: [PATCH 32/32] update-version: 0.1.6 -> 0.1.7 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2c931411..f33cca5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.1.6" +version = "0.1.7" edition = "2021" description = "A Rust Library to parse japanese addresses." repository = "https://github.com/YuukiToriyama/japanese-address-parser"