worlddb 1.7.2 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -1
- data/README.md +44 -5
- data/Rakefile +1 -53
- data/bin/worlddb +0 -0
- data/lib/worlddb/console.rb +7 -7
- data/lib/worlddb/matcher.rb +34 -23
- data/lib/worlddb/models/city.rb +2 -2
- data/lib/worlddb/models/continent.rb +3 -2
- data/lib/worlddb/models/country.rb +2 -2
- data/lib/worlddb/models/lang.rb +4 -2
- data/lib/worlddb/models/prop.rb +3 -2
- data/lib/worlddb/models/region.rb +2 -2
- data/lib/worlddb/models/tag.rb +6 -5
- data/lib/worlddb/models/tagging.rb +3 -2
- data/lib/worlddb/models/usage.rb +3 -2
- data/lib/worlddb/version.rb +1 -1
- data/lib/worlddb.rb +7 -4
- data/test/helper.rb +3 -3
- data/test/test_fixture_matchers.rb +96 -0
- data/test/test_values.rb +15 -15
- metadata +20 -17
- data/lib/worlddb/data/fixtures.rb +0 -42
data/Manifest.txt
CHANGED
@@ -7,7 +7,6 @@ lib/worlddb.rb
|
|
7
7
|
lib/worlddb/cli/main.rb
|
8
8
|
lib/worlddb/cli/opts.rb
|
9
9
|
lib/worlddb/console.rb
|
10
|
-
lib/worlddb/data/fixtures.rb
|
11
10
|
lib/worlddb/deleter.rb
|
12
11
|
lib/worlddb/matcher.rb
|
13
12
|
lib/worlddb/models/city.rb
|
@@ -25,4 +24,5 @@ lib/worlddb/stats.rb
|
|
25
24
|
lib/worlddb/utils.rb
|
26
25
|
lib/worlddb/version.rb
|
27
26
|
test/helper.rb
|
27
|
+
test/test_fixture_matchers.rb
|
28
28
|
test/test_values.rb
|
data/README.md
CHANGED
@@ -1,13 +1,41 @@
|
|
1
|
-
# worlddb
|
1
|
+
# worlddb
|
2
|
+
|
3
|
+
world.db Command Line Tool in Ruby
|
2
4
|
|
3
5
|
* home :: [github.com/geraldb/world.db.ruby](https://github.com/geraldb/world.db.ruby)
|
4
6
|
* bugs :: [github.com/geraldb/world.db.ruby/issues](https://github.com/geraldb/world.db.ruby/issues)
|
5
|
-
* gem :: [rubygems.org/gems/
|
7
|
+
* gem :: [rubygems.org/gems/worlddb](https://rubygems.org/gems/worlddb)
|
6
8
|
* rdoc :: [rubydoc.info/gems/wrolddb](http://rubydoc.info/gems/worlddb)
|
7
|
-
* forum :: [groups.google.com/group/
|
9
|
+
* forum :: [groups.google.com/group/openmundi](https://groups.google.com/group/openmundi)
|
10
|
+
|
11
|
+
|
12
|
+
## Usage Command Line
|
8
13
|
|
14
|
+
world.db command line tool, version 1.8.0
|
15
|
+
|
16
|
+
Commands:
|
17
|
+
create Create DB schema
|
18
|
+
help Display global or [command] help documentation.
|
19
|
+
load Load fixtures
|
20
|
+
logs Show logs
|
21
|
+
props Show props
|
22
|
+
setup Create DB schema 'n' load all data
|
23
|
+
stats Show stats
|
24
|
+
test Debug/test command suite
|
25
|
+
|
26
|
+
Global Options:
|
27
|
+
-i, --include PATH Data path (default is .)
|
28
|
+
-d, --dbpath PATH Database path (default is .)
|
29
|
+
-n, --dbname NAME Database name (datault is world.db)
|
30
|
+
-q, --quiet Only show warnings, errors and fatal messages
|
31
|
+
-w, --verbose Show debug messages
|
32
|
+
-h, --help Display help documentation
|
33
|
+
-v, --version Display version information
|
34
|
+
-t, --trace Display backtrace when an error occurs
|
35
|
+
|
36
|
+
|
37
|
+
## Usage Models
|
9
38
|
|
10
|
-
## Usage
|
11
39
|
|
12
40
|
TBD
|
13
41
|
|
@@ -19,7 +47,18 @@ Just install the gem:
|
|
19
47
|
$ gem install worlddb
|
20
48
|
|
21
49
|
|
50
|
+
## Free Open Public Domain Datasets
|
51
|
+
|
52
|
+
- [`world.db`](https://github.com/openmundi) - free open public domain countries, regions, cities n more data for use in any (programming) language
|
53
|
+
|
54
|
+
|
22
55
|
## License
|
23
56
|
|
24
57
|
The `worlddb` scripts are dedicated to the public domain.
|
25
|
-
Use it as you please with no restrictions whatsoever.
|
58
|
+
Use it as you please with no restrictions whatsoever.
|
59
|
+
|
60
|
+
## Questions? Comments?
|
61
|
+
|
62
|
+
Send them along to the [Open Mundi (world.db) Database Forum/Mailing List](http://groups.google.com/group/openmundi).
|
63
|
+
Thanks!
|
64
|
+
|
data/Rakefile
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'pp'
|
2
1
|
require 'hoe'
|
3
2
|
require './lib/worlddb/version.rb'
|
4
3
|
|
@@ -16,7 +15,7 @@ Hoe.spec 'worlddb' do
|
|
16
15
|
self.urls = ['https://github.com/geraldb/world.db.ruby']
|
17
16
|
|
18
17
|
self.author = 'Gerald Bauer'
|
19
|
-
self.email = '
|
18
|
+
self.email = 'openmundi@googlegroups.com'
|
20
19
|
|
21
20
|
self.extra_deps = [
|
22
21
|
['textutils', '~> 0.6'], # e.g. >= 0.6 && <= 1.0
|
@@ -32,54 +31,3 @@ Hoe.spec 'worlddb' do
|
|
32
31
|
}
|
33
32
|
|
34
33
|
end
|
35
|
-
|
36
|
-
##############################
|
37
|
-
## for testing
|
38
|
-
##
|
39
|
-
## NB: use rake -I ./lib dev:test # fresh import (starts w/ clean wipe out)
|
40
|
-
|
41
|
-
namespace :worlddb do
|
42
|
-
|
43
|
-
BUILD_DIR = "./build"
|
44
|
-
|
45
|
-
WORLD_DB_PATH = "#{BUILD_DIR}/world.db"
|
46
|
-
|
47
|
-
DB_CONFIG = {
|
48
|
-
:adapter => 'sqlite3',
|
49
|
-
:database => WORLD_DB_PATH
|
50
|
-
}
|
51
|
-
|
52
|
-
directory BUILD_DIR
|
53
|
-
|
54
|
-
task :clean do
|
55
|
-
rm WORLD_DB_PATH if File.exists?( WORLD_DB_PATH )
|
56
|
-
end
|
57
|
-
|
58
|
-
task :env => BUILD_DIR do
|
59
|
-
require 'worlddb' ### NB: for local testing use rake -I ./lib dev:test e.g. do NOT forget to add -I ./lib
|
60
|
-
require 'logutils/db'
|
61
|
-
|
62
|
-
LogUtils::Logger.root.level = :info
|
63
|
-
|
64
|
-
pp DB_CONFIG
|
65
|
-
ActiveRecord::Base.establish_connection( DB_CONFIG )
|
66
|
-
end
|
67
|
-
|
68
|
-
task :create => :env do
|
69
|
-
LogDb.create
|
70
|
-
WorldDb.create
|
71
|
-
end
|
72
|
-
|
73
|
-
task :import => :env do
|
74
|
-
WorldDb.read_setup( 'setups/europe.at', '../world.db', skip_tags: true ) # populate world tables
|
75
|
-
WorldDb.stats
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
desc 'worlddb - build from scratch'
|
80
|
-
task :build => [:clean, :create, :import]
|
81
|
-
|
82
|
-
desc 'worlddb - update'
|
83
|
-
task :update => [:import]
|
84
|
-
|
85
|
-
end # namespace :worlddb
|
data/bin/worlddb
CHANGED
File without changes
|
data/lib/worlddb/console.rb
CHANGED
@@ -14,13 +14,13 @@ require 'yaml'
|
|
14
14
|
|
15
15
|
## shortcuts for models
|
16
16
|
|
17
|
-
Tag = WorldDb::
|
18
|
-
Tagging = WorldDb::
|
19
|
-
Continent = WorldDb::
|
20
|
-
Country = WorldDb::
|
21
|
-
Region = WorldDb::
|
22
|
-
City = WorldDb::
|
23
|
-
Prop = WorldDb::
|
17
|
+
Tag = WorldDb::Model::Tag
|
18
|
+
Tagging = WorldDb::Model::Tagging
|
19
|
+
Continent = WorldDb::Model::Continent
|
20
|
+
Country = WorldDb::Model::Country
|
21
|
+
Region = WorldDb::Model::Region
|
22
|
+
City = WorldDb::Model::City
|
23
|
+
Prop = WorldDb::Model::Prop
|
24
24
|
|
25
25
|
## connect to db
|
26
26
|
|
data/lib/worlddb/matcher.rb
CHANGED
@@ -4,34 +4,43 @@ module WorldDb
|
|
4
4
|
|
5
5
|
module Matcher
|
6
6
|
|
7
|
-
def match_xxx_for_country( name, xxx
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
def match_xxx_for_country( name, xxx ) # xxx e.g. cities|regions|beers|breweries
|
8
|
+
# auto-add required country code (from folder structure)
|
9
|
+
if name =~ /(?:^|\/)([a-z]{2,3})-[^\/]+\/#{xxx}/ || # (1)
|
10
|
+
name =~ /(?:^|\/)[0-9]+--([a-z]{2,3})-[^\/]+\/#{xxx}/ || # (2)
|
11
|
+
name =~ /(?:^|\/)([a-z]{2,3})\/#{xxx}/ # (3)
|
12
|
+
|
11
13
|
country_key = $1.dup
|
12
|
-
|
14
|
+
yield( country_key )
|
13
15
|
true # bingo - match found
|
14
|
-
|
15
|
-
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
|
17
|
+
######
|
18
|
+
# (1) new style: e.g. /at-austria/beers or ^at-austria!/beers
|
19
|
+
#
|
20
|
+
# (2) new-new style e.g. /1--at-austria--central/beers
|
21
|
+
#
|
22
|
+
# (3) classic style: e.g. /at/beers (europe/at/beers)
|
20
23
|
else
|
21
24
|
false # no match found
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
25
|
-
def match_xxx_for_country_n_region( name, xxx
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
def match_xxx_for_country_n_region( name, xxx ) # xxx e.g. beers|breweries
|
29
|
+
# auto-add required country n region code (from folder structure)
|
30
|
+
if name =~ /(?:^|\/)([a-z]{2,3})-[^\/]+\/([a-z]{1,3})-[^\/]+\/#{xxx}/ || # (1)
|
31
|
+
name =~ /(?:^|\/)[0-9]+--([a-z]{2,3})-[^\/]+\/[0-9]+--([a-z]{1,3})-[^\/]+\/#{xxx}/ # (2)
|
32
|
+
|
33
|
+
#######
|
29
34
|
# nb: country must start name (^) or coming after / e.g. europe/at-austria/...
|
30
|
-
#
|
31
|
-
#
|
35
|
+
# (1)
|
36
|
+
# new style: e.g. /at-austria/w-wien/beers or
|
37
|
+
# ^at-austria!/w-wien/beers
|
38
|
+
# (2)
|
39
|
+
# new new style e.g. /1--at-austria--central/1--w-wien--eastern/beers
|
40
|
+
|
32
41
|
country_key = $1.dup
|
33
42
|
region_key = $2.dup
|
34
|
-
|
43
|
+
yield( country_key, region_key )
|
35
44
|
true # bingo - match found
|
36
45
|
else
|
37
46
|
false # no match found
|
@@ -40,23 +49,25 @@ module Matcher
|
|
40
49
|
|
41
50
|
|
42
51
|
def match_cities_for_country( name, &blk )
|
43
|
-
|
52
|
+
## todo: check if there's a better (more ruby way) to pass along code block ??
|
53
|
+
match_xxx_for_country( name, 'cities', &blk )
|
44
54
|
end
|
45
55
|
|
46
56
|
def match_regions_for_country( name, &blk )
|
47
|
-
|
57
|
+
## todo: check if there's a better (more ruby way) to pass along code block ??
|
58
|
+
match_xxx_for_country( name, 'regions', &blk )
|
48
59
|
end
|
49
60
|
|
50
61
|
def match_regions_abbr_for_country( name, &blk )
|
51
|
-
match_xxx_for_country( name, 'regions\.abbr', blk ) # NB: . gets escaped for regex, that is, \.
|
62
|
+
match_xxx_for_country( name, 'regions\.abbr', &blk ) # NB: . gets escaped for regex, that is, \.
|
52
63
|
end
|
53
64
|
|
54
65
|
def match_regions_iso_for_country( name, &blk ) # NB: . gets escaped for regex, that is, \.
|
55
|
-
match_xxx_for_country( name, 'regions\.iso', blk )
|
66
|
+
match_xxx_for_country( name, 'regions\.iso', &blk )
|
56
67
|
end
|
57
68
|
|
58
69
|
def match_regions_nuts_for_country( name, &blk ) # NB: . gets escaped for regex, that is, \.
|
59
|
-
match_xxx_for_country( name, 'regions\.nuts', blk )
|
70
|
+
match_xxx_for_country( name, 'regions\.nuts', &blk )
|
60
71
|
end
|
61
72
|
|
62
73
|
|
data/lib/worlddb/models/city.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module WorldDb::
|
3
|
+
module WorldDb::Model
|
4
4
|
|
5
5
|
class City < ActiveRecord::Base
|
6
6
|
|
@@ -201,4 +201,4 @@ class City < ActiveRecord::Base
|
|
201
201
|
|
202
202
|
end # class Cities
|
203
203
|
|
204
|
-
end # module WorldDb::
|
204
|
+
end # module WorldDb::Model
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module WorldDb::
|
3
|
+
module WorldDb::Model
|
4
4
|
|
5
5
|
class Country < ActiveRecord::Base
|
6
6
|
|
@@ -225,4 +225,4 @@ class Country < ActiveRecord::Base
|
|
225
225
|
end # class Country
|
226
226
|
|
227
227
|
|
228
|
-
end # module WorldDb::
|
228
|
+
end # module WorldDb::Model
|
data/lib/worlddb/models/lang.rb
CHANGED
data/lib/worlddb/models/prop.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
module WorldDb::
|
3
|
+
module WorldDb::Model
|
4
4
|
|
5
5
|
class Region < ActiveRecord::Base
|
6
6
|
|
@@ -150,4 +150,4 @@ class Region < ActiveRecord::Base
|
|
150
150
|
|
151
151
|
end # class Region
|
152
152
|
|
153
|
-
end # module WorldDb::
|
153
|
+
end # module WorldDb::Model
|
data/lib/worlddb/models/tag.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module WorldDb::
|
3
|
+
module WorldDb::Model
|
4
4
|
|
5
5
|
class Tag < ActiveRecord::Base
|
6
6
|
|
7
7
|
has_many :taggings
|
8
8
|
|
9
|
-
has_many :cities, :through => :taggings, :source => :taggable, :source_type => 'WorldDb::
|
10
|
-
has_many :countries, :through => :taggings, :source => :taggable, :source_type => 'WorldDb::
|
11
|
-
has_many :regions, :through => :taggings, :source => :taggable, :source_type => 'WorldDb::
|
9
|
+
has_many :cities, :through => :taggings, :source => :taggable, :source_type => 'WorldDb::Model::City', :class_name => 'City'
|
10
|
+
has_many :countries, :through => :taggings, :source => :taggable, :source_type => 'WorldDb::Model::Country', :class_name => 'Country'
|
11
|
+
has_many :regions, :through => :taggings, :source => :taggable, :source_type => 'WorldDb::Model::Region', :class_name => 'Region'
|
12
12
|
|
13
13
|
## nb: only allow spaces and underscore inbetween; do not allow digit as first char
|
14
14
|
validates :key, :format => { :with => /^[a-z]$|^[a-z][a-z0-9_ ]*[a-z0-9]$/, :message => 'expected one or more lowercase letters a-z or 0-9 digits or space or underscore' }
|
@@ -29,4 +29,5 @@ module WorldDb::Models
|
|
29
29
|
|
30
30
|
end # class Tag
|
31
31
|
|
32
|
-
end # module WorldDb::
|
32
|
+
end # module WorldDb::Model
|
33
|
+
|
data/lib/worlddb/models/usage.rb
CHANGED
data/lib/worlddb/version.rb
CHANGED
data/lib/worlddb.rb
CHANGED
@@ -36,15 +36,18 @@ require 'worlddb/models/tag'
|
|
36
36
|
require 'worlddb/models/tagging'
|
37
37
|
require 'worlddb/models/lang'
|
38
38
|
require 'worlddb/models/usage'
|
39
|
+
|
40
|
+
module WorldDb
|
41
|
+
Models = Model # note: alias for Model - remove later -- DEPRECIATED!!
|
42
|
+
end
|
43
|
+
|
44
|
+
|
39
45
|
require 'worlddb/schema' # NB: requires worlddb/models (include WorldDB::Models)
|
40
46
|
require 'worlddb/matcher'
|
41
47
|
require 'worlddb/reader'
|
42
48
|
require 'worlddb/deleter'
|
43
49
|
require 'worlddb/stats'
|
44
50
|
|
45
|
-
require 'worlddb/data/fixtures'
|
46
|
-
|
47
|
-
|
48
51
|
|
49
52
|
module WorldDb
|
50
53
|
|
@@ -63,7 +66,7 @@ module WorldDb
|
|
63
66
|
|
64
67
|
def self.create
|
65
68
|
CreateDb.new.up
|
66
|
-
WorldDb::
|
69
|
+
WorldDb::Model::Prop.create!( key: 'db.schema.world.version', value: VERSION )
|
67
70
|
end
|
68
71
|
|
69
72
|
|
data/test/helper.rb
CHANGED
@@ -24,9 +24,9 @@ require 'active_record'
|
|
24
24
|
require 'worlddb'
|
25
25
|
require 'logutils/db' # NB: explict require required for LogDb (not automatic)
|
26
26
|
|
27
|
-
Country = WorldDb::
|
28
|
-
Region = WorldDb::
|
29
|
-
City = WorldDb::
|
27
|
+
Country = WorldDb::Model::Country
|
28
|
+
Region = WorldDb::Model::Region
|
29
|
+
City = WorldDb::Model::City
|
30
30
|
|
31
31
|
|
32
32
|
def setup_in_memory_db
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'helper'
|
4
|
+
|
5
|
+
|
6
|
+
class TestFixtureMatchers < MiniTest::Unit::TestCase
|
7
|
+
|
8
|
+
include WorldDb::Matcher
|
9
|
+
|
10
|
+
|
11
|
+
def test_cities_for_country
|
12
|
+
|
13
|
+
cities_at = [
|
14
|
+
'europe/at/cities',
|
15
|
+
'europe/at-austria/cities',
|
16
|
+
'at-austria/cities',
|
17
|
+
'at-austria!/cities'
|
18
|
+
]
|
19
|
+
|
20
|
+
cities_at.each do |name|
|
21
|
+
found = match_cities_for_country( name ) do |country_key|
|
22
|
+
assert_equal country_key, 'at'
|
23
|
+
end
|
24
|
+
assert found
|
25
|
+
end
|
26
|
+
end # method test_cities_for_country
|
27
|
+
|
28
|
+
def test_country
|
29
|
+
|
30
|
+
beers_at = [
|
31
|
+
'europe/at/beers',
|
32
|
+
'europe/at-austria/beers',
|
33
|
+
'at-austria/beers',
|
34
|
+
'at-austria!/beers',
|
35
|
+
'1--at-austria--central/beers',
|
36
|
+
'europe/1--at-austria--central/beers'
|
37
|
+
]
|
38
|
+
|
39
|
+
beers_at.each do |name|
|
40
|
+
found = match_xxx_for_country( name, 'beers' ) do |country_key|
|
41
|
+
assert_equal country_key, 'at'
|
42
|
+
end
|
43
|
+
assert found
|
44
|
+
end
|
45
|
+
|
46
|
+
breweries_at = [
|
47
|
+
'europe/at/breweries',
|
48
|
+
'europe/at-austria/breweries',
|
49
|
+
'at-austria/breweries',
|
50
|
+
'at-austria!/breweries'
|
51
|
+
]
|
52
|
+
|
53
|
+
breweries_at.each do |name|
|
54
|
+
found = match_xxx_for_country( name, 'breweries' ) do |country_key|
|
55
|
+
assert_equal country_key, 'at'
|
56
|
+
end
|
57
|
+
assert found
|
58
|
+
end
|
59
|
+
end # method test_country
|
60
|
+
|
61
|
+
|
62
|
+
def test_country_n_region
|
63
|
+
|
64
|
+
beers_at = [
|
65
|
+
'europe/at-austria/w-wien/beers',
|
66
|
+
'at-austria/w-wien/beers',
|
67
|
+
'at-austria!/w-wien/beers',
|
68
|
+
'1--at-austria--central/1--w-wien--eastern/beers',
|
69
|
+
'europe/1--at-austria--central/1--w-wien--eastern/beers'
|
70
|
+
]
|
71
|
+
|
72
|
+
beers_at.each do |name|
|
73
|
+
found = match_xxx_for_country_n_region( name, 'beers' ) do |country_key,region_key|
|
74
|
+
assert_equal country_key, 'at'
|
75
|
+
assert_equal region_key, 'w'
|
76
|
+
end
|
77
|
+
assert found
|
78
|
+
end
|
79
|
+
|
80
|
+
breweries_at = [
|
81
|
+
'europe/at-austria/w-wien/breweries',
|
82
|
+
'at-austria/w-wien/breweries',
|
83
|
+
'at-austria!/w-wien/breweries'
|
84
|
+
]
|
85
|
+
|
86
|
+
breweries_at.each do |name|
|
87
|
+
found = match_xxx_for_country_n_region( name, 'breweries' ) do |country_key,region_key|
|
88
|
+
assert_equal country_key, 'at'
|
89
|
+
assert_equal region_key, 'w'
|
90
|
+
end
|
91
|
+
assert found
|
92
|
+
end
|
93
|
+
end # method test_country_n_region
|
94
|
+
|
95
|
+
|
96
|
+
end # class TestFixtureMatchers
|
data/test/test_values.rb
CHANGED
@@ -33,11 +33,11 @@ class TestValues < MiniTest::Unit::TestCase
|
|
33
33
|
c = Country.create_or_update_from_attribs( new_attributes, values )
|
34
34
|
|
35
35
|
c2 = Country.find_by_key!( new_attributes[:key] )
|
36
|
-
|
36
|
+
assert_equal c.id, c2.id
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
assert_equal c.title, new_attributes[:title]
|
39
|
+
assert_equal c.pop, 8_414_638
|
40
|
+
assert_equal c.area, 83_871
|
41
41
|
## todo: assert tag count; add supra:eu etc.
|
42
42
|
end
|
43
43
|
|
@@ -64,10 +64,10 @@ class TestValues < MiniTest::Unit::TestCase
|
|
64
64
|
r = Region.create_or_update_from_attribs( new_attributes, values )
|
65
65
|
|
66
66
|
r2 = Region.find_by_key!( new_attributes[:key] )
|
67
|
-
|
67
|
+
assert_equal r.id, r2.id
|
68
68
|
|
69
|
-
|
70
|
-
|
69
|
+
assert_equal r.title, new_attributes[:title]
|
70
|
+
assert_equal r.area, 415
|
71
71
|
## todo: assert country_id & country.title for assoc
|
72
72
|
end
|
73
73
|
|
@@ -99,14 +99,14 @@ class TestValues < MiniTest::Unit::TestCase
|
|
99
99
|
c = City.create_or_update_from_attribs( new_attributes, values )
|
100
100
|
|
101
101
|
c2 = City.find_by_key!( new_attributes[:key] )
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
102
|
+
assert_equal c.id, c2.id
|
103
|
+
|
104
|
+
assert_equal c.title, new_attributes[:title]
|
105
|
+
assert_equal c.pop, 1_731_236
|
106
|
+
assert_equal c.popm, 1_724_000
|
107
|
+
assert_equal c.m, true
|
108
|
+
assert_equal c.region_id, w.id
|
109
|
+
assert_equal c.country_id, at.id
|
110
110
|
end
|
111
111
|
|
112
112
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: worlddb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: textutils
|
16
|
-
requirement: &
|
16
|
+
requirement: &20916804 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.6'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *20916804
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: commander
|
27
|
-
requirement: &
|
27
|
+
requirement: &20916432 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 4.1.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *20916432
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: activerecord
|
38
|
-
requirement: &
|
38
|
+
requirement: &20916120 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,36 +43,38 @@ dependencies:
|
|
43
43
|
version: '3.2'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *20916120
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rdoc
|
49
|
-
requirement: &
|
49
|
+
requirement: &20915748 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '4.0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *20915748
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: hoe
|
60
|
-
requirement: &
|
60
|
+
requirement: &20915328 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: '3.
|
65
|
+
version: '3.7'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *20915328
|
69
69
|
description: worlddb - world.db command line tool
|
70
|
-
email:
|
70
|
+
email: openmundi@googlegroups.com
|
71
71
|
executables:
|
72
72
|
- worlddb
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files:
|
75
|
+
- History.md
|
75
76
|
- Manifest.txt
|
77
|
+
- README.md
|
76
78
|
files:
|
77
79
|
- History.md
|
78
80
|
- Manifest.txt
|
@@ -83,7 +85,6 @@ files:
|
|
83
85
|
- lib/worlddb/cli/main.rb
|
84
86
|
- lib/worlddb/cli/opts.rb
|
85
87
|
- lib/worlddb/console.rb
|
86
|
-
- lib/worlddb/data/fixtures.rb
|
87
88
|
- lib/worlddb/deleter.rb
|
88
89
|
- lib/worlddb/matcher.rb
|
89
90
|
- lib/worlddb/models/city.rb
|
@@ -101,6 +102,7 @@ files:
|
|
101
102
|
- lib/worlddb/utils.rb
|
102
103
|
- lib/worlddb/version.rb
|
103
104
|
- test/helper.rb
|
105
|
+
- test/test_fixture_matchers.rb
|
104
106
|
- test/test_values.rb
|
105
107
|
- .gemtest
|
106
108
|
homepage: https://github.com/geraldb/world.db.ruby
|
@@ -126,9 +128,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
128
|
version: '0'
|
127
129
|
requirements: []
|
128
130
|
rubyforge_project: worlddb
|
129
|
-
rubygems_version: 1.8.
|
131
|
+
rubygems_version: 1.8.16
|
130
132
|
signing_key:
|
131
133
|
specification_version: 3
|
132
134
|
summary: worlddb - world.db command line tool
|
133
135
|
test_files:
|
136
|
+
- test/test_fixture_matchers.rb
|
134
137
|
- test/test_values.rb
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
def find_world_db_path_from_gemfile_gitref!
|
5
|
-
puts "[debug] find_world_db_path..."
|
6
|
-
puts "load path:"
|
7
|
-
pp $LOAD_PATH
|
8
|
-
|
9
|
-
candidates = []
|
10
|
-
$LOAD_PATH.each do |path|
|
11
|
-
|
12
|
-
# nb: avoid matching /world.db.ruby/ (e.g. gem "worlddb", "0.10.0", :path => "../world.db.ruby")
|
13
|
-
|
14
|
-
if path =~ /\/(world\.db-[a-z0-9]+)|(world\.db)\//
|
15
|
-
candidates << path.dup
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
puts "found candidates:"
|
20
|
-
pp candidates
|
21
|
-
|
22
|
-
cand = candidates[0]
|
23
|
-
|
24
|
-
puts "cand before: #{cand}"
|
25
|
-
|
26
|
-
## nb: *? is non-greedy many operator
|
27
|
-
|
28
|
-
## todo: why not just cut off trailing /lib - is it good enough??
|
29
|
-
# it's easier
|
30
|
-
|
31
|
-
regex = /(\/world\.db.*?)(\/.*)/
|
32
|
-
cand = cand.sub( regex ) do |_|
|
33
|
-
puts "cutting off >>#{$2}<<"
|
34
|
-
$1
|
35
|
-
end
|
36
|
-
|
37
|
-
puts "cand after: #{cand}"
|
38
|
-
|
39
|
-
## todo:exit with error if not found!!!
|
40
|
-
|
41
|
-
cand
|
42
|
-
end
|