jp_prefecture 0.11.0 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,78 +0,0 @@
1
- name: Build
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
- pull_request:
8
- types: [opened, synchronize, reopened]
9
-
10
- jobs:
11
- matrix:
12
- runs-on: ubuntu-latest
13
-
14
- strategy:
15
- matrix:
16
- ruby:
17
- - 2.4
18
- - 2.5
19
- - 2.6
20
- - 2.7
21
- gemfile:
22
- - rails42.gemfile
23
- - rails50.gemfile
24
- - rails51.gemfile
25
- - rails52.gemfile
26
- - rails60.gemfile
27
- - rails61.gemfile
28
- exclude:
29
- - ruby: 2.4
30
- gemfile: rails60.gemfile
31
- - ruby: 2.4
32
- gemfile: rails61.gemfile
33
- - ruby: 2.5
34
- gemfile: rails60.gemfile
35
- - ruby: 2.5
36
- gemfile: rails61.gemfile
37
- - ruby: 2.7
38
- gemfile: rails42.gemfile
39
-
40
- env:
41
- CI: true
42
- COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
43
- BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}
44
-
45
- steps:
46
- - uses: actions/checkout@v1
47
-
48
- - name: Setup System
49
- run: |
50
- sudo apt-get update
51
- sudo apt-get install libsqlite3-dev
52
-
53
- - name: Set up Ruby ${{ matrix.ruby }}
54
- uses: eregon/use-ruby-action@master
55
- with:
56
- ruby-version: ${{ matrix.ruby }}
57
-
58
- - name: Build
59
- run: |
60
- gem install bundler
61
- bundle install --jobs 4 --retry 3
62
-
63
- - name: Test
64
- run: |
65
- bundle exec rspec
66
-
67
- - name: Coveralls Parallel
68
- uses: coverallsapp/github-action@master
69
- with:
70
- github-token: ${{ secrets.GITHUB_TOKEN }}
71
- parallel: true
72
- path-to-lcov: ./coverage/lcov.info
73
-
74
- - name: Coveralls Finished
75
- uses: coverallsapp/github-action@master
76
- with:
77
- github-token: ${{ secrets.GITHUB_TOKEN }}
78
- parallel-finished: true
data/.gitignore DELETED
@@ -1,20 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- .ruby-version
7
- Gemfile.lock
8
- InstalledFiles
9
- _yardoc
10
- coverage
11
- doc/
12
- lib/bundler/man
13
- pkg
14
- rdoc
15
- spec/reports
16
- test/tmp
17
- test/version_tmp
18
- tmp
19
- Guardfile
20
- gemfiles/*.lock
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format documentation
data/.yardopts DELETED
@@ -1,2 +0,0 @@
1
- -
2
- CHANGELOG.md
data/Appraisals DELETED
@@ -1,46 +0,0 @@
1
- appraise 'rails32' do
2
- gem 'activerecord', '~> 3.2.0'
3
- gem 'sqlite3', '< 1.4'
4
- end
5
-
6
- appraise 'rails40' do
7
- gem 'activerecord', '~> 4.0.0'
8
- gem 'sqlite3', '< 1.4'
9
- end
10
-
11
- appraise 'rails41' do
12
- gem 'activerecord', '~> 4.1.0'
13
- gem 'sqlite3', '< 1.4'
14
- end
15
-
16
- appraise 'rails42' do
17
- gem 'activerecord', '~> 4.2.0'
18
- gem 'sqlite3', '< 1.4'
19
- end
20
-
21
- if RUBY_VERSION >= '2.2.2'
22
- appraise 'rails50' do
23
- gem 'activerecord', '~> 5.0.0'
24
- gem 'sqlite3', '< 1.4'
25
- end
26
-
27
- appraise 'rails51' do
28
- gem 'activerecord', '~> 5.1.0'
29
- gem 'sqlite3', '< 1.4'
30
- end
31
-
32
- appraise 'rails52' do
33
- gem 'activerecord', '~> 5.2.0'
34
- gem 'sqlite3', '< 1.4'
35
- end
36
- end
37
-
38
- if RUBY_VERSION >= '2.6.0'
39
- appraise 'rails60' do
40
- gem 'activerecord', '~> 6.0.0'
41
- end
42
-
43
- appraise 'rails61' do
44
- gem 'activerecord', '~> 6.1.0'
45
- end
46
- end
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
data/MIT-LICENSE DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2013 chocoby
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/Rakefile DELETED
@@ -1,64 +0,0 @@
1
- #!/usr/bin/env rake
2
- # coding: utf-8
3
- require "bundler/gem_tasks"
4
-
5
- desc 'zip.yml を作成します'
6
- task :create_zips do
7
- require 'csv'
8
- require 'jp_prefecture'
9
-
10
- file_name = 'ken_all_utf8.csv'
11
-
12
- # download files
13
- `wget http://www.post.japanpost.jp/zipcode/dl/kogaki/lzh/ken_all.lzh`
14
- `lha x ken_all.lzh`
15
- `iconv -f sjis -t utf-8 ken_all.csv > #{file_name}`
16
- `rm ken_all.lzh`
17
- `rm ken_all.csv`
18
-
19
- zips = []
20
-
21
- # read CSV
22
- CSV.foreach(file_name, headers: false) { |line| zips << [line[2], line[6]] }
23
-
24
- # create sorted list of zips -> prefecture_code
25
- zips = zips
26
- .collect { |zip, prefecture| [zip.to_i, JpPrefecture::Prefecture.find(name: prefecture).code] }
27
- .sort{ |x, y| x[0] <=> y[0] }
28
-
29
- # prepare calculation
30
- ranged_zips = []
31
- current = [ zips.first[0], zips.first[0], zips.first[1] ]
32
-
33
- # calculate the zip ranges of each prefecture
34
- zips.each do |zip, code|
35
- if current[2] == code
36
- current[1] = zip
37
- else
38
- ranged_zips << current
39
- current = [zip, zip, code]
40
- end
41
- end
42
-
43
- # add last prefecture
44
- ranged_zips << current
45
-
46
- # create prefecture hash
47
- prefectures_to_zip = {}
48
-
49
- ranged_zips.each do |r0, r1, code|
50
- prefectures_to_zip[code] ||= []
51
- prefectures_to_zip[code] << [r0, r1]
52
- end
53
-
54
- prefectures_to_zip = Hash[*prefectures_to_zip.sort.flatten(1)]
55
-
56
- # save result
57
- File.open('data/zip.yml', 'w') do |file|
58
- file.write "# { prefecture_code: [[from_zip_1, to_zip_1], [from_zip_2, to_zip_2], ...], ... }\n"
59
- file.write prefectures_to_zip.to_yaml
60
- end
61
-
62
- # delete temporary file
63
- `rm #{file_name}`
64
- end
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 3.2.0"
6
- gem "sqlite3", "< 1.4"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.0.0"
6
- gem "sqlite3", "< 1.4"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.1.0"
6
- gem "sqlite3", "< 1.4"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.2.0"
6
- gem "sqlite3", "< 1.4"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 5.0.0"
6
- gem "sqlite3", "< 1.4"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 5.1.0"
6
- gem "sqlite3", "< 1.4"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 5.2.0"
6
- gem "sqlite3", "< 1.4"
7
-
8
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 6.0.0"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 6.1.0"
6
-
7
- gemspec path: "../"
@@ -1,26 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/jp_prefecture/version', __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.authors = ['chocoby']
6
- gem.email = ['chocoby@gmail.com']
7
- gem.summary = %q{Convert japan prefecture code into prefecture name}
8
- gem.description = %q{Convert japan prefecture code(JIS X 0402 based) into prefecture name.}
9
- gem.homepage = 'https://github.com/chocoby/jp_prefecture'
10
- gem.license = 'MIT'
11
-
12
- gem.files = `git ls-files`.split($\)
13
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
- gem.name = 'jp_prefecture'
16
- gem.require_paths = ['lib']
17
- gem.version = JpPrefecture::VERSION
18
-
19
- gem.add_development_dependency 'rake'
20
- gem.add_development_dependency 'rspec'
21
- gem.add_development_dependency 'activerecord', '>= 4.2.0'
22
- gem.add_development_dependency 'sqlite3'
23
- gem.add_development_dependency 'simplecov'
24
- gem.add_development_dependency 'simplecov-lcov'
25
- gem.add_development_dependency 'appraisal'
26
- end
data/spec/base_spec.rb DELETED
@@ -1,81 +0,0 @@
1
- # coding: utf-8
2
- require 'spec_helper'
3
-
4
- describe JpPrefecture::Base do
5
- describe '#jp_prefecture' do
6
- describe 'カラム名の指定について' do
7
- context 'prefecture_code を指定した場合' do
8
- let(:model_class) do
9
- klass = Class.new(ActiveRecord::Base) do
10
- self.table_name = :places
11
- include JpPrefecture
12
- jp_prefecture :prefecture_code
13
- end
14
-
15
- klass.new(prefecture_code: 1)
16
- end
17
-
18
- it 'prefecture_code のコードが変換できること' do
19
- expect(model_class.prefecture.name).to eq '北海道'
20
- end
21
- end
22
-
23
- context 'prefecture_id を指定した場合' do
24
- let(:model_class) do
25
- klass = Class.new(ActiveRecord::Base) do
26
- self.table_name = :places
27
- include JpPrefecture
28
- jp_prefecture :prefecture_id
29
- end
30
-
31
- klass.new(prefecture_id: 1)
32
- end
33
-
34
- it 'prefecture_id のコードが変換できること' do
35
- expect(model_class.prefecture.name).to eq '北海道'
36
- end
37
- end
38
- end
39
-
40
- describe '生成するメソッド名の指定について' do
41
- context 'prefecture_method を指定した場合' do
42
- let(:model_class) do
43
- klass = Class.new(ActiveRecord::Base) do
44
- self.table_name = :places
45
- include JpPrefecture
46
- jp_prefecture :prefecture_code, method_name: :prefecture_method
47
- end
48
-
49
- klass.new(prefecture_code: 1)
50
- end
51
-
52
- it 'prefecture_method で結果が参照できること' do
53
- expect(model_class.prefecture_method.name).to eq '北海道'
54
- end
55
- end
56
- end
57
-
58
- describe '都道府県の検索について' do
59
- let(:klass) do
60
- Class.new(ActiveRecord::Base) do
61
- self.table_name = :places
62
- include JpPrefecture
63
- jp_prefecture :prefecture_code
64
- end
65
- end
66
-
67
- context '都道府県が見つかった場合' do
68
- let(:model_class) { klass.new(prefecture_code: 1) }
69
- it { expect(model_class).to respond_to(:prefecture) }
70
- it { expect(model_class.prefecture).to be_an_instance_of(JpPrefecture::Prefecture) }
71
- it { expect(model_class.prefecture.name).to eq '北海道' }
72
- end
73
-
74
- context '都道府県が見つからなかった場合' do
75
- let(:model_class) { klass.new(prefecture_code: 99) }
76
- it { expect(model_class).to respond_to(:prefecture) }
77
- it { expect(model_class.prefecture).to be_nil }
78
- end
79
- end
80
- end
81
- end