ken_all 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +24 -0
- data/Gemfile.lock +122 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +36 -0
- data/Rakefile +27 -0
- data/app/assets/javascripts/ken_all/application.js +15 -0
- data/app/assets/stylesheets/ken_all/application.css +13 -0
- data/app/controllers/ken_all/application_controller.rb +4 -0
- data/app/helpers/ken_all/application_helper.rb +4 -0
- data/app/models/ken_all/postal_code.rb +7 -0
- data/app/views/layouts/ken_all/application.html.erb +14 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20121028092517_create_ken_all_postal_codes.rb +14 -0
- data/lib/ken_all.rb +12 -0
- data/lib/ken_all/engine.rb +9 -0
- data/lib/ken_all/import.rb +81 -0
- data/lib/ken_all/merge_box.rb +33 -0
- data/lib/ken_all/post.rb +38 -0
- data/lib/ken_all/version.rb +3 -0
- data/lib/ken_all/visualizer.rb +74 -0
- data/lib/tasks/ken_all_tasks.rake +21 -0
- metadata +168 -0
data/Gemfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in ken_all.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# jquery-rails is used by the dummy application
|
9
|
+
gem "jquery-rails"
|
10
|
+
|
11
|
+
# Declare any dependencies that are still in development here instead of in
|
12
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
13
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
14
|
+
# your gem to rubygems.org.
|
15
|
+
|
16
|
+
# To use debugger
|
17
|
+
# gem 'debugger'
|
18
|
+
gem 'zipruby'
|
19
|
+
gem 'activerecord-import'
|
20
|
+
|
21
|
+
group :test do
|
22
|
+
gem 'rspec-rails'
|
23
|
+
gem 'rr', "~> 1.0.0"
|
24
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ken_all (0.1.6)
|
5
|
+
activerecord-import (~> 0.2.11)
|
6
|
+
rails (>= 3.0.9)
|
7
|
+
zipruby
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionmailer (3.2.8)
|
13
|
+
actionpack (= 3.2.8)
|
14
|
+
mail (~> 2.4.4)
|
15
|
+
actionpack (3.2.8)
|
16
|
+
activemodel (= 3.2.8)
|
17
|
+
activesupport (= 3.2.8)
|
18
|
+
builder (~> 3.0.0)
|
19
|
+
erubis (~> 2.7.0)
|
20
|
+
journey (~> 1.0.4)
|
21
|
+
rack (~> 1.4.0)
|
22
|
+
rack-cache (~> 1.2)
|
23
|
+
rack-test (~> 0.6.1)
|
24
|
+
sprockets (~> 2.1.3)
|
25
|
+
activemodel (3.2.8)
|
26
|
+
activesupport (= 3.2.8)
|
27
|
+
builder (~> 3.0.0)
|
28
|
+
activerecord (3.2.8)
|
29
|
+
activemodel (= 3.2.8)
|
30
|
+
activesupport (= 3.2.8)
|
31
|
+
arel (~> 3.0.2)
|
32
|
+
tzinfo (~> 0.3.29)
|
33
|
+
activerecord-import (0.2.11)
|
34
|
+
activerecord (~> 3.0)
|
35
|
+
activerecord (~> 3.0)
|
36
|
+
activeresource (3.2.8)
|
37
|
+
activemodel (= 3.2.8)
|
38
|
+
activesupport (= 3.2.8)
|
39
|
+
activesupport (3.2.8)
|
40
|
+
i18n (~> 0.6)
|
41
|
+
multi_json (~> 1.0)
|
42
|
+
arel (3.0.2)
|
43
|
+
builder (3.0.4)
|
44
|
+
diff-lcs (1.1.3)
|
45
|
+
erubis (2.7.0)
|
46
|
+
hike (1.2.1)
|
47
|
+
i18n (0.6.1)
|
48
|
+
journey (1.0.4)
|
49
|
+
jquery-rails (2.1.3)
|
50
|
+
railties (>= 3.1.0, < 5.0)
|
51
|
+
thor (~> 0.14)
|
52
|
+
json (1.7.5)
|
53
|
+
mail (2.4.4)
|
54
|
+
i18n (>= 0.4.0)
|
55
|
+
mime-types (~> 1.16)
|
56
|
+
treetop (~> 1.4.8)
|
57
|
+
mime-types (1.19)
|
58
|
+
multi_json (1.3.7)
|
59
|
+
polyglot (0.3.3)
|
60
|
+
rack (1.4.1)
|
61
|
+
rack-cache (1.2)
|
62
|
+
rack (>= 0.4)
|
63
|
+
rack-ssl (1.3.2)
|
64
|
+
rack
|
65
|
+
rack-test (0.6.2)
|
66
|
+
rack (>= 1.0)
|
67
|
+
rails (3.2.8)
|
68
|
+
actionmailer (= 3.2.8)
|
69
|
+
actionpack (= 3.2.8)
|
70
|
+
activerecord (= 3.2.8)
|
71
|
+
activeresource (= 3.2.8)
|
72
|
+
activesupport (= 3.2.8)
|
73
|
+
bundler (~> 1.0)
|
74
|
+
railties (= 3.2.8)
|
75
|
+
railties (3.2.8)
|
76
|
+
actionpack (= 3.2.8)
|
77
|
+
activesupport (= 3.2.8)
|
78
|
+
rack-ssl (~> 1.3.2)
|
79
|
+
rake (>= 0.8.7)
|
80
|
+
rdoc (~> 3.4)
|
81
|
+
thor (>= 0.14.6, < 2.0)
|
82
|
+
rake (0.9.2.2)
|
83
|
+
rdoc (3.12)
|
84
|
+
json (~> 1.4)
|
85
|
+
rr (1.0.4)
|
86
|
+
rspec (2.11.0)
|
87
|
+
rspec-core (~> 2.11.0)
|
88
|
+
rspec-expectations (~> 2.11.0)
|
89
|
+
rspec-mocks (~> 2.11.0)
|
90
|
+
rspec-core (2.11.1)
|
91
|
+
rspec-expectations (2.11.3)
|
92
|
+
diff-lcs (~> 1.1.3)
|
93
|
+
rspec-mocks (2.11.3)
|
94
|
+
rspec-rails (2.11.4)
|
95
|
+
actionpack (>= 3.0)
|
96
|
+
activesupport (>= 3.0)
|
97
|
+
railties (>= 3.0)
|
98
|
+
rspec (~> 2.11.0)
|
99
|
+
sprockets (2.1.3)
|
100
|
+
hike (~> 1.2)
|
101
|
+
rack (~> 1.0)
|
102
|
+
tilt (~> 1.1, != 1.3.0)
|
103
|
+
sqlite3 (1.3.6)
|
104
|
+
thor (0.16.0)
|
105
|
+
tilt (1.3.3)
|
106
|
+
treetop (1.4.12)
|
107
|
+
polyglot
|
108
|
+
polyglot (>= 0.3.1)
|
109
|
+
tzinfo (0.3.35)
|
110
|
+
zipruby (0.3.6)
|
111
|
+
|
112
|
+
PLATFORMS
|
113
|
+
ruby
|
114
|
+
|
115
|
+
DEPENDENCIES
|
116
|
+
activerecord-import
|
117
|
+
jquery-rails
|
118
|
+
ken_all!
|
119
|
+
rr (~> 1.0.0)
|
120
|
+
rspec-rails
|
121
|
+
sqlite3
|
122
|
+
zipruby
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 Yamamoto Kazuhisa
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
= ken_all
|
2
|
+
|
3
|
+
半分ジョーク、半分マジなrails用郵便番号データ活用ツールです
|
4
|
+
|
5
|
+
== How to use.
|
6
|
+
|
7
|
+
(1) Gemfileに追加
|
8
|
+
gem "ken_all"
|
9
|
+
|
10
|
+
(2) 使い方
|
11
|
+
$ rake ken_all:install:migrations #migrationファイルをプロジェクトに作成
|
12
|
+
$ rake db:migrate #テーブルの作成
|
13
|
+
$ rake ken_all:import #郵便番号の取込
|
14
|
+
|
15
|
+
取り込んだデータはKenAll::PostalCodeで使用することができます。
|
16
|
+
|
17
|
+
(3) 郵便番号について
|
18
|
+
郵便番号は日本郵便のページ(http://www.japanpost.jp)からダウンロードされます。
|
19
|
+
そのままでは使いにくいので次の処理を行なっています。
|
20
|
+
・address3に「以下に掲載がない場合」が設定されている場合は空文字列に置換します。
|
21
|
+
・address3に「境町の次に番地がくる場合」が設定されている場合は空文字列に置換します。
|
22
|
+
・address3に「〜一円」が設定されている場合は空文字列に置換します。ただし、一円という地名は除きます。
|
23
|
+
・複数行にまたがる場合は1レコードに集約します。
|
24
|
+
|
25
|
+
zip cloudさん(http://zipcloud.ibsnet.co.jp)と同等の処理をしたかったのですが、ちょっと手が届きませんでした。
|
26
|
+
|
27
|
+
(3) Options
|
28
|
+
$ rake ken_all:import:silent #静かに取込を行います
|
29
|
+
$ rake ken_all:import:file FILE=/path/to/x-ken-all.csv #外部のファイルから取り込みます(*)
|
30
|
+
|
31
|
+
* zip cloudさん(http://zipcloud.ibsnet.co.jp)の加工済みバージョンを利用すると良いです
|
32
|
+
|
33
|
+
== Copyright
|
34
|
+
|
35
|
+
Copyright (c) 2012 Yamamoto Kazuhisa. See MIT-LICENSE for
|
36
|
+
further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'KenAll'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>KenAll</title>
|
5
|
+
<%= stylesheet_link_tag "ken_all/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "ken_all/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateKenAllPostalCodes < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :ken_all_postal_codes do |t|
|
4
|
+
t.string :code
|
5
|
+
t.string :address1
|
6
|
+
t.string :address2
|
7
|
+
t.string :address3
|
8
|
+
t.string :address_kana1
|
9
|
+
t.string :address_kana2
|
10
|
+
t.string :address_kana3
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/ken_all.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'tempfile'
|
4
|
+
require 'zipruby'
|
5
|
+
require 'csv'
|
6
|
+
require 'curses'
|
7
|
+
require 'activerecord-import'
|
8
|
+
require 'ken_all/visualizer'
|
9
|
+
require 'ken_all/engine'
|
10
|
+
require 'ken_all/import'
|
11
|
+
require 'ken_all/merge_box'
|
12
|
+
require 'ken_all/post'
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module KenAll
|
4
|
+
class Import
|
5
|
+
URI = "http://www.post.japanpost.jp/zipcode/dl/kogaki/zip/ken_all.zip"
|
6
|
+
|
7
|
+
def initialize(opt = {visualize: true})
|
8
|
+
@visualizer = KenAll::Visualizer.new(opt[:visualize])
|
9
|
+
end
|
10
|
+
|
11
|
+
def from_net
|
12
|
+
@visualizer.screen_init do
|
13
|
+
Tempfile.open("ken_all.zip") do |f|
|
14
|
+
download_file(f)
|
15
|
+
csv = zip_to_csv(f)
|
16
|
+
import_model(csv)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def from_file
|
22
|
+
if ENV["FILE"].present?
|
23
|
+
CSV.open(ENV["FILE"],:encoding => "Shift_JIS:UTF-8") do |csv|
|
24
|
+
import_model(csv)
|
25
|
+
end
|
26
|
+
else
|
27
|
+
puts "Specify FILE arguments."
|
28
|
+
puts "rake ken_all:import:file FILE=/path/to/x-ken-all.csv"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def download_file(file)
|
33
|
+
@visualizer.download_status do
|
34
|
+
file.binmode
|
35
|
+
open(URI, 'rb') do |read_file|
|
36
|
+
file.write(read_file.read)
|
37
|
+
end
|
38
|
+
file.rewind
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def zip_to_csv(zip_file)
|
43
|
+
csv = nil
|
44
|
+
@visualizer.unzip_status do
|
45
|
+
Zip::Archive.open_buffer(zip_file.read) do |ar|
|
46
|
+
ar.fopen(ar.get_name(0)) do |file|
|
47
|
+
csv = CSV.parse(file.read.encode("utf-8","sjis"))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
csv
|
52
|
+
end
|
53
|
+
|
54
|
+
def import_model(csv)
|
55
|
+
@visualizer.import_status do
|
56
|
+
ActiveRecord::Base.transaction do
|
57
|
+
header = [:code, :address1, :address2, :address3, :address_kana1, :address_kana2, :address_kana3]
|
58
|
+
list = []
|
59
|
+
merge = MergeBox.new
|
60
|
+
csv.each do |row|
|
61
|
+
post = Post.new(row)
|
62
|
+
if post.adr_start?
|
63
|
+
merge.add(post)
|
64
|
+
elsif post.adr_end?
|
65
|
+
merge.add(post)
|
66
|
+
list << merge.to_array
|
67
|
+
merge.clear
|
68
|
+
next
|
69
|
+
elsif merge.count > 0
|
70
|
+
merge.add(post)
|
71
|
+
else
|
72
|
+
list << post.to_array
|
73
|
+
end
|
74
|
+
end
|
75
|
+
KenAll::PostalCode.delete_all
|
76
|
+
KenAll::PostalCode.import(header, list)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module KenAll
|
4
|
+
class MergeBox
|
5
|
+
def initialize
|
6
|
+
@list = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def add(post)
|
10
|
+
@list << post
|
11
|
+
end
|
12
|
+
|
13
|
+
def clear
|
14
|
+
@list = []
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_array
|
18
|
+
post = Post.new
|
19
|
+
post.code = @list[0].code
|
20
|
+
post.address1 = @list[0].address1
|
21
|
+
post.address2 = @list[0].address2
|
22
|
+
post.address3 = @list.inject(""){|str,v| str += v.address3}
|
23
|
+
post.address_kana1 = @list[0].address_kana1
|
24
|
+
post.address_kana2 = @list[0].address_kana2
|
25
|
+
post.address_kana3 = @list.inject(""){|str,v| str += v.address_kana3}
|
26
|
+
post.to_array
|
27
|
+
end
|
28
|
+
|
29
|
+
def count
|
30
|
+
@list.count
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/ken_all/post.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module KenAll
|
4
|
+
class Post
|
5
|
+
NOT_FOUND = /^以下に掲載がない場合$/
|
6
|
+
NEXT_ADDRESS = /^境町の次に番地がくる場合$/
|
7
|
+
WHOLE_PLACE = /.+一円$/
|
8
|
+
|
9
|
+
attr_accessor :code, :address1, :address2, :address3, :address_kana1, :address_kana2, :address_kana3
|
10
|
+
def initialize(row = nil)
|
11
|
+
unless row.nil?
|
12
|
+
self.code = row[2]
|
13
|
+
self.address1 = row[6]
|
14
|
+
self.address2 = row[7]
|
15
|
+
self.address3 = row[8]
|
16
|
+
self.address_kana1 = row[3]
|
17
|
+
self.address_kana2 = row[4]
|
18
|
+
self.address_kana3 = row[5]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def adr_start?
|
23
|
+
(self.address3 =~ /(/ && !(self.address3 =~ /)/)) || (self.address_kana3 =~ /\(/ && !(self.address_kana3 =~ /\)/))
|
24
|
+
end
|
25
|
+
|
26
|
+
def adr_end?
|
27
|
+
(!(self.address3 =~ /(/) && self.address3 =~ /)/) || (!(self.address_kana3 =~ /\(/) && self.address_kana3 =~ /\)/)
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_array
|
31
|
+
if self.address3 =~ NOT_FOUND || self.address3 =~ NEXT_ADDRESS || self.address3 =~ WHOLE_PLACE
|
32
|
+
self.address3 = ""
|
33
|
+
self.address_kana3 = ""
|
34
|
+
end
|
35
|
+
[self.code, self.address1, self.address2, self.address3, self.address_kana1, self.address_kana2, self.address_kana3]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module KenAll
|
4
|
+
class Visualizer
|
5
|
+
RED = 1
|
6
|
+
GREEN = 2
|
7
|
+
|
8
|
+
def initialize(visualize = true)
|
9
|
+
@visualize = visualize
|
10
|
+
end
|
11
|
+
|
12
|
+
def screen_init
|
13
|
+
if @visualize
|
14
|
+
Curses.init_screen
|
15
|
+
Curses.start_color
|
16
|
+
Curses.init_pair RED, Curses::COLOR_RED, Curses::COLOR_BLACK
|
17
|
+
Curses.init_pair GREEN, Curses::COLOR_GREEN, Curses::COLOR_BLACK
|
18
|
+
|
19
|
+
Curses.setpos(0, 1)
|
20
|
+
Curses.attrset(Curses.color_pair(GREEN))
|
21
|
+
Curses.addstr("******** KEN_ALL ********")
|
22
|
+
|
23
|
+
Curses.setpos(1, 1)
|
24
|
+
Curses.attrset(Curses.color_pair(GREEN))
|
25
|
+
Curses.addstr("Welcome to amazing world.")
|
26
|
+
|
27
|
+
Curses.setpos(2, 1)
|
28
|
+
Curses.attrset(Curses.color_pair(RED))
|
29
|
+
Curses.addstr("+download")
|
30
|
+
Curses.setpos(3, 1)
|
31
|
+
Curses.attrset(Curses.color_pair(RED))
|
32
|
+
Curses.addstr("+unzip")
|
33
|
+
Curses.setpos(4, 1)
|
34
|
+
Curses.attrset(Curses.color_pair(RED))
|
35
|
+
Curses.addstr("+import")
|
36
|
+
|
37
|
+
Curses.setpos(5, 1)
|
38
|
+
Curses.attrset(Curses.color_pair(GREEN))
|
39
|
+
Curses.addstr("*************************")
|
40
|
+
Curses.refresh
|
41
|
+
end
|
42
|
+
yield
|
43
|
+
ensure
|
44
|
+
Curses.close_screen if @visualize
|
45
|
+
end
|
46
|
+
|
47
|
+
def download_status
|
48
|
+
yield
|
49
|
+
return unless @visualize
|
50
|
+
Curses.setpos(2, 1)
|
51
|
+
Curses.attrset(Curses.color_pair(GREEN))
|
52
|
+
Curses.addstr("+download")
|
53
|
+
Curses.refresh
|
54
|
+
end
|
55
|
+
|
56
|
+
def unzip_status
|
57
|
+
yield
|
58
|
+
return unless @visualize
|
59
|
+
Curses.setpos(3, 1)
|
60
|
+
Curses.attrset(Curses.color_pair(GREEN))
|
61
|
+
Curses.addstr("+unzip")
|
62
|
+
Curses.refresh
|
63
|
+
end
|
64
|
+
|
65
|
+
def import_status
|
66
|
+
yield
|
67
|
+
return unless @visualize
|
68
|
+
Curses.setpos(4, 1)
|
69
|
+
Curses.attrset(Curses.color_pair(GREEN))
|
70
|
+
Curses.addstr("+import")
|
71
|
+
Curses.refresh
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
namespace :ken_all do
|
2
|
+
desc "Download & Import KEN_ALL"
|
3
|
+
task :import => :environment do
|
4
|
+
import = KenAll::Import.new
|
5
|
+
import.from_net
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :import do
|
9
|
+
desc "Silent Download & Import KEN_ALL"
|
10
|
+
task :silent => :environment do
|
11
|
+
import = KenAll::Import.new(visualize: false)
|
12
|
+
import.from_net
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Import from file"
|
16
|
+
task :file => :environment do
|
17
|
+
import = KenAll::Import.new(visualize: false)
|
18
|
+
import.from_file
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ken_all
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.6
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yamamoto Kazuhisa
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activerecord-import
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.2.11
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.2.11
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: zipruby
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rails
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 3.0.9
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.9
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: sqlite3
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec-rails
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rr
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.0.0
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.0.0
|
110
|
+
description: Japanese postal code tools.
|
111
|
+
email:
|
112
|
+
- ak.hisashi@gmail.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- app/assets/javascripts/ken_all/application.js
|
118
|
+
- app/assets/stylesheets/ken_all/application.css
|
119
|
+
- app/controllers/ken_all/application_controller.rb
|
120
|
+
- app/helpers/ken_all/application_helper.rb
|
121
|
+
- app/models/ken_all/postal_code.rb
|
122
|
+
- app/views/layouts/ken_all/application.html.erb
|
123
|
+
- config/routes.rb
|
124
|
+
- db/migrate/20121028092517_create_ken_all_postal_codes.rb
|
125
|
+
- lib/ken_all/engine.rb
|
126
|
+
- lib/ken_all/import.rb
|
127
|
+
- lib/ken_all/merge_box.rb
|
128
|
+
- lib/ken_all/post.rb
|
129
|
+
- lib/ken_all/version.rb
|
130
|
+
- lib/ken_all/visualizer.rb
|
131
|
+
- lib/ken_all.rb
|
132
|
+
- lib/tasks/ken_all_tasks.rake
|
133
|
+
- MIT-LICENSE
|
134
|
+
- Rakefile
|
135
|
+
- README.rdoc
|
136
|
+
- Gemfile
|
137
|
+
- Gemfile.lock
|
138
|
+
homepage: https://github.com/kazuhisa/ken_all
|
139
|
+
licenses: []
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
segments:
|
151
|
+
- 0
|
152
|
+
hash: -2356946912816725775
|
153
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ! '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
segments:
|
160
|
+
- 0
|
161
|
+
hash: -2356946912816725775
|
162
|
+
requirements: []
|
163
|
+
rubyforge_project:
|
164
|
+
rubygems_version: 1.8.24
|
165
|
+
signing_key:
|
166
|
+
specification_version: 3
|
167
|
+
summary: Japanese postal code tools.
|
168
|
+
test_files: []
|