geo_master_jp 0.1.27 → 0.1.28

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdbb79f24d837f43fc96dc1ddf04fe14bd43d1b234e9928d9e8435f3445f6216
4
- data.tar.gz: 06a43b3aa8e7ac69bc00e1dfc8fa7df61e8f7fff830652be49febcceccf6e901
3
+ metadata.gz: adc8a7e422e37711056c4ddd7712130b61589a1c195b37523dc3d724ffd8a5e9
4
+ data.tar.gz: ed1f046133cf53560bf063eac7077da0e10e6d48673824c54bcef2e37af54211
5
5
  SHA512:
6
- metadata.gz: e994cc5ab019eed3de83acff48524e0cd97f1bb047f1313d816ac2951861a2455fb917af49fe7d2f05ad917295794dc7791f3f7f9a9c72e9ed9b6581c8d3e8ed
7
- data.tar.gz: 355268293ef44ba5a4009cda8a951935b9bede0d82d20f1ac3efcff91d290db9b43ec94bd384e3a4ad62f4b2c8d0b858243e3e99e1254b8bbf878659a89d6c70
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
- self.all.map{|prefecture| [prefecture.name, prefecture.code] }
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module GeoMasterJp
2
- VERSION = '0.1.27'
2
+ VERSION = '0.1.28'
3
3
  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.27
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-29 00:00:00.000000000 Z
11
+ date: 2023-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails