local_gov_code 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e32a02438c316bf7890afb2d59311d2c5513c16e
4
+ data.tar.gz: efe02c0a1641ae5672dc7dc371dd7cec1c4658fa
5
+ SHA512:
6
+ metadata.gz: 267bb89e651dee196996715b5d0e150244f60e810dcd2f5b82e2fe774f11c3b98ae6d5f98c3cab27755d810fdb19b496e56644808161ac64eebc612251f06419
7
+ data.tar.gz: 164e80226576f02e3d79b982957038e25ac5306ff1c4ba3d17981d9d4542a48c46242c278ccba6e5e6a1d12866faa128bf30600577d97b907a417f2a7a94e5d3
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.12.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in local_gov_code.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Hideo NAKAMURA
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # LocalGovCode
2
+
3
+ 全国地方公共団体コード(都道府県コード及び市区町村コード)を収録したgem。
4
+
5
+ データソースは[総務省HP](http://www.soumu.go.jp/denshijiti/code.html)(平成28年5月21日閲覧)。
6
+
7
+ * 都道府県コード及び市区町村コードは平成26年4月5日現在のもの。
8
+
9
+ ## Installation
10
+
11
+ Gemfileに次の1行を加え、
12
+
13
+ gem 'local_gov_code'
14
+
15
+ その後、bundleでインストール。
16
+
17
+ $ bundle
18
+
19
+ あるいは、
20
+
21
+ $ gem install local_gov_code
22
+
23
+ ## Usage
24
+
25
+ LocalGovCodeのインスタンスに対して地方自治体コード(5桁)で問い合わせる(findメソッド)ことで、LocalGovインスタンスが得られます。
26
+
27
+ また、都道府県名+市区町村名や市区町村名で問い合わせる(find_by_fullname, find_by_nameメソッド)と、LocalGovインスタンスの配列が得られます。
28
+
29
+ LocalGovインスタンスからは、市区町村コード、都道府県名、市区町村名、よみなどを取得することが出来ます。
30
+
31
+ require 'local_gov_code'
32
+
33
+ # new ではなく、 instance メソッドを用います。
34
+ local_gov_code = LocalGovCode.instance
35
+
36
+ # 地方自治体コード(5桁)でLocalGovインスタンスを取得
37
+
38
+ lg01000 = local_gov_code.find(1000) # 整数でも可。これは北海道'01000'
39
+ lg47201 = local_gov_code.find('47201') # 文字列でも可
40
+
41
+ # LocalGovインスタンスは、次の情報を持っている。
42
+
43
+ lg01000.code # '01000'
44
+ lg01000.checksum # 0
45
+ lg01000.fullname # '北海道'
46
+ lg01000.prefname # '北海道'
47
+ lg01000.name # ''
48
+ lg01000.prefkana # 'ホッカイドウ'
49
+ lg01000.kana # ''
50
+
51
+ lg47201.code # '47201'
52
+ lg47201.checksum # 8
53
+ lg47201.fullname # '沖縄県那覇市'
54
+ lg47201.prefname # '沖縄県'
55
+ lg47201.name # '那覇市'
56
+ lg47201.prefkana # 'オキナワケン'
57
+ lg47201.kana # 'ナハシ'
58
+
59
+ # 都道府県名+市区町村名だと配列が得られます。
60
+ # 現在は同一都道府県に同一名称の市区町村は複数ありませんので、
61
+ # 配列の要素数はすべて1です。
62
+
63
+ tokyokitaku = local_gov_code.find_by_fullname('東京都北区').first
64
+ tokyokitaku.code # '13117'
65
+
66
+ # 市区町村名だけでも配列が得られます。
67
+
68
+ ikedas = local_gov_code.find_by_name('池田町')
69
+ ikedas.each do |ikeda|
70
+ print ikeda.fullname
71
+ print ' '
72
+ end
73
+ # -> 北海道池田町 福井県池田町 長野県池田町 岐阜県池田町
74
+
75
+ # 政令市は、政令市名のほか政令市+区名でもデータがあります。
76
+ # 例えば、3区ある静岡市の場合は、次の4つのデータが存在します。
77
+ # '22100' 静岡市
78
+ # '22101' 静岡市葵区
79
+ # '22102' 静岡市駿河区
80
+ # '22103' 静岡市清水区
81
+
82
+ # find_by_fullname, find_by_nameは `==` のものを検索します。
83
+
84
+ # すべての地方公共団体を取得することも出来ます。
85
+ # LocalGovインスタンスの配列で、コード順に入っています。
86
+
87
+ all = local_gov_code.all
88
+ all.size = 1963
89
+ all.first.fullname # '北海道'
90
+ all.last.fullname # '沖縄県与那国町'
91
+
92
+ ## Development
93
+
94
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
95
+
96
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
97
+
98
+ ## Contributing
99
+
100
+ Bug reports and pull requests are welcome on GitHub at https://github.com/cxn03651/local_gov_code.
101
+
102
+
103
+ ## License
104
+
105
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "local_gov_code"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here