jp_address_complement 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.agent/rules/specify-rules.md +29 -0
- data/.agent/workflows/speckit.analyze.md +184 -0
- data/.agent/workflows/speckit.checklist.md +294 -0
- data/.agent/workflows/speckit.clarify.md +181 -0
- data/.agent/workflows/speckit.constitution.md +84 -0
- data/.agent/workflows/speckit.implement.md +135 -0
- data/.agent/workflows/speckit.plan.md +90 -0
- data/.agent/workflows/speckit.specify.md +258 -0
- data/.agent/workflows/speckit.tasks.md +137 -0
- data/.agent/workflows/speckit.taskstoissues.md +30 -0
- data/.claude/commands/speckit.analyze.md +184 -0
- data/.claude/commands/speckit.checklist.md +294 -0
- data/.claude/commands/speckit.clarify.md +181 -0
- data/.claude/commands/speckit.constitution.md +84 -0
- data/.claude/commands/speckit.implement.md +135 -0
- data/.claude/commands/speckit.plan.md +90 -0
- data/.claude/commands/speckit.specify.md +258 -0
- data/.claude/commands/speckit.tasks.md +137 -0
- data/.claude/commands/speckit.taskstoissues.md +30 -0
- data/.cursor/commands/speckit.analyze.md +184 -0
- data/.cursor/commands/speckit.checklist.md +294 -0
- data/.cursor/commands/speckit.clarify.md +181 -0
- data/.cursor/commands/speckit.constitution.md +84 -0
- data/.cursor/commands/speckit.implement.md +135 -0
- data/.cursor/commands/speckit.plan.md +90 -0
- data/.cursor/commands/speckit.specify.md +258 -0
- data/.cursor/commands/speckit.tasks.md +137 -0
- data/.cursor/commands/speckit.taskstoissues.md +30 -0
- data/.cursor/rules/specify-rules.mdc +32 -0
- data/.rubocop.yml +118 -0
- data/.specify/memory/constitution.md +130 -0
- data/.specify/scripts/bash/check-prerequisites.sh +166 -0
- data/.specify/scripts/bash/common.sh +156 -0
- data/.specify/scripts/bash/create-new-feature.sh +297 -0
- data/.specify/scripts/bash/setup-plan.sh +61 -0
- data/.specify/scripts/bash/update-agent-context.sh +810 -0
- data/.specify/templates/agent-file-template.md +28 -0
- data/.specify/templates/checklist-template.md +40 -0
- data/.specify/templates/constitution-template.md +50 -0
- data/.specify/templates/plan-template.md +104 -0
- data/.specify/templates/spec-template.md +115 -0
- data/.specify/templates/tasks-template.md +251 -0
- data/CHANGELOG.md +26 -0
- data/LICENSE +9 -0
- data/README.md +274 -0
- data/Rakefile +19 -0
- data/Steepfile +9 -0
- data/examples/rails/jp_address_complement_demo/.gitignore +15 -0
- data/examples/rails/jp_address_complement_demo/.ruby-version +1 -0
- data/examples/rails/jp_address_complement_demo/Gemfile +22 -0
- data/examples/rails/jp_address_complement_demo/Gemfile.lock +252 -0
- data/examples/rails/jp_address_complement_demo/README.md +57 -0
- data/examples/rails/jp_address_complement_demo/Rakefile +6 -0
- data/examples/rails/jp_address_complement_demo/app/assets/images/.keep +0 -0
- data/examples/rails/jp_address_complement_demo/app/assets/stylesheets/application.css +1 -0
- data/examples/rails/jp_address_complement_demo/app/controllers/addresses_controller.rb +59 -0
- data/examples/rails/jp_address_complement_demo/app/controllers/application_controller.rb +4 -0
- data/examples/rails/jp_address_complement_demo/app/controllers/concerns/.keep +0 -0
- data/examples/rails/jp_address_complement_demo/app/helpers/application_helper.rb +2 -0
- data/examples/rails/jp_address_complement_demo/app/models/application_record.rb +3 -0
- data/examples/rails/jp_address_complement_demo/app/models/concerns/.keep +0 -0
- data/examples/rails/jp_address_complement_demo/app/views/addresses/index.html.erb +22 -0
- data/examples/rails/jp_address_complement_demo/app/views/addresses/prefecture.html.erb +20 -0
- data/examples/rails/jp_address_complement_demo/app/views/addresses/prefix.html.erb +25 -0
- data/examples/rails/jp_address_complement_demo/app/views/addresses/reverse.html.erb +30 -0
- data/examples/rails/jp_address_complement_demo/app/views/addresses/validate.html.erb +23 -0
- data/examples/rails/jp_address_complement_demo/app/views/layouts/application.html.erb +40 -0
- data/examples/rails/jp_address_complement_demo/app/views/pwa/manifest.json.erb +22 -0
- data/examples/rails/jp_address_complement_demo/app/views/pwa/service-worker.js +26 -0
- data/examples/rails/jp_address_complement_demo/bin/ci +6 -0
- data/examples/rails/jp_address_complement_demo/bin/dev +2 -0
- data/examples/rails/jp_address_complement_demo/bin/rails +4 -0
- data/examples/rails/jp_address_complement_demo/bin/rake +4 -0
- data/examples/rails/jp_address_complement_demo/bin/setup +35 -0
- data/examples/rails/jp_address_complement_demo/config/application.rb +42 -0
- data/examples/rails/jp_address_complement_demo/config/boot.rb +3 -0
- data/examples/rails/jp_address_complement_demo/config/ci.rb +15 -0
- data/examples/rails/jp_address_complement_demo/config/credentials.yml.enc +1 -0
- data/examples/rails/jp_address_complement_demo/config/database.yml +31 -0
- data/examples/rails/jp_address_complement_demo/config/environment.rb +5 -0
- data/examples/rails/jp_address_complement_demo/config/environments/development.rb +54 -0
- data/examples/rails/jp_address_complement_demo/config/environments/production.rb +67 -0
- data/examples/rails/jp_address_complement_demo/config/environments/test.rb +42 -0
- data/examples/rails/jp_address_complement_demo/config/initializers/content_security_policy.rb +29 -0
- data/examples/rails/jp_address_complement_demo/config/initializers/filter_parameter_logging.rb +8 -0
- data/examples/rails/jp_address_complement_demo/config/initializers/inflections.rb +16 -0
- data/examples/rails/jp_address_complement_demo/config/locales/en.yml +31 -0
- data/examples/rails/jp_address_complement_demo/config/puma.rb +39 -0
- data/examples/rails/jp_address_complement_demo/config/routes.rb +19 -0
- data/examples/rails/jp_address_complement_demo/config.ru +6 -0
- data/examples/rails/jp_address_complement_demo/db/migrate/20260228083709_create_jp_address_complement_postal_codes.rb +44 -0
- data/examples/rails/jp_address_complement_demo/db/schema.rb +33 -0
- data/examples/rails/jp_address_complement_demo/db/seeds.rb +24 -0
- data/examples/rails/jp_address_complement_demo/lib/tasks/.keep +0 -0
- data/examples/rails/jp_address_complement_demo/log/.keep +0 -0
- data/examples/rails/jp_address_complement_demo/public/400.html +135 -0
- data/examples/rails/jp_address_complement_demo/public/404.html +135 -0
- data/examples/rails/jp_address_complement_demo/public/406-unsupported-browser.html +135 -0
- data/examples/rails/jp_address_complement_demo/public/422.html +135 -0
- data/examples/rails/jp_address_complement_demo/public/500.html +135 -0
- data/examples/rails/jp_address_complement_demo/public/icon.png +0 -0
- data/examples/rails/jp_address_complement_demo/public/icon.svg +3 -0
- data/examples/rails/jp_address_complement_demo/public/robots.txt +1 -0
- data/examples/rails/jp_address_complement_demo/script/.keep +0 -0
- data/examples/rails/jp_address_complement_demo/storage/.keep +0 -0
- data/examples/rails/jp_address_complement_demo/vendor/.keep +0 -0
- data/lib/generators/jp_address_complement/install_generator.rb +34 -0
- data/lib/generators/jp_address_complement/templates/create_jp_address_complement_postal_codes.rb.erb +45 -0
- data/lib/jp_address_complement/address_record.rb +36 -0
- data/lib/jp_address_complement/configuration.rb +21 -0
- data/lib/jp_address_complement/importers/csv_importer.rb +148 -0
- data/lib/jp_address_complement/ken_all_downloader.rb +122 -0
- data/lib/jp_address_complement/models/postal_code.rb +21 -0
- data/lib/jp_address_complement/normalizer.rb +77 -0
- data/lib/jp_address_complement/prefecture.rb +105 -0
- data/lib/jp_address_complement/railtie.rb +27 -0
- data/lib/jp_address_complement/repositories/active_record_postal_code_repository.rb +78 -0
- data/lib/jp_address_complement/repositories/csv_postal_code_repository.rb +200 -0
- data/lib/jp_address_complement/repositories/postal_code_repository.rb +36 -0
- data/lib/jp_address_complement/searcher.rb +85 -0
- data/lib/jp_address_complement/validators/address_validator.rb +41 -0
- data/lib/jp_address_complement/version.rb +6 -0
- data/lib/jp_address_complement.rb +129 -0
- data/lib/tasks/jp_address_complement.rake +32 -0
- data/rbs_collection.lock.yaml +380 -0
- data/rbs_collection.yaml +19 -0
- data/sig/generated/generators/jp_address_complement/install_generator.rbs +18 -0
- data/sig/generated/jp_address_complement/configuration.rbs +18 -0
- data/sig/generated/jp_address_complement/importers/csv_importer.rbs +78 -0
- data/sig/generated/jp_address_complement/ken_all_downloader.rbs +49 -0
- data/sig/generated/jp_address_complement/normalizer.rbs +37 -0
- data/sig/generated/jp_address_complement/prefecture.rbs +27 -0
- data/sig/generated/jp_address_complement/railtie.rbs +8 -0
- data/sig/generated/jp_address_complement/repositories/active_record_postal_code_repository.rbs +38 -0
- data/sig/generated/jp_address_complement/repositories/csv_postal_code_repository.rbs +100 -0
- data/sig/generated/jp_address_complement/repositories/postal_code_repository.rbs +29 -0
- data/sig/generated/jp_address_complement/searcher.rbs +43 -0
- data/sig/generated/jp_address_complement/validators/address_validator.rbs +24 -0
- data/sig/generated/jp_address_complement/version.rbs +5 -0
- data/sig/generated/jp_address_complement.rbs +84 -0
- data/sig/manual/address_record.rbs +40 -0
- data/sig/manual/gem_rubyzip.rbs +17 -0
- data/sig/manual/postal_code.rbs +9 -0
- data/sig/manual/stdlib_csv_invalid_encoding_error.rbs +5 -0
- data/sig/manual/stdlib_net_http.rbs +33 -0
- data/sig/manual/stdlib_openuri.rbs +9 -0
- data/sig/manual/stdlib_tmpdir.rbs +4 -0
- data/specs/001-jp-address-complement-gem/checklists/requirements.md +36 -0
- data/specs/001-jp-address-complement-gem/contracts/public-api.md +209 -0
- data/specs/001-jp-address-complement-gem/data-model.md +207 -0
- data/specs/001-jp-address-complement-gem/plan.md +124 -0
- data/specs/001-jp-address-complement-gem/quickstart.md +151 -0
- data/specs/001-jp-address-complement-gem/research.md +139 -0
- data/specs/001-jp-address-complement-gem/spec.md +153 -0
- data/specs/001-jp-address-complement-gem/tasks.md +279 -0
- data/specs/002-rbs-type-annotations/checklists/requirements.md +37 -0
- data/specs/002-rbs-type-annotations/contracts/rbs-public-api.md +116 -0
- data/specs/002-rbs-type-annotations/data-model.md +119 -0
- data/specs/002-rbs-type-annotations/plan.md +116 -0
- data/specs/002-rbs-type-annotations/quickstart.md +105 -0
- data/specs/002-rbs-type-annotations/research.md +173 -0
- data/specs/002-rbs-type-annotations/spec.md +125 -0
- data/specs/002-rbs-type-annotations/tasks.md +189 -0
- data/specs/003-csv-remove-obsolete/checklists/requirements.md +34 -0
- data/specs/003-csv-remove-obsolete/contracts/csv-import.md +41 -0
- data/specs/003-csv-remove-obsolete/data-model.md +47 -0
- data/specs/003-csv-remove-obsolete/plan.md +73 -0
- data/specs/003-csv-remove-obsolete/quickstart.md +40 -0
- data/specs/003-csv-remove-obsolete/research.md +71 -0
- data/specs/003-csv-remove-obsolete/spec.md +85 -0
- data/specs/003-csv-remove-obsolete/tasks.md +167 -0
- data/specs/004-prefecture-code-reverse-lookup/checklists/requirements.md +34 -0
- data/specs/004-prefecture-code-reverse-lookup/contracts/public-api-prefecture-and-reverse.md +122 -0
- data/specs/004-prefecture-code-reverse-lookup/data-model.md +81 -0
- data/specs/004-prefecture-code-reverse-lookup/plan.md +92 -0
- data/specs/004-prefecture-code-reverse-lookup/quickstart.md +91 -0
- data/specs/004-prefecture-code-reverse-lookup/research.md +62 -0
- data/specs/004-prefecture-code-reverse-lookup/spec.md +120 -0
- data/specs/004-prefecture-code-reverse-lookup/tasks.md +190 -0
- metadata +451 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
|
|
3
|
+
<html lang="en">
|
|
4
|
+
|
|
5
|
+
<head>
|
|
6
|
+
|
|
7
|
+
<title>The change you wanted was rejected (422 Unprocessable Entity)</title>
|
|
8
|
+
|
|
9
|
+
<meta charset="utf-8">
|
|
10
|
+
<meta name="viewport" content="initial-scale=1, width=device-width">
|
|
11
|
+
<meta name="robots" content="noindex, nofollow">
|
|
12
|
+
|
|
13
|
+
<style>
|
|
14
|
+
|
|
15
|
+
*, *::before, *::after {
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
* {
|
|
20
|
+
margin: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
html {
|
|
24
|
+
font-size: 16px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
body {
|
|
28
|
+
background: #FFF;
|
|
29
|
+
color: #261B23;
|
|
30
|
+
display: grid;
|
|
31
|
+
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Aptos, Roboto, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
32
|
+
font-size: clamp(1rem, 2.5vw, 2rem);
|
|
33
|
+
-webkit-font-smoothing: antialiased;
|
|
34
|
+
font-style: normal;
|
|
35
|
+
font-weight: 400;
|
|
36
|
+
letter-spacing: -0.0025em;
|
|
37
|
+
line-height: 1.4;
|
|
38
|
+
min-height: 100dvh;
|
|
39
|
+
place-items: center;
|
|
40
|
+
text-rendering: optimizeLegibility;
|
|
41
|
+
-webkit-text-size-adjust: 100%;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#error-description {
|
|
45
|
+
fill: #d30001;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#error-id {
|
|
49
|
+
fill: #f0eff0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@media (prefers-color-scheme: dark) {
|
|
53
|
+
body {
|
|
54
|
+
background: #101010;
|
|
55
|
+
color: #e0e0e0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#error-description {
|
|
59
|
+
fill: #FF6161;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#error-id {
|
|
63
|
+
fill: #2c2c2c;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
a {
|
|
68
|
+
color: inherit;
|
|
69
|
+
font-weight: 700;
|
|
70
|
+
text-decoration: underline;
|
|
71
|
+
text-underline-offset: 0.0925em;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
b, strong {
|
|
75
|
+
font-weight: 700;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
i, em {
|
|
79
|
+
font-style: italic;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
main {
|
|
83
|
+
display: grid;
|
|
84
|
+
gap: 1em;
|
|
85
|
+
padding: 2em;
|
|
86
|
+
place-items: center;
|
|
87
|
+
text-align: center;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
main header {
|
|
91
|
+
width: min(100%, 12em);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
main header svg {
|
|
95
|
+
height: auto;
|
|
96
|
+
max-width: 100%;
|
|
97
|
+
width: 100%;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
main article {
|
|
101
|
+
width: min(100%, 30em);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
main article p {
|
|
105
|
+
font-size: 75%;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
main article br {
|
|
109
|
+
display: none;
|
|
110
|
+
|
|
111
|
+
@media(min-width: 48em) {
|
|
112
|
+
display: inline;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
</style>
|
|
117
|
+
|
|
118
|
+
</head>
|
|
119
|
+
|
|
120
|
+
<body>
|
|
121
|
+
|
|
122
|
+
<!-- This file lives in public/422.html -->
|
|
123
|
+
|
|
124
|
+
<main>
|
|
125
|
+
<header>
|
|
126
|
+
<svg height="172" viewBox="0 0 480 172" width="480" xmlns="http://www.w3.org/2000/svg"><path d="m124.48 3.00509-45.6889 100.02991h26.2239v-28.1168h38.119v28.1168h21.628v35.145h-21.628v30.82h-37.308v-30.82h-72.1833v-31.901l50.2851-103.27391zm130.453 51.63681c0-8.9215-6.218-15.4099-15.681-15.4099-10.273 0-15.95 7.5698-16.491 16.4913h-44.608c3.244-30.8199 25.683-55.421707 61.099-55.421707 36.498 0 59.477 20.816907 59.477 51.636807 0 21.3577-14.869 36.7676-31.901 52.7186l-27.305 27.035h59.747v37.308h-120.306v-27.846l57.044-56.7736c11.084-11.8954 18.925-20.0059 18.925-29.7385zm140.455 0c0-8.9215-6.218-15.4099-15.68-15.4099-10.274 0-15.951 7.5698-16.492 16.4913h-44.608c3.245-30.8199 25.684-55.421707 61.1-55.421707 36.497 0 59.477 20.816907 59.477 51.636807 0 21.3577-14.87 36.7676-31.902 52.7186l-27.305 27.035h59.747v37.308h-120.305v-27.846l57.043-56.7736c11.085-11.8954 18.925-20.0059 18.925-29.7385z" id="error-id"/><path d="m19.3936 103.554c-8.9715 0-14.84183-5.0952-14.84183-14.4544v-20.1029h8.86083v19.3276c0 4.8181 2.2706 7.3102 5.981 7.3102 3.6551 0 5.9257-2.4921 5.9257-7.3102v-19.3276h8.8608v20.1583c0 9.3038-5.8149 14.399-14.7865 14.399zm18.734-.554v-24.921h8.6947v2.1598c1.3845-1.5506 3.8212-2.7136 6.701-2.7136 5.538 0 8.8054 3.5997 8.8054 9.1377v16.3371h-8.6393v-14.2327c0-2.049-1.0522-3.5443-3.2674-3.5443-1.7168 0-3.1567.9969-3.5997 2.7136v15.0634zm36.8584-1.994v10.799h-8.6946v-33.726h8.6946v1.9937c1.163-1.3291 3.5997-2.5475 6.1472-2.5475 7.1994 0 11.1314 5.8703 11.1314 13.0143 0 7.0886-3.932 13.0145-11.1314 13.0145-2.5475 0-4.9842-1.219-6.1472-2.548zm0-13.7893v6.5902c.6646 1.3845 2.1599 2.326 3.8213 2.326 2.9905 0 4.7626-2.3814 4.7626-5.5934s-1.7721-5.6488-4.7626-5.6488c-1.7168 0-3.1567.9969-3.8213 2.326zm36.789-9.2485v8.3624c-1.052-.5538-2.215-.7753-3.6-.7753-2.381 0-3.987 1.0522-4.43 2.8244v14.6203h-8.6949v-24.921h8.6949v2.2152c1.218-1.6614 3.156-2.769 5.648-2.769 1.108 0 1.994.2215 2.382.443zm26.769 12.5713c0 7.6978-5.15 13.0145-12.737 13.0145-7.532 0-12.738-5.3167-12.738-13.0145s5.206-13.0143 12.738-13.0143c7.587 0 12.737 5.3165 12.737 13.0143zm-8.528 0c0-3.4336-1.496-5.8703-4.209-5.8703-2.659 0-4.154 2.4367-4.154 5.8703s1.495 5.8149 4.154 5.8149c2.713 0 4.209-2.3813 4.209-5.8149zm10.352 0c0-7.6978 5.095-13.0143 12.571-13.0143 6.701 0 10.855 3.9874 11.574 9.8023h-8.417c-.222-1.4953-1.385-2.6029-3.157-2.6029-2.437 0-3.987 2.2706-3.987 5.8149s1.55 5.7595 3.987 5.7595c1.772 0 2.935-1.0522 3.157-2.5475h8.417c-.719 5.7596-4.873 9.8025-11.574 9.8025-7.476 0-12.571-5.3167-12.571-13.0145zm42.013 3.7658h8.03c-.886 5.7597-5.206 9.2487-11.685 9.2487-7.643 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.316-13.0143 12.516-13.0143 7.642 0 11.962 5.095 11.962 12.5159v2.1598h-16.116c.277 2.9905 1.828 4.5965 4.32 4.5965 1.772 0 3.156-.7753 3.655-2.4921zm-3.821-10.0237c-2.049 0-3.434 1.2737-3.988 3.5997h7.532c-.111-2.0491-1.385-3.5997-3.544-3.5997zm13.428 11.0206h8.473c.387 1.3845 1.606 2.1598 3.156 2.1598 1.44 0 2.548-.5538 2.548-1.7168 0-.9414-.72-1.2737-1.938-1.5506l-4.874-.9969c-4.153-.886-6.867-2.8797-6.867-7.2547 0-5.3165 4.763-8.4178 10.633-8.4178 6.812 0 10.522 3.1567 11.297 8.0855h-8.03c-.277-1.0522-1.052-1.9937-3.046-1.9937-1.273 0-2.326.5538-2.326 1.6614 0 .7753.554 1.163 1.717 1.3845l4.929 1.163c4.541 1.0522 6.978 3.4335 6.978 7.4763 0 5.3168-4.818 8.2518-10.91 8.2518-6.369 0-10.965-2.88-11.74-8.2518zm24.269 0h8.474c.387 1.3845 1.606 2.1598 3.156 2.1598 1.44 0 2.548-.5538 2.548-1.7168 0-.9414-.72-1.2737-1.939-1.5506l-4.873-.9969c-4.154-.886-6.867-2.8797-6.867-7.2547 0-5.3165 4.763-8.4178 10.633-8.4178 6.812 0 10.522 3.1567 11.297 8.0855h-8.03c-.277-1.0522-1.052-1.9937-3.046-1.9937-1.273 0-2.326.5538-2.326 1.6614 0 .7753.554 1.163 1.717 1.3845l4.929 1.163c4.541 1.0522 6.978 3.4335 6.978 7.4763 0 5.3168-4.818 8.2518-10.91 8.2518-6.369 0-10.965-2.88-11.741-8.2518zm47.918 7.6978h-8.363v-1.274c-.831.831-3.323 1.717-5.981 1.717-4.929 0-9.082-2.769-9.082-8.0301 0-4.818 4.153-7.9193 9.581-7.9193 2.049 0 4.485.6646 5.482 1.3845v-1.606c0-1.606-.941-2.9905-3.046-2.9905-1.606 0-2.547.7199-2.935 1.8275h-8.196c.72-4.8181 4.984-8.6393 11.408-8.6393 7.089 0 11.132 3.7659 11.132 10.2453zm-8.363-6.9779v-1.4399c-.554-1.0522-2.049-1.7167-3.655-1.7167-1.717 0-3.434.7199-3.434 2.3813 0 1.7168 1.717 2.4367 3.434 2.4367 1.606 0 3.101-.6645 3.655-1.6614zm20.742 4.9839v1.994h-8.695v-35.997h8.695v13.0697c1.163-1.3291 3.6-2.5475 6.147-2.5475 7.2 0 11.132 5.8149 11.132 13.0143s-3.932 13.0145-11.132 13.0145c-2.547 0-4.984-1.219-6.147-2.548zm0-13.7893v6.5902c.665 1.3845 2.105 2.326 3.821 2.326 2.991 0 4.763-2.3814 4.763-5.5934s-1.772-5.6488-4.763-5.6488c-1.661 0-3.156.9969-3.821 2.326zm28.759-20.2137v35.997h-8.695v-35.997zm19.172 27.3023h8.03c-.886 5.7597-5.206 9.2487-11.685 9.2487-7.643 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.316-13.0143 12.515-13.0143 7.643 0 11.962 5.095 11.962 12.5159v2.1598h-16.115c.277 2.9905 1.827 4.5965 4.32 4.5965 1.772 0 3.156-.7753 3.655-2.4921zm-3.822-10.0237c-2.049 0-3.433 1.2737-3.987 3.5997h7.532c-.111-2.0491-1.385-3.5997-3.545-3.5997zm25.461-15.2849h24.311v7.6424h-15.561v5.3165h14.232v7.4763h-14.232v5.8703h15.561v7.6978h-24.311zm27.942 34.0033v-24.921h8.694v2.1598c1.385-1.5506 3.822-2.7136 6.701-2.7136 5.538 0 8.806 3.5997 8.806 9.1377v16.3371h-8.639v-14.2327c0-2.049-1.053-3.5443-3.268-3.5443-1.717 0-3.157.9969-3.6 2.7136v15.0634zm29.991-8.5839v-9.5807h-3.655v-6.7564h3.655v-6.8671h8.584v6.8671h5.206v6.7564h-5.206v8.307c0 1.9383.941 2.769 2.658 2.769.942 0 1.994-.2216 2.769-.5538v7.3654c-.997.443-2.88.775-4.818.775-5.87 0-9.193-2.769-9.193-9.0819zm26.161-16.3371v24.921h-8.694v-24.921zm.61-6.7564c0 2.8244-2.271 4.652-4.929 4.652s-4.929-1.8276-4.929-4.652c0-2.8797 2.271-4.7073 4.929-4.7073s4.929 1.8276 4.929 4.7073zm5.382 23.0935v-9.5807h-3.655v-6.7564h3.655v-6.8671h8.584v6.8671h5.206v6.7564h-5.206v8.307c0 1.9383.941 2.769 2.658 2.769.941 0 1.994-.2216 2.769-.5538v7.3654c-.997.443-2.88.775-4.818.775-5.87 0-9.193-2.769-9.193-9.0819zm29.22 17.3889h-8.584l3.655-9.414-9.303-24.312h9.026l4.763 14.1773 4.652-14.1773h8.639z" id="error-description"/></svg>
|
|
127
|
+
</header>
|
|
128
|
+
<article>
|
|
129
|
+
<p><strong>The change you wanted was rejected.</strong> Maybe you tried to change something you didn't have access to. If you're the application owner check the logs for more information.</p>
|
|
130
|
+
</article>
|
|
131
|
+
</main>
|
|
132
|
+
|
|
133
|
+
</body>
|
|
134
|
+
|
|
135
|
+
</html>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
|
|
3
|
+
<html lang="en">
|
|
4
|
+
|
|
5
|
+
<head>
|
|
6
|
+
|
|
7
|
+
<title>We're sorry, but something went wrong (500 Internal Server Error)</title>
|
|
8
|
+
|
|
9
|
+
<meta charset="utf-8">
|
|
10
|
+
<meta name="viewport" content="initial-scale=1, width=device-width">
|
|
11
|
+
<meta name="robots" content="noindex, nofollow">
|
|
12
|
+
|
|
13
|
+
<style>
|
|
14
|
+
|
|
15
|
+
*, *::before, *::after {
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
* {
|
|
20
|
+
margin: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
html {
|
|
24
|
+
font-size: 16px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
body {
|
|
28
|
+
background: #FFF;
|
|
29
|
+
color: #261B23;
|
|
30
|
+
display: grid;
|
|
31
|
+
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Aptos, Roboto, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
32
|
+
font-size: clamp(1rem, 2.5vw, 2rem);
|
|
33
|
+
-webkit-font-smoothing: antialiased;
|
|
34
|
+
font-style: normal;
|
|
35
|
+
font-weight: 400;
|
|
36
|
+
letter-spacing: -0.0025em;
|
|
37
|
+
line-height: 1.4;
|
|
38
|
+
min-height: 100dvh;
|
|
39
|
+
place-items: center;
|
|
40
|
+
text-rendering: optimizeLegibility;
|
|
41
|
+
-webkit-text-size-adjust: 100%;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#error-description {
|
|
45
|
+
fill: #d30001;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#error-id {
|
|
49
|
+
fill: #f0eff0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@media (prefers-color-scheme: dark) {
|
|
53
|
+
body {
|
|
54
|
+
background: #101010;
|
|
55
|
+
color: #e0e0e0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#error-description {
|
|
59
|
+
fill: #FF6161;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#error-id {
|
|
63
|
+
fill: #2c2c2c;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
a {
|
|
68
|
+
color: inherit;
|
|
69
|
+
font-weight: 700;
|
|
70
|
+
text-decoration: underline;
|
|
71
|
+
text-underline-offset: 0.0925em;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
b, strong {
|
|
75
|
+
font-weight: 700;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
i, em {
|
|
79
|
+
font-style: italic;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
main {
|
|
83
|
+
display: grid;
|
|
84
|
+
gap: 1em;
|
|
85
|
+
padding: 2em;
|
|
86
|
+
place-items: center;
|
|
87
|
+
text-align: center;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
main header {
|
|
91
|
+
width: min(100%, 12em);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
main header svg {
|
|
95
|
+
height: auto;
|
|
96
|
+
max-width: 100%;
|
|
97
|
+
width: 100%;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
main article {
|
|
101
|
+
width: min(100%, 30em);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
main article p {
|
|
105
|
+
font-size: 75%;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
main article br {
|
|
109
|
+
display: none;
|
|
110
|
+
|
|
111
|
+
@media(min-width: 48em) {
|
|
112
|
+
display: inline;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
</style>
|
|
117
|
+
|
|
118
|
+
</head>
|
|
119
|
+
|
|
120
|
+
<body>
|
|
121
|
+
|
|
122
|
+
<!-- This file lives in public/500.html -->
|
|
123
|
+
|
|
124
|
+
<main>
|
|
125
|
+
<header>
|
|
126
|
+
<svg height="172" viewBox="0 0 480 172" width="480" xmlns="http://www.w3.org/2000/svg"><path d="m101.23 93.8427c-8.1103 0-15.4098 3.7849-19.7354 8.3813h-36.2269v-99.21891h103.8143v37.03791h-68.3984v24.8722c5.1366-2.7035 15.1396-5.9477 24.6014-5.9477 35.146 0 56.233 22.7094 56.233 55.4215 0 34.605-23.791 57.315-60.558 57.315-37.8492 0-61.64-22.169-63.8028-55.963h42.9857c1.0814 10.814 9.1919 19.195 21.6281 19.195 11.355 0 19.465-8.381 19.465-20.547 0-11.625-7.299-20.5463-20.006-20.5463zm138.833 77.8613c-40.822 0-64.884-35.146-64.884-85.7015 0-50.5554 24.062-85.700907 64.884-85.700907 40.823 0 64.884 35.145507 64.884 85.700907 0 50.5555-24.061 85.7015-64.884 85.7015zm0-133.2831c-17.572 0-22.709 21.8984-22.709 47.5816 0 25.6835 5.137 47.5815 22.709 47.5815 17.303 0 22.71-21.898 22.71-47.5815 0-25.6832-5.407-47.5816-22.71-47.5816zm140.456 133.2831c-40.823 0-64.884-35.146-64.884-85.7015 0-50.5554 24.061-85.700907 64.884-85.700907 40.822 0 64.884 35.145507 64.884 85.700907 0 50.5555-24.062 85.7015-64.884 85.7015zm0-133.2831c-17.573 0-22.71 21.8984-22.71 47.5816 0 25.6835 5.137 47.5815 22.71 47.5815 17.302 0 22.709-21.898 22.709-47.5815 0-25.6832-5.407-47.5816-22.709-47.5816z" id="error-id"/><path d="m23.1377 68.9967v34.0033h-8.9162v-34.0033zm4.3157 34.0033v-24.921h8.6947v2.1598c1.3845-1.5506 3.8212-2.7136 6.701-2.7136 5.538 0 8.8054 3.5997 8.8054 9.1377v16.3371h-8.6393v-14.2327c0-2.049-1.0522-3.5443-3.2674-3.5443-1.7168 0-3.1567.9969-3.5997 2.7136v15.0634zm29.9913-8.5839v-9.5807h-3.655v-6.7564h3.655v-6.8671h8.5839v6.8671h5.2058v6.7564h-5.2058v8.307c0 1.9383.9415 2.769 2.6583 2.769.9414 0 1.9937-.2216 2.769-.5538v7.3654c-.9969.443-2.8798.775-4.8181.775-5.8703 0-9.1931-2.769-9.1931-9.0819zm32.3666-.1108h8.0301c-.8861 5.7597-5.2057 9.2487-11.6852 9.2487-7.6424 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.3165-13.0143 12.5159-13.0143 7.6424 0 11.9621 5.095 11.9621 12.5159v2.1598h-16.1156c.2769 2.9905 1.8275 4.5965 4.3196 4.5965 1.7722 0 3.1567-.7753 3.6551-2.4921zm-3.8212-10.0237c-2.0491 0-3.4336 1.2737-3.9874 3.5997h7.5317c-.1107-2.0491-1.3845-3.5997-3.5443-3.5997zm31.4299-6.3134v8.3624c-1.052-.5538-2.215-.7753-3.599-.7753-2.382 0-3.988 1.0522-4.431 2.8244v14.6203h-8.694v-24.921h8.694v2.2152c1.219-1.6614 3.157-2.769 5.649-2.769 1.108 0 1.994.2215 2.381.443zm2.949 25.0318v-24.921h8.694v2.1598c1.385-1.5506 3.821-2.7136 6.701-2.7136 5.538 0 8.806 3.5997 8.806 9.1377v16.3371h-8.64v-14.2327c0-2.049-1.052-3.5443-3.267-3.5443-1.717 0-3.157.9969-3.6 2.7136v15.0634zm50.371 0h-8.363v-1.274c-.83.831-3.323 1.717-5.981 1.717-4.929 0-9.082-2.769-9.082-8.0301 0-4.818 4.153-7.9193 9.581-7.9193 2.049 0 4.485.6646 5.482 1.3845v-1.606c0-1.606-.941-2.9905-3.046-2.9905-1.606 0-2.547.7199-2.935 1.8275h-8.196c.72-4.8181 4.984-8.6393 11.408-8.6393 7.089 0 11.132 3.7659 11.132 10.2453zm-8.363-6.9779v-1.4399c-.554-1.0522-2.049-1.7167-3.655-1.7167-1.717 0-3.433.7199-3.433 2.3813 0 1.7168 1.716 2.4367 3.433 2.4367 1.606 0 3.101-.6645 3.655-1.6614zm20.742-29.0191v35.997h-8.694v-35.997zm13.036 25.9178h9.248c.72 2.326 2.714 3.489 5.483 3.489 2.713 0 4.596-1.163 4.596-3.2674 0-1.6061-1.052-2.326-3.212-2.8244l-6.534-1.3845c-4.985-1.1076-8.751-3.7105-8.751-9.47 0-6.6456 5.538-11.0206 13.07-11.0206 8.307 0 13.014 4.5411 13.956 10.4114h-8.695c-.72-1.8829-2.27-3.3228-5.205-3.3228-2.548 0-4.265 1.1076-4.265 2.9905 0 1.4953 1.052 2.326 2.825 2.7137l6.645 1.5506c5.815 1.3845 9.027 4.5412 9.027 9.8023 0 6.9778-5.87 10.9654-13.291 10.9654-8.141 0-13.679-3.9322-14.897-10.6332zm46.509 1.3845h8.031c-.887 5.7597-5.206 9.2487-11.686 9.2487-7.642 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.317-13.0143 12.516-13.0143 7.643 0 11.962 5.095 11.962 12.5159v2.1598h-16.115c.277 2.9905 1.827 4.5965 4.319 4.5965 1.773 0 3.157-.7753 3.655-2.4921zm-3.821-10.0237c-2.049 0-3.433 1.2737-3.987 3.5997h7.532c-.111-2.0491-1.385-3.5997-3.545-3.5997zm31.431-6.3134v8.3624c-1.053-.5538-2.216-.7753-3.6-.7753-2.381 0-3.988 1.0522-4.431 2.8244v14.6203h-8.694v-24.921h8.694v2.2152c1.219-1.6614 3.157-2.769 5.649-2.769 1.108 0 1.994.2215 2.382.443zm18.288 25.0318h-7.809l-9.47-24.921h8.861l4.763 14.288 4.652-14.288h8.528zm25.614-8.6947h8.03c-.886 5.7597-5.206 9.2487-11.685 9.2487-7.642 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.316-13.0143 12.516-13.0143 7.642 0 11.962 5.095 11.962 12.5159v2.1598h-16.116c.277 2.9905 1.828 4.5965 4.32 4.5965 1.772 0 3.157-.7753 3.655-2.4921zm-3.821-10.0237c-2.049 0-3.434 1.2737-3.988 3.5997h7.532c-.111-2.0491-1.384-3.5997-3.544-3.5997zm31.43-6.3134v8.3624c-1.052-.5538-2.215-.7753-3.6-.7753-2.381 0-3.987 1.0522-4.43 2.8244v14.6203h-8.695v-24.921h8.695v2.2152c1.218-1.6614 3.157-2.769 5.649-2.769 1.107 0 1.993.2215 2.381.443zm13.703-8.9715h24.312v7.6424h-15.562v5.3165h14.232v7.4763h-14.232v5.8703h15.562v7.6978h-24.312zm44.667 8.9715v8.3624c-1.052-.5538-2.215-.7753-3.6-.7753-2.381 0-3.987 1.0522-4.43 2.8244v14.6203h-8.695v-24.921h8.695v2.2152c1.218-1.6614 3.156-2.769 5.648-2.769 1.108 0 1.994.2215 2.382.443zm19.673 0v8.3624c-1.053-.5538-2.216-.7753-3.6-.7753-2.381 0-3.987 1.0522-4.43 2.8244v14.6203h-8.695v-24.921h8.695v2.2152c1.218-1.6614 3.156-2.769 5.648-2.769 1.108 0 1.994.2215 2.382.443zm26.769 12.5713c0 7.6978-5.15 13.0145-12.737 13.0145-7.532 0-12.738-5.3167-12.738-13.0145s5.206-13.0143 12.738-13.0143c7.587 0 12.737 5.3165 12.737 13.0143zm-8.529 0c0-3.4336-1.495-5.8703-4.208-5.8703-2.659 0-4.154 2.4367-4.154 5.8703s1.495 5.8149 4.154 5.8149c2.713 0 4.208-2.3813 4.208-5.8149zm28.082-12.5713v8.3624c-1.052-.5538-2.215-.7753-3.6-.7753-2.381 0-3.987 1.0522-4.43 2.8244v14.6203h-8.695v-24.921h8.695v2.2152c1.218-1.6614 3.157-2.769 5.649-2.769 1.107 0 1.993.2215 2.381.443z" id="error-description"/></svg>
|
|
127
|
+
</header>
|
|
128
|
+
<article>
|
|
129
|
+
<p><strong>We're sorry, but something went wrong.</strong><br> If you're the application owner check the logs for more information.</p>
|
|
130
|
+
</article>
|
|
131
|
+
</main>
|
|
132
|
+
|
|
133
|
+
</body>
|
|
134
|
+
|
|
135
|
+
</html>
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# rbs_inline: enabled
|
|
3
|
+
|
|
4
|
+
require 'rails/generators'
|
|
5
|
+
require 'rails/generators/migration'
|
|
6
|
+
|
|
7
|
+
module JpAddressComplement
|
|
8
|
+
module Generators
|
|
9
|
+
# `rails g jp_address_complement:install` で呼び出されるジェネレーター
|
|
10
|
+
# 住所テーブル用マイグレーションファイルを利用者アプリの db/migrate/ に生成する
|
|
11
|
+
class InstallGenerator < Rails::Generators::Base
|
|
12
|
+
include Rails::Generators::Migration
|
|
13
|
+
|
|
14
|
+
# __dir__ は String を返す(Rails の RBS で nil と誤推論される場合の対策)
|
|
15
|
+
source_root File.expand_path('templates', __dir__.to_s)
|
|
16
|
+
desc 'Creates a migration file for jp_address_complement postal codes table'
|
|
17
|
+
|
|
18
|
+
# Rails::Generators::Base の RBS に next_migration_number 等が未定義のため steep:ignore
|
|
19
|
+
# @rbs (String dirname) -> String
|
|
20
|
+
def self.next_migration_number(dirname)
|
|
21
|
+
next_migration_number = current_migration_number(dirname) + 1 # steep:ignore
|
|
22
|
+
ActiveRecord::Migration.next_migration_number(next_migration_number) # steep:ignore
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @rbs () -> void
|
|
26
|
+
def create_migration_file
|
|
27
|
+
migration_template( # steep:ignore
|
|
28
|
+
'create_jp_address_complement_postal_codes.rb.erb',
|
|
29
|
+
'db/migrate/create_jp_address_complement_postal_codes.rb'
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
data/lib/generators/jp_address_complement/templates/create_jp_address_complement_postal_codes.rb.erb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
class CreateJpAddressComplementPostalCodes < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
|
2
|
+
def change
|
|
3
|
+
create_table :jp_address_complement_postal_codes do |t|
|
|
4
|
+
t.string :postal_code, limit: 7, null: false
|
|
5
|
+
t.string :pref_code, limit: 2, null: false
|
|
6
|
+
t.string :pref, limit: 10, null: false
|
|
7
|
+
t.string :city, limit: 50, null: false
|
|
8
|
+
t.string :town, limit: 100
|
|
9
|
+
t.string :kana_pref, limit: 20
|
|
10
|
+
t.string :kana_city, limit: 100
|
|
11
|
+
t.string :kana_town, limit: 200
|
|
12
|
+
t.boolean :has_alias, default: false, null: false
|
|
13
|
+
t.boolean :is_partial, default: false, null: false
|
|
14
|
+
t.boolean :is_large_office, default: false, null: false
|
|
15
|
+
t.integer :version, default: 0, null: false
|
|
16
|
+
t.timestamps
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
add_index :jp_address_complement_postal_codes, :postal_code,
|
|
20
|
+
name: 'idx_jp_address_complement_postal_code'
|
|
21
|
+
|
|
22
|
+
# 同一の郵便番号・都道府県・市区町村・町域(漢字)でも読み(カナ)が異なれば別レコードとする
|
|
23
|
+
reversible do |dir|
|
|
24
|
+
dir.up do
|
|
25
|
+
# MySQL 8.0.13+ では式インデックスに各式を二重括弧で囲む必要がある
|
|
26
|
+
unique_index_columns = if connection.adapter_name =~ /mysql/i
|
|
27
|
+
"(postal_code, pref_code, city, (COALESCE(town,'')), (COALESCE(kana_pref,'')), (COALESCE(kana_city,'')), (COALESCE(kana_town,'')))"
|
|
28
|
+
else
|
|
29
|
+
"(postal_code, pref_code, city, COALESCE(town,''), COALESCE(kana_pref,''), COALESCE(kana_city,''), COALESCE(kana_town,''))"
|
|
30
|
+
end
|
|
31
|
+
execute <<-SQL.squish
|
|
32
|
+
CREATE UNIQUE INDEX idx_jp_address_complement_unique
|
|
33
|
+
ON jp_address_complement_postal_codes
|
|
34
|
+
#{unique_index_columns}
|
|
35
|
+
SQL
|
|
36
|
+
end
|
|
37
|
+
dir.down do
|
|
38
|
+
remove_index :jp_address_complement_postal_codes, name: 'idx_jp_address_complement_unique'
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
add_index :jp_address_complement_postal_codes, :version,
|
|
43
|
+
name: 'idx_jp_address_complement_version'
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# rbs_inline: disabled — AddressRecord は Data.define のため sig/manual/address_record.rbs で手動定義
|
|
3
|
+
|
|
4
|
+
module JpAddressComplement
|
|
5
|
+
# 郵便番号に対応する住所データの値オブジェクト
|
|
6
|
+
# ActiveRecord インスタンスを返さないことでコアロジックの AR 依存を排除する
|
|
7
|
+
ADDRESS_RECORD_ATTRIBUTES = %i[
|
|
8
|
+
postal_code
|
|
9
|
+
pref_code
|
|
10
|
+
pref
|
|
11
|
+
city
|
|
12
|
+
town
|
|
13
|
+
kana_pref
|
|
14
|
+
kana_city
|
|
15
|
+
kana_town
|
|
16
|
+
has_alias
|
|
17
|
+
is_partial
|
|
18
|
+
is_large_office
|
|
19
|
+
].freeze
|
|
20
|
+
|
|
21
|
+
# Ruby 3.2 以降を対象。Data.define で定義する。
|
|
22
|
+
AddressRecord = Data.define(*ADDRESS_RECORD_ATTRIBUTES)
|
|
23
|
+
|
|
24
|
+
# インスタンスメソッドは Steep の型解決のためクラス再オープンで定義(Data.define のブロック内だと self が正しく解釈されない)
|
|
25
|
+
class AddressRecord
|
|
26
|
+
# 通常住所に含まれない情報(括弧()内の部分、「以下に掲載がない場合」等)を除いた町域名
|
|
27
|
+
def normalized_town
|
|
28
|
+
Normalizer.normalize_town_for_display(town)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# 通常住所に含まれない情報を除いた町域カナ
|
|
32
|
+
def normalized_kana_town
|
|
33
|
+
Normalizer.normalize_town_for_display(kana_town)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# rbs_inline: enabled
|
|
3
|
+
|
|
4
|
+
module JpAddressComplement
|
|
5
|
+
# Gem の設定を保持するクラス
|
|
6
|
+
# configure ブロックを通じて repository アダプター・PostalCode の継承元などを注入する
|
|
7
|
+
class Configuration
|
|
8
|
+
attr_accessor :repository #: Repositories::PostalCodeRepository?
|
|
9
|
+
# PostalCode モデルの継承元。nil のときは ActiveRecord::Base。initializer で ApplicationRecord 等に変更可能。
|
|
10
|
+
attr_accessor :postal_code_model_base #: Class?
|
|
11
|
+
# PostalCode が参照するテーブル名。nil のときは 'jp_address_complement_postal_codes'。initializer で変更可能。
|
|
12
|
+
attr_accessor :postal_code_table_name #: String?
|
|
13
|
+
|
|
14
|
+
# @rbs () -> void
|
|
15
|
+
def initialize
|
|
16
|
+
@repository = nil
|
|
17
|
+
@postal_code_model_base = nil
|
|
18
|
+
@postal_code_table_name = nil
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# rbs_inline: enabled
|
|
3
|
+
|
|
4
|
+
require 'csv'
|
|
5
|
+
require_relative '../address_record'
|
|
6
|
+
require_relative '../models/postal_code'
|
|
7
|
+
|
|
8
|
+
module JpAddressComplement
|
|
9
|
+
module Importers
|
|
10
|
+
# インポート結果(件数報告用)
|
|
11
|
+
# @rbs type upserted = Integer
|
|
12
|
+
# @rbs type deleted = Integer
|
|
13
|
+
ImportResult = Data.define(:upserted, :deleted)
|
|
14
|
+
|
|
15
|
+
# UTF-8 版 KEN_ALL(utf_ken_all.csv)を読み込み、jp_address_complement_postal_codes テーブルに upsert する
|
|
16
|
+
# UTF-8 形式の CSV を前提として処理する
|
|
17
|
+
class CsvImporter
|
|
18
|
+
BATCH_SIZE = 1000 #: Integer
|
|
19
|
+
|
|
20
|
+
# 列インデックス(KEN_ALL.CSV 形式)
|
|
21
|
+
COL_PREF_CODE = 0 #: Integer
|
|
22
|
+
COL_POSTAL_CODE = 2 #: Integer
|
|
23
|
+
COL_KANA_PREF = 3 #: Integer
|
|
24
|
+
COL_KANA_CITY = 4 #: Integer
|
|
25
|
+
COL_KANA_TOWN = 5 #: Integer
|
|
26
|
+
COL_PREF = 6 #: Integer
|
|
27
|
+
COL_CITY = 7 #: Integer
|
|
28
|
+
COL_TOWN = 8 #: Integer
|
|
29
|
+
COL_IS_PARTIAL = 9 #: Integer
|
|
30
|
+
COL_HAS_ALIAS = 12 #: Integer
|
|
31
|
+
COL_IS_LARGE_OFFICE = 13 #: Integer
|
|
32
|
+
|
|
33
|
+
# @rbs (String csv_path) -> void
|
|
34
|
+
def initialize(csv_path)
|
|
35
|
+
@csv_path = csv_path
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# CSV を読み込み、upsert 後に古いバージョンの行を一括削除する。戻り値は ImportResult。
|
|
39
|
+
# バージョンは既存レコードの最大値+1 で、別テーブルでは管理しない。
|
|
40
|
+
# @rbs () -> ImportResult
|
|
41
|
+
# @return [ImportResult] upserted 件数と deleted 件数
|
|
42
|
+
def import
|
|
43
|
+
raise ImportError, "CSV ファイルが見つかりません: #{@csv_path}" unless File.exist?(@csv_path)
|
|
44
|
+
|
|
45
|
+
import_version = (PostalCode.maximum(:version) || 0) + 1
|
|
46
|
+
total_upserted, keys_in_csv = read_and_upsert(import_version)
|
|
47
|
+
raise ImportError, '有効行が0件のためインポートを実行しません(空CSVは拒否します)' if keys_in_csv.empty?
|
|
48
|
+
|
|
49
|
+
deleted = delete_obsolete(import_version)
|
|
50
|
+
ImportResult.new(upserted: total_upserted, deleted: deleted)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
# @rbs (Array[String?] row) -> (Hash[Symbol, untyped] | nil)
|
|
56
|
+
def parse_row(row)
|
|
57
|
+
postal_code = row[COL_POSTAL_CODE]&.strip
|
|
58
|
+
pref_code = row[COL_PREF_CODE]&.strip&.slice(0, 2)
|
|
59
|
+
pref = row[COL_PREF]&.strip
|
|
60
|
+
city = row[COL_CITY]&.strip
|
|
61
|
+
|
|
62
|
+
return nil if postal_code.nil? || pref_code.nil? || pref.nil? || city.nil?
|
|
63
|
+
return nil unless postal_code.match?(/\A\d{7}\z/)
|
|
64
|
+
|
|
65
|
+
{
|
|
66
|
+
postal_code: postal_code,
|
|
67
|
+
pref_code: pref_code,
|
|
68
|
+
pref: pref,
|
|
69
|
+
city: city,
|
|
70
|
+
town: row[COL_TOWN]&.strip,
|
|
71
|
+
kana_pref: row[COL_KANA_PREF]&.strip,
|
|
72
|
+
kana_city: row[COL_KANA_CITY]&.strip,
|
|
73
|
+
kana_town: row[COL_KANA_TOWN]&.strip,
|
|
74
|
+
has_alias: row[COL_HAS_ALIAS]&.strip == '1',
|
|
75
|
+
is_partial: row[COL_IS_PARTIAL]&.strip == '1',
|
|
76
|
+
is_large_office: row[COL_IS_LARGE_OFFICE]&.strip == '1'
|
|
77
|
+
}
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# @rbs (Integer import_version) -> [Integer, Hash[untyped, bool]]
|
|
81
|
+
def read_and_upsert(import_version)
|
|
82
|
+
keys_in_csv = {} #: Hash[untyped, bool]
|
|
83
|
+
total_upserted = 0
|
|
84
|
+
batch = [] #: Array[Hash[Symbol, untyped]]
|
|
85
|
+
|
|
86
|
+
CSV.foreach(@csv_path, encoding: 'UTF-8') do |row|
|
|
87
|
+
record = parse_row(row)
|
|
88
|
+
next if record.nil?
|
|
89
|
+
|
|
90
|
+
record = record.merge(version: import_version)
|
|
91
|
+
keys_in_csv[row_key(record)] = true
|
|
92
|
+
batch << record
|
|
93
|
+
if batch.size >= BATCH_SIZE
|
|
94
|
+
upsert_batch(batch)
|
|
95
|
+
total_upserted += batch.size
|
|
96
|
+
batch.clear
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
if batch.any?
|
|
101
|
+
upsert_batch(batch)
|
|
102
|
+
total_upserted += batch.size
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
[total_upserted, keys_in_csv]
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# @rbs (Array[Hash[Symbol, untyped]] batch) -> void
|
|
109
|
+
def upsert_batch(batch)
|
|
110
|
+
PostalCode.transaction do
|
|
111
|
+
batch.each do |record|
|
|
112
|
+
PostalCode.where(
|
|
113
|
+
postal_code: record[:postal_code],
|
|
114
|
+
pref_code: record[:pref_code],
|
|
115
|
+
city: record[:city],
|
|
116
|
+
town: record[:town],
|
|
117
|
+
kana_pref: record[:kana_pref],
|
|
118
|
+
kana_city: record[:kana_city],
|
|
119
|
+
kana_town: record[:kana_town]
|
|
120
|
+
).delete_all
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
PostalCode.upsert_all(batch)
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# 郵便番号・都道府県・市区町村・町域(漢字)が同じでも読み(カナ)が異なれば別レコードとして扱う
|
|
128
|
+
# @rbs (Hash[Symbol, untyped] record) -> Array[String]
|
|
129
|
+
def row_key(record)
|
|
130
|
+
[
|
|
131
|
+
record[:postal_code].to_s,
|
|
132
|
+
record[:pref_code].to_s,
|
|
133
|
+
record[:city].to_s,
|
|
134
|
+
(record[:town] || '').to_s,
|
|
135
|
+
(record[:kana_pref] || '').to_s,
|
|
136
|
+
(record[:kana_city] || '').to_s,
|
|
137
|
+
(record[:kana_town] || '').to_s
|
|
138
|
+
]
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# 今回のインポートより古いバージョンの行を一括削除し、削除件数を返す
|
|
142
|
+
# @rbs (Integer import_version) -> Integer
|
|
143
|
+
def delete_obsolete(import_version)
|
|
144
|
+
PostalCode.where(version: ...import_version).delete_all
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|