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,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddressesController < ApplicationController
|
|
4
|
+
def index
|
|
5
|
+
@postal_code = params[:postal_code].to_s.strip
|
|
6
|
+
@addresses = if @postal_code.present?
|
|
7
|
+
JpAddressComplement.search_by_postal_code(@postal_code)
|
|
8
|
+
else
|
|
9
|
+
[]
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def prefix
|
|
14
|
+
@prefix = params[:prefix].to_s.strip
|
|
15
|
+
@addresses = if @prefix.present? && @prefix.length >= 4
|
|
16
|
+
JpAddressComplement.search_by_postal_code_prefix(@prefix)
|
|
17
|
+
else
|
|
18
|
+
[]
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def validate
|
|
23
|
+
@postal_code = params[:postal_code].to_s.strip
|
|
24
|
+
@address = params[:address].to_s.strip
|
|
25
|
+
if @postal_code.present? && @address.present?
|
|
26
|
+
@valid = JpAddressComplement.valid_combination?(@postal_code, @address)
|
|
27
|
+
else
|
|
28
|
+
@valid = nil
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def prefecture
|
|
33
|
+
@code = params[:code].to_s.strip
|
|
34
|
+
@name = params[:name].to_s.strip
|
|
35
|
+
@code_to_name = nil
|
|
36
|
+
@name_to_code = nil
|
|
37
|
+
if @code.present?
|
|
38
|
+
@code_to_name = JpAddressComplement.prefecture_name_from_code(@code)
|
|
39
|
+
end
|
|
40
|
+
if @name.present?
|
|
41
|
+
@name_to_code = JpAddressComplement.prefecture_code_from_name(@name)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def reverse
|
|
46
|
+
@pref = params[:pref].to_s.strip
|
|
47
|
+
@city = params[:city].to_s.strip
|
|
48
|
+
@town = params[:town].to_s.strip
|
|
49
|
+
if @pref.present? && @city.present?
|
|
50
|
+
@postal_codes = JpAddressComplement.search_postal_codes_by_address(
|
|
51
|
+
pref: @pref,
|
|
52
|
+
city: @city,
|
|
53
|
+
town: @town.presence
|
|
54
|
+
)
|
|
55
|
+
else
|
|
56
|
+
@postal_codes = []
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<h1>郵便番号から住所を検索(7桁完全一致)</h1>
|
|
2
|
+
|
|
3
|
+
<%= form_with url: addresses_path, method: :get, local: true do |f| %>
|
|
4
|
+
<p>
|
|
5
|
+
<%= f.label :postal_code, '郵便番号(7桁・ハイフン可)' %>
|
|
6
|
+
<%= f.text_field :postal_code, value: @postal_code, placeholder: '1000001', maxlength: 8, size: 10 %>
|
|
7
|
+
<%= f.submit '検索' %>
|
|
8
|
+
</p>
|
|
9
|
+
<% end %>
|
|
10
|
+
|
|
11
|
+
<% if @postal_code.present? %>
|
|
12
|
+
<h2>検索結果(<%= @postal_code %>)</h2>
|
|
13
|
+
<% if @addresses.any? %>
|
|
14
|
+
<ul>
|
|
15
|
+
<% @addresses.each do |addr| %>
|
|
16
|
+
<li><%= addr.pref %><%= addr.city %><%= addr.town %></li>
|
|
17
|
+
<% end %>
|
|
18
|
+
</ul>
|
|
19
|
+
<% else %>
|
|
20
|
+
<p>該当する住所はありません。</p>
|
|
21
|
+
<% end %>
|
|
22
|
+
<% end %>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<h1>都道府県コードと都道府県名の変換</h1>
|
|
2
|
+
<p>JIS X 0401 の都道府県コード(01〜47)と都道府県名の相互変換ができます。どちらか一方、または両方入力して試せます。</p>
|
|
3
|
+
|
|
4
|
+
<%= form_with url: addresses_prefecture_path, method: :get, local: true do |f| %>
|
|
5
|
+
<p>
|
|
6
|
+
<%= f.label :code, '都道府県コード → 都道府県名' %>
|
|
7
|
+
<%= f.text_field :code, value: @code, placeholder: '13', maxlength: 2, size: 4 %>
|
|
8
|
+
<% if @code_to_name != nil %>
|
|
9
|
+
→ <strong><%= @code_to_name || '(該当なし)' %></strong>
|
|
10
|
+
<% end %>
|
|
11
|
+
</p>
|
|
12
|
+
<p>
|
|
13
|
+
<%= f.label :name, '都道府県名 → 都道府県コード' %>
|
|
14
|
+
<%= f.text_field :name, value: @name, placeholder: '東京都', size: 12 %>
|
|
15
|
+
<% if @name_to_code != nil %>
|
|
16
|
+
→ <strong><%= @name_to_code || '(該当なし)' %></strong>
|
|
17
|
+
<% end %>
|
|
18
|
+
</p>
|
|
19
|
+
<p><%= f.submit '変換' %></p>
|
|
20
|
+
<% end %>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<h1>郵便番号のプレフィックス検索</h1>
|
|
2
|
+
<p>郵便番号の先頭4桁以上を入力すると、そのプレフィックスに一致する住所候補を返します。入力中の補完に利用できます。</p>
|
|
3
|
+
|
|
4
|
+
<%= form_with url: addresses_prefix_path, method: :get, local: true do |f| %>
|
|
5
|
+
<p>
|
|
6
|
+
<%= f.label :prefix, '郵便番号(先頭4桁以上)' %>
|
|
7
|
+
<%= f.text_field :prefix, value: @prefix, placeholder: '1000', maxlength: 8, size: 10 %>
|
|
8
|
+
<%= f.submit '検索' %>
|
|
9
|
+
</p>
|
|
10
|
+
<% end %>
|
|
11
|
+
|
|
12
|
+
<% if @prefix.present? %>
|
|
13
|
+
<h2>検索結果(<%= @prefix %> で始まる郵便番号)</h2>
|
|
14
|
+
<% if @prefix.length < 4 %>
|
|
15
|
+
<p>4桁以上入力してください。</p>
|
|
16
|
+
<% elsif @addresses.any? %>
|
|
17
|
+
<ul>
|
|
18
|
+
<% @addresses.each do |addr| %>
|
|
19
|
+
<li><%= addr.postal_code %>: <%= addr.pref %><%= addr.city %><%= addr.town %></li>
|
|
20
|
+
<% end %>
|
|
21
|
+
</ul>
|
|
22
|
+
<% else %>
|
|
23
|
+
<p>該当する住所はありません。</p>
|
|
24
|
+
<% end %>
|
|
25
|
+
<% end %>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<h1>住所から郵便番号の逆引き</h1>
|
|
2
|
+
<p>都道府県・市区町村・町域を指定して、対応する郵便番号の一覧を取得します。町域は省略可能です。</p>
|
|
3
|
+
|
|
4
|
+
<%= form_with url: addresses_reverse_path, method: :get, local: true do |f| %>
|
|
5
|
+
<p>
|
|
6
|
+
<%= f.label :pref, '都道府県' %>
|
|
7
|
+
<%= f.text_field :pref, value: @pref, placeholder: '東京都', size: 12 %>
|
|
8
|
+
</p>
|
|
9
|
+
<p>
|
|
10
|
+
<%= f.label :city, '市区町村' %>
|
|
11
|
+
<%= f.text_field :city, value: @city, placeholder: '千代田区', size: 16 %>
|
|
12
|
+
</p>
|
|
13
|
+
<p>
|
|
14
|
+
<%= f.label :town, '町域(任意)' %>
|
|
15
|
+
<%= f.text_field :town, value: @town, placeholder: '千代田', size: 20 %>
|
|
16
|
+
</p>
|
|
17
|
+
<p><%= f.submit '郵便番号を検索' %></p>
|
|
18
|
+
<% end %>
|
|
19
|
+
|
|
20
|
+
<% if @pref.present? && @city.present? %>
|
|
21
|
+
<h2>検索結果</h2>
|
|
22
|
+
<% if @postal_codes.any? %>
|
|
23
|
+
<p>該当する郵便番号: </p>
|
|
24
|
+
<% @postal_codes.map(&:second).each do |record| %>
|
|
25
|
+
<p><%= "#{record.postal_code} #{record.pref}#{record.city}#{record.town}" %></p>
|
|
26
|
+
<% end %>
|
|
27
|
+
<% else %>
|
|
28
|
+
<p>該当する郵便番号はありません。</p>
|
|
29
|
+
<% end %>
|
|
30
|
+
<% end %>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<h1>郵便番号と住所の整合性チェック</h1>
|
|
2
|
+
<p>「この郵便番号とこの住所の組み合わせは正しいか?」を判定します。フォームのバリデーションに利用できます。</p>
|
|
3
|
+
|
|
4
|
+
<%= form_with url: addresses_validate_path, method: :get, local: true do |f| %>
|
|
5
|
+
<p>
|
|
6
|
+
<%= f.label :postal_code, '郵便番号' %>
|
|
7
|
+
<%= f.text_field :postal_code, value: @postal_code, placeholder: '1000001', maxlength: 8, size: 10 %>
|
|
8
|
+
</p>
|
|
9
|
+
<p>
|
|
10
|
+
<%= f.label :address, '住所' %>
|
|
11
|
+
<%= f.text_field :address, value: @address, placeholder: '東京都千代田区千代田', size: 40 %>
|
|
12
|
+
</p>
|
|
13
|
+
<p><%= f.submit '整合性をチェック' %></p>
|
|
14
|
+
<% end %>
|
|
15
|
+
|
|
16
|
+
<% if @valid != nil %>
|
|
17
|
+
<h2>結果</h2>
|
|
18
|
+
<% if @valid %>
|
|
19
|
+
<p style="color: green;">✓ この郵便番号と住所の組み合わせは正しいです。</p>
|
|
20
|
+
<% else %>
|
|
21
|
+
<p style="color: #c00;">✗ この郵便番号と住所の組み合わせは一致しません。</p>
|
|
22
|
+
<% end %>
|
|
23
|
+
<% end %>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title><%= content_for(:title) || "Search Postal Code To Address" %></title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
7
|
+
<meta name="application-name" content="Search Postal Code To Address">
|
|
8
|
+
<meta name="mobile-web-app-capable" content="yes">
|
|
9
|
+
<%= csrf_meta_tags %>
|
|
10
|
+
<%= csp_meta_tag %>
|
|
11
|
+
|
|
12
|
+
<%= yield :head %>
|
|
13
|
+
|
|
14
|
+
<%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %>
|
|
15
|
+
<%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %>
|
|
16
|
+
|
|
17
|
+
<link rel="icon" href="/icon.png" type="image/png">
|
|
18
|
+
<link rel="icon" href="/icon.svg" type="image/svg+xml">
|
|
19
|
+
<link rel="apple-touch-icon" href="/icon.png">
|
|
20
|
+
|
|
21
|
+
<%# Includes all stylesheet files in app/assets/stylesheets %>
|
|
22
|
+
<%= stylesheet_link_tag "application" %>
|
|
23
|
+
</head>
|
|
24
|
+
|
|
25
|
+
<body>
|
|
26
|
+
<nav style="margin-bottom: 1.5rem; padding: 0.5rem 0; border-bottom: 1px solid #ccc;">
|
|
27
|
+
<strong>JpAddressComplement デモ:</strong>
|
|
28
|
+
<%= link_to "郵便番号→住所(7桁)", addresses_path %>
|
|
29
|
+
|
|
|
30
|
+
<%= link_to "プレフィックス検索", addresses_prefix_path %>
|
|
31
|
+
|
|
|
32
|
+
<%= link_to "整合性チェック", addresses_validate_path %>
|
|
33
|
+
|
|
|
34
|
+
<%= link_to "都道府県コード⇔名", addresses_prefecture_path %>
|
|
35
|
+
|
|
|
36
|
+
<%= link_to "住所→郵便番号の逆引き", addresses_reverse_path %>
|
|
37
|
+
</nav>
|
|
38
|
+
<%= yield %>
|
|
39
|
+
</body>
|
|
40
|
+
</html>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "JpAddressComplementDemo",
|
|
3
|
+
"icons": [
|
|
4
|
+
{
|
|
5
|
+
"src": "/icon.png",
|
|
6
|
+
"type": "image/png",
|
|
7
|
+
"sizes": "512x512"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"src": "/icon.png",
|
|
11
|
+
"type": "image/png",
|
|
12
|
+
"sizes": "512x512",
|
|
13
|
+
"purpose": "maskable"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"start_url": "/",
|
|
17
|
+
"display": "standalone",
|
|
18
|
+
"scope": "/",
|
|
19
|
+
"description": "jp_address_complement gem の公開APIデモ(郵便番号・住所・都道府県コードなど).",
|
|
20
|
+
"theme_color": "red",
|
|
21
|
+
"background_color": "red"
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Add a service worker for processing Web Push notifications:
|
|
2
|
+
//
|
|
3
|
+
// self.addEventListener("push", async (event) => {
|
|
4
|
+
// const { title, options } = await event.data.json()
|
|
5
|
+
// event.waitUntil(self.registration.showNotification(title, options))
|
|
6
|
+
// })
|
|
7
|
+
//
|
|
8
|
+
// self.addEventListener("notificationclick", function(event) {
|
|
9
|
+
// event.notification.close()
|
|
10
|
+
// event.waitUntil(
|
|
11
|
+
// clients.matchAll({ type: "window" }).then((clientList) => {
|
|
12
|
+
// for (let i = 0; i < clientList.length; i++) {
|
|
13
|
+
// let client = clientList[i]
|
|
14
|
+
// let clientPath = (new URL(client.url)).pathname
|
|
15
|
+
//
|
|
16
|
+
// if (clientPath == event.notification.data.path && "focus" in client) {
|
|
17
|
+
// return client.focus()
|
|
18
|
+
// }
|
|
19
|
+
// }
|
|
20
|
+
//
|
|
21
|
+
// if (clients.openWindow) {
|
|
22
|
+
// return clients.openWindow(event.notification.data.path)
|
|
23
|
+
// }
|
|
24
|
+
// })
|
|
25
|
+
// )
|
|
26
|
+
// })
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require "fileutils"
|
|
3
|
+
|
|
4
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
|
5
|
+
|
|
6
|
+
def system!(*args)
|
|
7
|
+
system(*args, exception: true)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
FileUtils.chdir APP_ROOT do
|
|
11
|
+
# This script is a way to set up or update your development environment automatically.
|
|
12
|
+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
|
13
|
+
# Add necessary setup steps to this file.
|
|
14
|
+
|
|
15
|
+
puts "== Installing dependencies =="
|
|
16
|
+
system("bundle check") || system!("bundle install")
|
|
17
|
+
|
|
18
|
+
# puts "\n== Copying sample files =="
|
|
19
|
+
# unless File.exist?("config/database.yml")
|
|
20
|
+
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
|
|
21
|
+
# end
|
|
22
|
+
|
|
23
|
+
puts "\n== Preparing database =="
|
|
24
|
+
system! "bin/rails db:prepare"
|
|
25
|
+
system! "bin/rails db:reset" if ARGV.include?("--reset")
|
|
26
|
+
|
|
27
|
+
puts "\n== Removing old logs and tempfiles =="
|
|
28
|
+
system! "bin/rails log:clear tmp:clear"
|
|
29
|
+
|
|
30
|
+
unless ARGV.include?("--skip-server")
|
|
31
|
+
puts "\n== Starting development server =="
|
|
32
|
+
STDOUT.flush # flush the output before exec(2) so that it displays
|
|
33
|
+
exec "bin/dev"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require_relative "boot"
|
|
2
|
+
|
|
3
|
+
require "rails"
|
|
4
|
+
# Pick the frameworks you want:
|
|
5
|
+
require "active_model/railtie"
|
|
6
|
+
# require "active_job/railtie"
|
|
7
|
+
require "active_record/railtie"
|
|
8
|
+
# require "active_storage/engine"
|
|
9
|
+
require "action_controller/railtie"
|
|
10
|
+
# require "action_mailer/railtie"
|
|
11
|
+
# require "action_mailbox/engine"
|
|
12
|
+
# require "action_text/engine"
|
|
13
|
+
require "action_view/railtie"
|
|
14
|
+
# require "action_cable/engine"
|
|
15
|
+
# require "rails/test_unit/railtie"
|
|
16
|
+
|
|
17
|
+
# Require the gems listed in Gemfile, including any gems
|
|
18
|
+
# you've limited to :test, :development, or :production.
|
|
19
|
+
Bundler.require(*Rails.groups)
|
|
20
|
+
|
|
21
|
+
module JpAddressComplementDemo
|
|
22
|
+
class Application < Rails::Application
|
|
23
|
+
# Initialize configuration defaults for originally generated Rails version.
|
|
24
|
+
config.load_defaults 8.1
|
|
25
|
+
|
|
26
|
+
# Please, add to the `ignore` list any other `lib` subdirectories that do
|
|
27
|
+
# not contain `.rb` files, or that should not be reloaded or eager loaded.
|
|
28
|
+
# Common ones are `templates`, `generators`, or `middleware`, for example.
|
|
29
|
+
config.autoload_lib(ignore: %w[assets tasks])
|
|
30
|
+
|
|
31
|
+
# Configuration for the application, engines, and railties goes here.
|
|
32
|
+
#
|
|
33
|
+
# These settings can be overridden in specific environments using the files
|
|
34
|
+
# in config/environments, which are processed later.
|
|
35
|
+
#
|
|
36
|
+
# config.time_zone = "Central Time (US & Canada)"
|
|
37
|
+
# config.eager_load_paths << Rails.root.join("extras")
|
|
38
|
+
|
|
39
|
+
# Don't generate system test files.
|
|
40
|
+
config.generators.system_tests = nil
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Run using bin/ci
|
|
2
|
+
|
|
3
|
+
CI.run do
|
|
4
|
+
step "Setup", "bin/setup --skip-server"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Optional: set a green GitHub commit status to unblock PR merge.
|
|
9
|
+
# Requires the `gh` CLI and `gh extension install basecamp/gh-signoff`.
|
|
10
|
+
# if success?
|
|
11
|
+
# step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff"
|
|
12
|
+
# else
|
|
13
|
+
# failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again."
|
|
14
|
+
# end
|
|
15
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
baNtetP6wv5inaVa0w5/xCAq5ZBoFeJsTzXkIjn43d/CMcPOR4uO/iJgqeXtjgnffMybw29Z+QiEt7BjsE54d2jlhGt+NPDflk4exK2TLJmk0Im1vZ3z1BYCI9F2LBus6pFO+jYmUx07wK9DfmDudtV2tSYntlqJ2VdTSEx9ktXyXDksbNqTuXaPZFxi1/bn/t5O1YgQDgbvnohEmliJk9yDlLGlghx8j6tzPfWCxxr6DMu9MiSLuCSSqx2bMBXbYVU8K7qNB2DxTYe8gAgbT2px1K83a65oCqSln0K2G8+a/3rW9YXiAMbz+XRCd5bTWv4cVP69YtXE6piuBYUKwUM0LfYav4p9sjzOaPTLDyNN5yrmirwE4bHMiufkCyWFWlNZP87jzQYjz5qldVRyoVmQfLzf1+3x33/zMabiSvztpVpjBdEaaakYFJV2G1x1+boOjempbZx5xCzFb6wVbr8vlTCTfhaG2uost1txXMauEYfPbJrNu871--eyA6lsKXQfzwZVfG--wuK40RlIJ/vfdveYCKz1Mg==
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# SQLite. Versions 3.8.0 and up are supported.
|
|
2
|
+
# gem install sqlite3
|
|
3
|
+
#
|
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
|
5
|
+
# gem "sqlite3"
|
|
6
|
+
#
|
|
7
|
+
default: &default
|
|
8
|
+
adapter: sqlite3
|
|
9
|
+
max_connections: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
|
10
|
+
timeout: 5000
|
|
11
|
+
|
|
12
|
+
development:
|
|
13
|
+
<<: *default
|
|
14
|
+
database: storage/development.sqlite3
|
|
15
|
+
|
|
16
|
+
# Warning: The database defined as "test" will be erased and
|
|
17
|
+
# re-generated from your development database when you run "rake".
|
|
18
|
+
# Do not set this db to the same as development or production.
|
|
19
|
+
test:
|
|
20
|
+
<<: *default
|
|
21
|
+
database: storage/test.sqlite3
|
|
22
|
+
|
|
23
|
+
# SQLite3 write its data on the local filesystem, as such it requires
|
|
24
|
+
# persistent disks. If you are deploying to a managed service, you should
|
|
25
|
+
# make sure it provides disk persistence, as many don't.
|
|
26
|
+
#
|
|
27
|
+
# Similarly, if you deploy your application as a Docker container, you must
|
|
28
|
+
# ensure the database is located in a persisted volume.
|
|
29
|
+
production:
|
|
30
|
+
<<: *default
|
|
31
|
+
# database: path/to/persistent/storage/production.sqlite3
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require "active_support/core_ext/integer/time"
|
|
2
|
+
|
|
3
|
+
Rails.application.configure do
|
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
|
5
|
+
|
|
6
|
+
# Make code changes take effect immediately without server restart.
|
|
7
|
+
config.enable_reloading = true
|
|
8
|
+
|
|
9
|
+
# Do not eager load code on boot.
|
|
10
|
+
config.eager_load = false
|
|
11
|
+
|
|
12
|
+
# Show full error reports.
|
|
13
|
+
config.consider_all_requests_local = true
|
|
14
|
+
|
|
15
|
+
# Enable server timing.
|
|
16
|
+
config.server_timing = true
|
|
17
|
+
|
|
18
|
+
# Enable/disable Action Controller caching. By default Action Controller caching is disabled.
|
|
19
|
+
# Run rails dev:cache to toggle Action Controller caching.
|
|
20
|
+
if Rails.root.join("tmp/caching-dev.txt").exist?
|
|
21
|
+
config.action_controller.perform_caching = true
|
|
22
|
+
config.action_controller.enable_fragment_cache_logging = true
|
|
23
|
+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
|
|
24
|
+
else
|
|
25
|
+
config.action_controller.perform_caching = false
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Change to :null_store to avoid any caching.
|
|
29
|
+
config.cache_store = :memory_store
|
|
30
|
+
|
|
31
|
+
# Print deprecation notices to the Rails logger.
|
|
32
|
+
config.active_support.deprecation = :log
|
|
33
|
+
|
|
34
|
+
# Raise an error on page load if there are pending migrations.
|
|
35
|
+
config.active_record.migration_error = :page_load
|
|
36
|
+
|
|
37
|
+
# Highlight code that triggered database queries in logs.
|
|
38
|
+
config.active_record.verbose_query_logs = true
|
|
39
|
+
|
|
40
|
+
# Append comments with runtime information tags to SQL queries in logs.
|
|
41
|
+
config.active_record.query_log_tags_enabled = true
|
|
42
|
+
|
|
43
|
+
# Highlight code that triggered redirect in logs.
|
|
44
|
+
config.action_dispatch.verbose_redirect_logs = true
|
|
45
|
+
|
|
46
|
+
# Raises error for missing translations.
|
|
47
|
+
# config.i18n.raise_on_missing_translations = true
|
|
48
|
+
|
|
49
|
+
# Annotate rendered view with file names.
|
|
50
|
+
config.action_view.annotate_rendered_view_with_filenames = true
|
|
51
|
+
|
|
52
|
+
# Raise error when a before_action's only/except options reference missing actions.
|
|
53
|
+
config.action_controller.raise_on_missing_callback_actions = true
|
|
54
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require "active_support/core_ext/integer/time"
|
|
2
|
+
|
|
3
|
+
Rails.application.configure do
|
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
|
5
|
+
|
|
6
|
+
# Code is not reloaded between requests.
|
|
7
|
+
config.enable_reloading = false
|
|
8
|
+
|
|
9
|
+
# Eager load code on boot for better performance and memory savings (ignored by Rake tasks).
|
|
10
|
+
config.eager_load = true
|
|
11
|
+
|
|
12
|
+
# Full error reports are disabled.
|
|
13
|
+
config.consider_all_requests_local = false
|
|
14
|
+
|
|
15
|
+
# Turn on fragment caching in view templates.
|
|
16
|
+
config.action_controller.perform_caching = true
|
|
17
|
+
|
|
18
|
+
# Cache assets for far-future expiry since they are all digest stamped.
|
|
19
|
+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }
|
|
20
|
+
|
|
21
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
|
22
|
+
# config.asset_host = "http://assets.example.com"
|
|
23
|
+
|
|
24
|
+
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
|
|
25
|
+
config.assume_ssl = true
|
|
26
|
+
|
|
27
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
|
28
|
+
config.force_ssl = true
|
|
29
|
+
|
|
30
|
+
# Skip http-to-https redirect for the default health check endpoint.
|
|
31
|
+
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
|
|
32
|
+
|
|
33
|
+
# Log to STDOUT with the current request id as a default log tag.
|
|
34
|
+
config.log_tags = [ :request_id ]
|
|
35
|
+
config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
|
|
36
|
+
|
|
37
|
+
# Change to "debug" to log everything (including potentially personally-identifiable information!).
|
|
38
|
+
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
|
|
39
|
+
|
|
40
|
+
# Prevent health checks from clogging up the logs.
|
|
41
|
+
config.silence_healthcheck_path = "/up"
|
|
42
|
+
|
|
43
|
+
# Don't log any deprecations.
|
|
44
|
+
config.active_support.report_deprecations = false
|
|
45
|
+
|
|
46
|
+
# Replace the default in-process memory cache store with a durable alternative.
|
|
47
|
+
# config.cache_store = :mem_cache_store
|
|
48
|
+
|
|
49
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
|
50
|
+
# the I18n.default_locale when a translation cannot be found).
|
|
51
|
+
config.i18n.fallbacks = true
|
|
52
|
+
|
|
53
|
+
# Do not dump schema after migrations.
|
|
54
|
+
config.active_record.dump_schema_after_migration = false
|
|
55
|
+
|
|
56
|
+
# Only use :id for inspections in production.
|
|
57
|
+
config.active_record.attributes_for_inspect = [ :id ]
|
|
58
|
+
|
|
59
|
+
# Enable DNS rebinding protection and other `Host` header attacks.
|
|
60
|
+
# config.hosts = [
|
|
61
|
+
# "example.com", # Allow requests from example.com
|
|
62
|
+
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
|
|
63
|
+
# ]
|
|
64
|
+
#
|
|
65
|
+
# Skip DNS rebinding protection for the default health check endpoint.
|
|
66
|
+
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
|
|
67
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# The test environment is used exclusively to run your application's
|
|
2
|
+
# test suite. You never need to work with it otherwise. Remember that
|
|
3
|
+
# your test database is "scratch space" for the test suite and is wiped
|
|
4
|
+
# and recreated between test runs. Don't rely on the data there!
|
|
5
|
+
|
|
6
|
+
Rails.application.configure do
|
|
7
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
|
8
|
+
|
|
9
|
+
# While tests run files are not watched, reloading is not necessary.
|
|
10
|
+
config.enable_reloading = false
|
|
11
|
+
|
|
12
|
+
# Eager loading loads your entire application. When running a single test locally,
|
|
13
|
+
# this is usually not necessary, and can slow down your test suite. However, it's
|
|
14
|
+
# recommended that you enable it in continuous integration systems to ensure eager
|
|
15
|
+
# loading is working properly before deploying your code.
|
|
16
|
+
config.eager_load = ENV["CI"].present?
|
|
17
|
+
|
|
18
|
+
# Configure public file server for tests with cache-control for performance.
|
|
19
|
+
config.public_file_server.headers = { "cache-control" => "public, max-age=3600" }
|
|
20
|
+
|
|
21
|
+
# Show full error reports.
|
|
22
|
+
config.consider_all_requests_local = true
|
|
23
|
+
config.cache_store = :null_store
|
|
24
|
+
|
|
25
|
+
# Render exception templates for rescuable exceptions and raise for other exceptions.
|
|
26
|
+
config.action_dispatch.show_exceptions = :rescuable
|
|
27
|
+
|
|
28
|
+
# Disable request forgery protection in test environment.
|
|
29
|
+
config.action_controller.allow_forgery_protection = false
|
|
30
|
+
|
|
31
|
+
# Print deprecation notices to the stderr.
|
|
32
|
+
config.active_support.deprecation = :stderr
|
|
33
|
+
|
|
34
|
+
# Raises error for missing translations.
|
|
35
|
+
# config.i18n.raise_on_missing_translations = true
|
|
36
|
+
|
|
37
|
+
# Annotate rendered view with file names.
|
|
38
|
+
# config.action_view.annotate_rendered_view_with_filenames = true
|
|
39
|
+
|
|
40
|
+
# Raise error when a before_action's only/except options reference missing actions.
|
|
41
|
+
config.action_controller.raise_on_missing_callback_actions = true
|
|
42
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Define an application-wide content security policy.
|
|
4
|
+
# See the Securing Rails Applications Guide for more information:
|
|
5
|
+
# https://guides.rubyonrails.org/security.html#content-security-policy-header
|
|
6
|
+
|
|
7
|
+
# Rails.application.configure do
|
|
8
|
+
# config.content_security_policy do |policy|
|
|
9
|
+
# policy.default_src :self, :https
|
|
10
|
+
# policy.font_src :self, :https, :data
|
|
11
|
+
# policy.img_src :self, :https, :data
|
|
12
|
+
# policy.object_src :none
|
|
13
|
+
# policy.script_src :self, :https
|
|
14
|
+
# policy.style_src :self, :https
|
|
15
|
+
# # Specify URI for violation reports
|
|
16
|
+
# # policy.report_uri "/csp-violation-report-endpoint"
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
# # Generate session nonces for permitted importmap, inline scripts, and inline styles.
|
|
20
|
+
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
|
|
21
|
+
# config.content_security_policy_nonce_directives = %w(script-src style-src)
|
|
22
|
+
#
|
|
23
|
+
# # Automatically add `nonce` to `javascript_tag`, `javascript_include_tag`, and `stylesheet_link_tag`
|
|
24
|
+
# # if the corresponding directives are specified in `content_security_policy_nonce_directives`.
|
|
25
|
+
# # config.content_security_policy_nonce_auto = true
|
|
26
|
+
#
|
|
27
|
+
# # Report violations without enforcing the policy.
|
|
28
|
+
# # config.content_security_policy_report_only = true
|
|
29
|
+
# end
|