iarea 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +0 -0
- data/.travis.yml +2 -0
- data/Gemfile.lock +1 -0
- data/Rakefile +1 -0
- data/db/iareadata.sqlite3 +0 -0
- data/iarea.gemspec +1 -0
- data/lib/iarea/version.rb +1 -1
- data/lib/iarea/zone.rb +4 -0
- data/spec/iarea/prefecture_spec.rb +6 -6
- data/spec/iarea/zone_spec.rb +6 -6
- data/tools/import_areas.rb +8 -6
- metadata +28 -19
data/.rspec
ADDED
File without changes
|
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
data/db/iareadata.sqlite3
CHANGED
Binary file
|
data/iarea.gemspec
CHANGED
data/lib/iarea/version.rb
CHANGED
data/lib/iarea/zone.rb
CHANGED
@@ -2,12 +2,14 @@ module Iarea
|
|
2
2
|
class Zone < OpenStruct
|
3
3
|
@@zones = []
|
4
4
|
|
5
|
+
# Prefectures in the zone
|
5
6
|
def prefectures
|
6
7
|
DB[:prefectures].where(:zone_id => self.id).select(:id).order(:id).map do |prefecture|
|
7
8
|
Prefecture.find(prefecture[:id])
|
8
9
|
end
|
9
10
|
end
|
10
11
|
|
12
|
+
# Areas in the zone
|
11
13
|
def areas
|
12
14
|
DB[:areas].where(:zone_id => self.id).select(:areacode).order(:areacode).map do |area|
|
13
15
|
Area.find(area[:areacode])
|
@@ -15,10 +17,12 @@ module Iarea
|
|
15
17
|
end
|
16
18
|
|
17
19
|
class << self
|
20
|
+
# Find a zone by <tt>id</tt>
|
18
21
|
def find(id)
|
19
22
|
@@zones[id] ||= new DB[:zones].where(:id => id).first
|
20
23
|
end
|
21
24
|
|
25
|
+
# All zones
|
22
26
|
def all
|
23
27
|
DB[:zones].select(:id).order(:id).all.map{ |z| find(z[:id]) }
|
24
28
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe Iarea::Prefecture do
|
5
5
|
describe 'Tokyo' do
|
6
|
-
subject { Iarea::Prefecture.find(
|
6
|
+
subject { Iarea::Prefecture.find(13) }
|
7
7
|
its(:name) { should == "東京" }
|
8
8
|
it do
|
9
9
|
subject.zone.name.should == "関東甲信越"
|
@@ -11,7 +11,7 @@ describe Iarea::Prefecture do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
describe 'Okinawa' do
|
14
|
-
subject { Iarea::Prefecture.find(
|
14
|
+
subject { Iarea::Prefecture.find(47) }
|
15
15
|
its(:name) { should == "沖縄" }
|
16
16
|
it do
|
17
17
|
subject.areas.map(&:name).should == ["那覇/浦添", "沖縄/名護", "宮古/石垣"]
|
@@ -20,9 +20,9 @@ describe Iarea::Prefecture do
|
|
20
20
|
|
21
21
|
describe 'equivalence' do
|
22
22
|
before do
|
23
|
-
@a = Iarea::Prefecture.find(
|
24
|
-
@b = Iarea::Prefecture.find(
|
25
|
-
@c = Iarea::Prefecture.find(
|
23
|
+
@a = Iarea::Prefecture.find(1)
|
24
|
+
@b = Iarea::Prefecture.find(1)
|
25
|
+
@c = Iarea::Prefecture.find(2)
|
26
26
|
end
|
27
27
|
it do
|
28
28
|
@a.should == @b
|
@@ -33,6 +33,6 @@ describe Iarea::Prefecture do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it '#all' do
|
36
|
-
Iarea::Prefecture.all.should == (
|
36
|
+
Iarea::Prefecture.all.should == (1..47).map {|i| Iarea::Prefecture.find(i)}
|
37
37
|
end
|
38
38
|
end
|
data/spec/iarea/zone_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe Iarea::Zone do
|
5
5
|
describe 'Tokyo' do
|
6
|
-
subject { Iarea::Zone.find(
|
6
|
+
subject { Iarea::Zone.find(3) }
|
7
7
|
its(:name) { should == "関東甲信越" }
|
8
8
|
|
9
9
|
it '#prefectures' do
|
@@ -12,7 +12,7 @@ describe Iarea::Zone do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe 'Shikoku' do
|
15
|
-
subject { Iarea::Zone.find(
|
15
|
+
subject { Iarea::Zone.find(8) }
|
16
16
|
it '#areas' do
|
17
17
|
subject.areas.map(&:name).should == ["高松市周辺", "東讃", "中讃", "西讃", "徳島市", "徳島県北部", "徳島県西部", "徳島県南部", "中予", "東予", "南予北部", "南予南部", "高知市", "高知県中部", "高知県東部", "高知県西部"]
|
18
18
|
end
|
@@ -20,9 +20,9 @@ describe Iarea::Zone do
|
|
20
20
|
|
21
21
|
describe 'equivalence' do
|
22
22
|
before do
|
23
|
-
@a = Iarea::Zone.find(
|
24
|
-
@b = Iarea::Zone.find(
|
25
|
-
@c = Iarea::Zone.find(
|
23
|
+
@a = Iarea::Zone.find(1)
|
24
|
+
@b = Iarea::Zone.find(1)
|
25
|
+
@c = Iarea::Zone.find(2)
|
26
26
|
end
|
27
27
|
it do
|
28
28
|
@a.should == @b
|
@@ -33,6 +33,6 @@ describe Iarea::Zone do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it '#all' do
|
36
|
-
Iarea::Zone.all.should == (
|
36
|
+
Iarea::Zone.all.should == (1..9).map {|i| Iarea::Zone.find(i)}
|
37
37
|
end
|
38
38
|
end
|
data/tools/import_areas.rb
CHANGED
@@ -64,13 +64,15 @@ db.transaction do
|
|
64
64
|
end
|
65
65
|
# zones
|
66
66
|
data['zones'].each_with_index do |zone, i|
|
67
|
-
|
68
|
-
|
67
|
+
id = i + 1
|
68
|
+
$stderr.puts " importing zone %d %s" % [id, zone['name']]
|
69
|
+
db[:zones].insert(:id => id, :name => zone['name'])
|
69
70
|
end
|
70
71
|
# prefs
|
71
72
|
data['prefs'].each_with_index do |pref, i|
|
72
|
-
|
73
|
-
|
73
|
+
id = i + 1
|
74
|
+
$stderr.puts " importing prefecture %d %s" % [id, pref['name']]
|
75
|
+
db[:prefectures].insert(:id => id, :name => pref['name'], :zone_id => pref['zone'] + 1)
|
74
76
|
end
|
75
77
|
# areas
|
76
78
|
data['areas'].each do |areacode, area|
|
@@ -85,8 +87,8 @@ db.transaction do
|
|
85
87
|
:south => area['msSouth'],
|
86
88
|
:east => area['msEast'],
|
87
89
|
:north => area['msNorth'],
|
88
|
-
:zone_id => area['zone'],
|
89
|
-
:prefecture_id => area['pref']
|
90
|
+
:zone_id => area['zone'] + 1,
|
91
|
+
:prefecture_id => area['pref'] + 1
|
90
92
|
}
|
91
93
|
# fix .js problem
|
92
94
|
if hash[:name] == '新宿1?2丁目'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iarea
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-08-01 00:00:00.000000000 +09:00
|
13
|
+
default_executable:
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: sequel
|
16
|
-
requirement: &
|
17
|
+
requirement: &2158352220 !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ! '>='
|
@@ -21,10 +22,10 @@ dependencies:
|
|
21
22
|
version: '0'
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
+
version_requirements: *2158352220
|
25
26
|
- !ruby/object:Gem::Dependency
|
26
27
|
name: sqlite3-ruby
|
27
|
-
requirement: &
|
28
|
+
requirement: &2158351740 !ruby/object:Gem::Requirement
|
28
29
|
none: false
|
29
30
|
requirements:
|
30
31
|
- - ! '>='
|
@@ -32,10 +33,10 @@ dependencies:
|
|
32
33
|
version: '0'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
+
version_requirements: *2158351740
|
36
37
|
- !ruby/object:Gem::Dependency
|
37
38
|
name: rspec
|
38
|
-
requirement: &
|
39
|
+
requirement: &2158351260 !ruby/object:Gem::Requirement
|
39
40
|
none: false
|
40
41
|
requirements:
|
41
42
|
- - ! '>='
|
@@ -43,10 +44,10 @@ dependencies:
|
|
43
44
|
version: '0'
|
44
45
|
type: :development
|
45
46
|
prerelease: false
|
46
|
-
version_requirements: *
|
47
|
+
version_requirements: *2158351260
|
47
48
|
- !ruby/object:Gem::Dependency
|
48
49
|
name: rdoc
|
49
|
-
requirement: &
|
50
|
+
requirement: &2158350760 !ruby/object:Gem::Requirement
|
50
51
|
none: false
|
51
52
|
requirements:
|
52
53
|
- - ! '>='
|
@@ -54,10 +55,10 @@ dependencies:
|
|
54
55
|
version: '0'
|
55
56
|
type: :development
|
56
57
|
prerelease: false
|
57
|
-
version_requirements: *
|
58
|
+
version_requirements: *2158350760
|
58
59
|
- !ruby/object:Gem::Dependency
|
59
60
|
name: rake
|
60
|
-
requirement: &
|
61
|
+
requirement: &2158350300 !ruby/object:Gem::Requirement
|
61
62
|
none: false
|
62
63
|
requirements:
|
63
64
|
- - ! '>='
|
@@ -65,7 +66,18 @@ dependencies:
|
|
65
66
|
version: '0'
|
66
67
|
type: :development
|
67
68
|
prerelease: false
|
68
|
-
version_requirements: *
|
69
|
+
version_requirements: *2158350300
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: bundler
|
72
|
+
requirement: &2158349800 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: *2158349800
|
69
81
|
description: A library for DoCoMo Open Iarea.
|
70
82
|
email:
|
71
83
|
- dara@shidara.net
|
@@ -74,6 +86,8 @@ extensions: []
|
|
74
86
|
extra_rdoc_files: []
|
75
87
|
files:
|
76
88
|
- .gitignore
|
89
|
+
- .rspec
|
90
|
+
- .travis.yml
|
77
91
|
- Gemfile
|
78
92
|
- Gemfile.lock
|
79
93
|
- MIT-LICENSE
|
@@ -96,6 +110,7 @@ files:
|
|
96
110
|
- spec/spec_helper.rb
|
97
111
|
- tools/import_areas.rb
|
98
112
|
- tools/import_meshes.rb
|
113
|
+
has_rdoc: true
|
99
114
|
homepage: http://github.com/darashi/iarea
|
100
115
|
licenses: []
|
101
116
|
post_install_message:
|
@@ -108,21 +123,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
123
|
- - ! '>='
|
109
124
|
- !ruby/object:Gem::Version
|
110
125
|
version: '0'
|
111
|
-
segments:
|
112
|
-
- 0
|
113
|
-
hash: 2329483377850070231
|
114
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
127
|
none: false
|
116
128
|
requirements:
|
117
129
|
- - ! '>='
|
118
130
|
- !ruby/object:Gem::Version
|
119
131
|
version: '0'
|
120
|
-
segments:
|
121
|
-
- 0
|
122
|
-
hash: 2329483377850070231
|
123
132
|
requirements: []
|
124
133
|
rubyforge_project: iarea
|
125
|
-
rubygems_version: 1.
|
134
|
+
rubygems_version: 1.6.1
|
126
135
|
signing_key:
|
127
136
|
specification_version: 3
|
128
137
|
summary: A library for DoCoMo Open Iarea.
|