geo_master_jp 0.1.27 → 0.1.28
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adc8a7e422e37711056c4ddd7712130b61589a1c195b37523dc3d724ffd8a5e9
|
4
|
+
data.tar.gz: ed1f046133cf53560bf063eac7077da0e10e6d48673824c54bcef2e37af54211
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccd1b651a6d72e10c34d9224fc700d549efd350df4a7b091b4adaea5be7fbc39d37b0ea4b80e2ea21e82f669db158fa089b2b2fe6585e80e68608d6d1a438b71
|
7
|
+
data.tar.gz: 5ea2374908c016d0ad9709075263889b580e889503d29e924ef8a5a58aea4ebd3da63695a1d10e3afe29d54e1ff79567330a50f2098a2bbf710527e241399f0e
|
@@ -3,6 +3,8 @@ module GeoMasterJp
|
|
3
3
|
def prefectures
|
4
4
|
prefectures = GeoMasterJp::Prefecture.all
|
5
5
|
|
6
|
+
prefectures = GeoMasterJp.config.api.prefectures_filter.call(prefectures) if GeoMasterJp.config.api.prefectures_filter
|
7
|
+
|
6
8
|
render json: {
|
7
9
|
prefectures: prefectures.map{|prefecture|
|
8
10
|
prefecture.as_json(only: [:code, :name, :name_kana, :name_alphabet, :short_name])
|
@@ -20,6 +22,8 @@ module GeoMasterJp
|
|
20
22
|
|
21
23
|
cities = GeoMasterJp::Prefecture.find_by(code: params[:prefecture_code]).cities
|
22
24
|
|
25
|
+
cities = GeoMasterJp.config.api.cities_filter.call(cities) if GeoMasterJp.config.api.cities_filter
|
26
|
+
|
23
27
|
render json: {
|
24
28
|
cities: cities.map{|city|
|
25
29
|
city.as_json(only: [:code, :name, :name_kana, :name_alphabet, :short_name])
|
@@ -37,6 +41,8 @@ module GeoMasterJp
|
|
37
41
|
|
38
42
|
towns = GeoMasterJp::City.find_by(code: params[:city_code]).towns
|
39
43
|
|
44
|
+
towns = GeoMasterJp.config.api.towns_filter.call(towns) if GeoMasterJp.config.api.towns_filter
|
45
|
+
|
40
46
|
render json: {
|
41
47
|
towns: towns.map{|town|
|
42
48
|
town.as_json(only: [:zip_code, :code, :name, :name_kana, :name_alphabet, :short_name])
|
@@ -44,5 +50,9 @@ module GeoMasterJp
|
|
44
50
|
initials: towns.sort_by(&:name_kana).group_by(&:head_kana).sort_by(&:first).to_h
|
45
51
|
}
|
46
52
|
end
|
53
|
+
|
54
|
+
def self.aaa(text)
|
55
|
+
puts text
|
56
|
+
end
|
47
57
|
end
|
48
58
|
end
|
@@ -22,8 +22,8 @@ module GeoMasterJp
|
|
22
22
|
self.cities.map{|city| [city.name, city.code] }
|
23
23
|
end
|
24
24
|
|
25
|
-
def self.select_options
|
26
|
-
|
25
|
+
def self.select_options(transactions=nil)
|
26
|
+
(transactions || all).map{|prefecture| [prefecture.name, prefecture.code] }
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -12,4 +12,14 @@ GeoMasterJp.configure do |config|
|
|
12
12
|
|
13
13
|
# Use Models
|
14
14
|
# config.use_models = [:area, :railway]
|
15
|
+
|
16
|
+
# API Filters
|
17
|
+
# config.api.prefectures_filter = ->(prefectures) {
|
18
|
+
# prefecture_codes = ['11', '12', '13', '14']
|
19
|
+
# prefectures.select { |prefecture| prefecture.code.in?(prefecture_codes) }
|
20
|
+
# }
|
21
|
+
# config.api.cities_filter = ->(cities) {
|
22
|
+
# }
|
23
|
+
# config.api.towns_filter = ->(towns) {
|
24
|
+
# }
|
15
25
|
end
|
data/lib/geo_master_jp/config.rb
CHANGED
@@ -9,15 +9,20 @@ module GeoMasterJp
|
|
9
9
|
|
10
10
|
class Config
|
11
11
|
# Variables detail is writen in lib/generators/templates/geo_master_jp.rb.
|
12
|
-
attr_accessor :alternative_class_names, :use_models
|
12
|
+
attr_accessor :alternative_class_names, :use_models, :api
|
13
13
|
|
14
14
|
def initialize
|
15
15
|
@alternative_class_names = {}
|
16
16
|
@use_models = [:area, :railway]
|
17
|
+
@api = API.new
|
17
18
|
end
|
18
19
|
|
19
20
|
def alternative_class_name(key)
|
20
21
|
@alternative_class_names[key] || "GeoMasterJp::#{key.to_s.camelize}"
|
21
22
|
end
|
23
|
+
|
24
|
+
class API
|
25
|
+
attr_accessor :prefectures_filter, :cities_filter, :towns_filter
|
26
|
+
end
|
22
27
|
end
|
23
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geo_master_jp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ykogure
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11
|
11
|
+
date: 2023-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|