jp_city_code 0.0.1

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.
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jp_city_code/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jp_city_code"
8
+ spec.version = JpCityCode::VERSION
9
+ spec.authors = ["sakura1116"]
10
+ spec.email = ["sakura1116@gmail.com"]
11
+
12
+ spec.summary = %q{JP-CITY-CODE.}
13
+ spec.description = %q{JP-CITY-CODE.}
14
+ spec.homepage = "https://github.com/sakura1116"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.12"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ end
@@ -0,0 +1,13 @@
1
+ # coding: utf-8
2
+ require "jp_city_code/version"
3
+ require "jp_city_code/city_code"
4
+ require "jp_city_code/config"
5
+
6
+ module JpCityCode
7
+ @config = Config.new
8
+
9
+ def self.config
10
+ @config
11
+ end
12
+
13
+ end
@@ -0,0 +1,26 @@
1
+ require "jp_city_code/mapping"
2
+ module JpCityCode
3
+ class CityCode
4
+ attr_accessor :city_code, :prefecture_name, :city_name, :prefecture_name_k, :city_name_k
5
+
6
+ def self.build(city_code, prefecture_name, city_name, prefecture_name_k, city_name_k)
7
+ city = self.new
8
+ city.city_code = city_code
9
+ city.prefecture_name = prefecture_name
10
+ city.city_name = city_name
11
+ city.prefecture_name_k = prefecture_name_k
12
+ city.city_name_k = city_name_k
13
+
14
+ city
15
+ end
16
+
17
+ def self.find(city_code)
18
+ return if city_code.nil?
19
+ return unless city_code.is_a?(String)
20
+ ret = Mapping.data[city_code]
21
+ return unless ret
22
+
23
+ self.build(ret[:city_code], ret[:prefecture_name], ret[:city_name], ret[:prefecture_name_k], ret[:city_name_k])
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ module JpCityCode
2
+ class Config
3
+ attr_accessor :mapping_data
4
+ end
5
+ end
6
+
@@ -0,0 +1,13 @@
1
+ require 'yaml'
2
+
3
+ module JpCityCode
4
+ module Mapping
5
+
6
+ filepath = File.join(File.dirname(__FILE__), '../../data/city_code.yml')
7
+ @data = YAML.load_file(filepath)
8
+
9
+ def self.data
10
+ JpCityCode.config.mapping_data || @data
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module JpCityCode
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jp_city_code
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - sakura1116
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-08-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: JP-CITY-CODE.
56
+ email:
57
+ - sakura1116@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".idea/vcs.xml"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - CODE_OF_CONDUCT.md
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - bin/console
72
+ - bin/setup
73
+ - data/city_code.yml
74
+ - jp_city_code.gemspec
75
+ - lib/jp_city_code.rb
76
+ - lib/jp_city_code/city_code.rb
77
+ - lib/jp_city_code/config.rb
78
+ - lib/jp_city_code/mapping.rb
79
+ - lib/jp_city_code/version.rb
80
+ homepage: https://github.com/sakura1116
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.4.5
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: JP-CITY-CODE.
104
+ test_files: []