jp_prefectures_tools 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +68 -0
- data/Rakefile +7 -0
- data/jp_prefectures_tools.gemspec +23 -0
- data/lib/jp_prefectures_tools.rb +85 -0
- data/lib/jp_prefectures_tools/version.rb +3 -0
- data/spec/jp_prefectures_tools_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 01f54249b245b7724da9ee97c5385dfc0880ff3e
|
4
|
+
data.tar.gz: 45a1ae3b42157294dfcfdc0019ee9bfa7fc60475
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 75ec523c00360d87983de2e33d2b0cbdce0ae55431e6921c4326b96f60fc8bf63109a9176e350c038ac4a5abb5586840b6c10a4485120d21195167dd474bdd65
|
7
|
+
data.tar.gz: 01c6fec8287f02930a094947520e59392c73ef49e66fdfdf0b9406b77103fb1c564993160d92450bd73a7b2124c80dbc9f57d05c7a13f84d507d699756acd7b7
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Takuya Mukohira
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# JpPrefecturesTools
|
2
|
+
|
3
|
+
This is a tools of prefectures of Japan.
|
4
|
+
|
5
|
+
## インストール
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'jp_prefectures_tools'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install jp_prefectures_tools
|
18
|
+
|
19
|
+
## 使い方
|
20
|
+
### ライブラリの読み込み
|
21
|
+
```ruby
|
22
|
+
require 'jp_prefectures_tools'
|
23
|
+
```
|
24
|
+
|
25
|
+
#### 都道府県名から県庁所在地名を取得
|
26
|
+
|
27
|
+
JpPrefecturesTools::prefecture_name_to_city_name を使う。
|
28
|
+
|
29
|
+
```
|
30
|
+
# 都道府県名を渡すと県庁所在地名が返ってくる。
|
31
|
+
JpPrefecturesTools::prefecture_name_to_city_name("北海道")
|
32
|
+
=> "札幌"
|
33
|
+
|
34
|
+
# 都, 道, 府, 県は省略してもOK
|
35
|
+
JpPrefecturesTools::prefecture_name_to_city_name("千葉")
|
36
|
+
=> "千葉"
|
37
|
+
|
38
|
+
# 都道府県名じゃない文字列を渡すと、 nil を返す。
|
39
|
+
JpPrefecturesTools::prefecture_name_to_city_name("うどん県")
|
40
|
+
=> nil
|
41
|
+
```
|
42
|
+
|
43
|
+
#### 県庁所在地名から都道府県名を取得
|
44
|
+
|
45
|
+
JpPrefecturesTools::city_name_to_prefecture_name を使う。
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# 県庁所在地名を入れると都道府県名が返ってくる。
|
49
|
+
JpPrefecturesTools::city_name_to_prefecture_name("那覇市")
|
50
|
+
=> "沖縄県"
|
51
|
+
|
52
|
+
# '市'は省略してもOK
|
53
|
+
JpPrefecturesTools::city_name_to_prefecture_name("札幌")
|
54
|
+
=> "北海道"
|
55
|
+
|
56
|
+
# 県庁所在地名じゃない文字列を渡すと、 nil を返す。
|
57
|
+
JpPrefecturesTools::city_name_to_prefecture_name("千歳市")
|
58
|
+
=> nil
|
59
|
+
```
|
60
|
+
|
61
|
+
|
62
|
+
## Contributing
|
63
|
+
|
64
|
+
1. Fork it ( https://github.com/[my-github-username]/jp_prefectures_tools/fork )
|
65
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
66
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
67
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
68
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jp_prefectures_tools/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jp_prefectures_tools"
|
8
|
+
spec.version = JpPrefecturesTools::VERSION
|
9
|
+
spec.authors = ["Takuya Mukohira"]
|
10
|
+
spec.email = ["takuya.mk96@gmail.com"]
|
11
|
+
spec.summary = %q{This is a tools of prefectures of Japan.}
|
12
|
+
spec.homepage = "https://github.com/lo-upe/jp_prefectures_tools"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "rspec"
|
23
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require "jp_prefectures_tools/version"
|
2
|
+
|
3
|
+
module JpPrefecturesTools
|
4
|
+
@prefectures = {
|
5
|
+
"北海道"=>"札幌",
|
6
|
+
"青森県"=>"青森",
|
7
|
+
"岩手県"=>"盛岡",
|
8
|
+
"宮城県"=>"仙台",
|
9
|
+
"秋田県"=>"秋田",
|
10
|
+
"山形県"=>"山形",
|
11
|
+
"福島県"=>"福島",
|
12
|
+
"茨城県"=>"水戸",
|
13
|
+
"栃木県"=>"宇都宮",
|
14
|
+
"群馬県"=>"前橋",
|
15
|
+
"埼玉県"=>"さいたま",
|
16
|
+
"千葉県"=>"千葉",
|
17
|
+
"東京都"=>"東京",
|
18
|
+
"神奈川県"=>"横浜",
|
19
|
+
"新潟県"=>"新潟",
|
20
|
+
"富山県"=>"富山",
|
21
|
+
"石川県"=>"金沢",
|
22
|
+
"福井県"=>"福井",
|
23
|
+
"山梨県"=>"甲府",
|
24
|
+
"長野県"=>"長野",
|
25
|
+
"岐阜県"=>"岐阜",
|
26
|
+
"静岡県"=>"静岡",
|
27
|
+
"愛知県"=>"名古屋",
|
28
|
+
"三重県"=>"津",
|
29
|
+
"滋賀県"=>"大津",
|
30
|
+
"京都府"=>"京都",
|
31
|
+
"大阪府"=>"大阪",
|
32
|
+
"兵庫県"=>"神戸",
|
33
|
+
"奈良県"=>"奈良",
|
34
|
+
"和歌山県"=>"和歌山",
|
35
|
+
"鳥取県"=>"鳥取",
|
36
|
+
"島根県"=>"松江",
|
37
|
+
"岡山県"=>"岡山",
|
38
|
+
"広島県"=>"広島",
|
39
|
+
"山口県"=>"山口",
|
40
|
+
"徳島県"=>"徳島",
|
41
|
+
"香川県"=>"高松",
|
42
|
+
"愛媛県"=>"松山",
|
43
|
+
"高知県"=>"高知",
|
44
|
+
"福岡県"=>"福岡",
|
45
|
+
"佐賀県"=>"佐賀",
|
46
|
+
"長崎県"=>"長崎",
|
47
|
+
"熊本県"=>"熊本",
|
48
|
+
"大分県"=>"大分",
|
49
|
+
"宮崎県"=>"宮崎",
|
50
|
+
"鹿児島県"=>"鹿児島",
|
51
|
+
"沖縄県"=>"那覇"
|
52
|
+
}
|
53
|
+
|
54
|
+
def self.prefecture_name_to_city_name(prefecture_name)
|
55
|
+
unless prefecture_name.match(/[都道府県]$/)
|
56
|
+
case prefecture_name
|
57
|
+
when "東京"
|
58
|
+
prefecture_name += "都"
|
59
|
+
|
60
|
+
when "北海"
|
61
|
+
prefecture_name += "道"
|
62
|
+
|
63
|
+
when "大阪"
|
64
|
+
prefecture_name += "府"
|
65
|
+
|
66
|
+
else
|
67
|
+
prefecture_name += "県"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
prefecture_name += "府" if prefecture_name == "京都"
|
71
|
+
|
72
|
+
return @prefectures[prefecture_name]
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.city_name_to_prefecture_name(city_name)
|
76
|
+
city_name.chop! if city_name.match(/市$/)
|
77
|
+
|
78
|
+
@prefectures.each do |key, value|
|
79
|
+
if value == city_name
|
80
|
+
return key
|
81
|
+
end
|
82
|
+
end
|
83
|
+
return nil
|
84
|
+
end
|
85
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jp_prefectures_tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Takuya Mukohira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-18 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.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '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: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- takuya.mk96@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- jp_prefectures_tools.gemspec
|
70
|
+
- lib/jp_prefectures_tools.rb
|
71
|
+
- lib/jp_prefectures_tools/version.rb
|
72
|
+
- spec/jp_prefectures_tools_spec.rb
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
homepage: https://github.com/lo-upe/jp_prefectures_tools
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.2.2
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: This is a tools of prefectures of Japan.
|
98
|
+
test_files:
|
99
|
+
- spec/jp_prefectures_tools_spec.rb
|
100
|
+
- spec/spec_helper.rb
|