worlddb 2.0.0 → 2.0.1
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 +4 -4
- data/Manifest.txt +0 -1
- data/README.md +87 -26
- data/Rakefile +1 -1
- data/lib/worlddb/models/continent.rb +5 -0
- data/lib/worlddb/models/country.rb +13 -2
- data/lib/worlddb/schema.rb +2 -0
- data/lib/worlddb/version.rb +2 -1
- data/lib/worlddb.rb +0 -2
- data/test/test_model_country.rb +10 -0
- metadata +4 -5
- data/lib/worlddb/utils.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b65594f88cfffccc8acebb72f70c8a159f0567b
|
4
|
+
data.tar.gz: 992aee423be6b539415f6dadd8a38dd59a7d32ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab185997dfc12146ed72b4b7e78a38307e1bff1312ce6a0cf65e77c5038446e42da0dde0849031eb43238024331fb6f66d7815cc17fffab34a0f82869188bf49
|
7
|
+
data.tar.gz: 15a37472e6017d9609ad4d057a4480d022793f853219d693f35add17d09e1705e6db1e6a181302eee1dd81f894ee1f1108da8df2ac8b023e4746dffd1f1d0ff3
|
data/Manifest.txt
CHANGED
data/README.md
CHANGED
@@ -5,33 +5,94 @@ world.db Command Line Tool in Ruby
|
|
5
5
|
* home :: [github.com/geraldb/world.db.ruby](https://github.com/geraldb/world.db.ruby)
|
6
6
|
* bugs :: [github.com/geraldb/world.db.ruby/issues](https://github.com/geraldb/world.db.ruby/issues)
|
7
7
|
* gem :: [rubygems.org/gems/worlddb](https://rubygems.org/gems/worlddb)
|
8
|
-
* rdoc :: [rubydoc.info/gems/
|
8
|
+
* rdoc :: [rubydoc.info/gems/worlddb](http://rubydoc.info/gems/worlddb)
|
9
9
|
* forum :: [groups.google.com/group/openmundi](https://groups.google.com/group/openmundi)
|
10
10
|
|
11
11
|
|
12
12
|
## Usage Command Line
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
-
|
33
|
-
|
34
|
-
|
14
|
+
The worlddb gem lets you load plain text fixtures into your database
|
15
|
+
(and also includes schema n models for easy reuse).
|
16
|
+
|
17
|
+
~~~
|
18
|
+
SYNOPSIS
|
19
|
+
worlddb [global options] command [command options] [arguments...]
|
20
|
+
|
21
|
+
VERSION
|
22
|
+
2.0
|
23
|
+
|
24
|
+
GLOBAL OPTIONS
|
25
|
+
-d, --dbpath=PATH - Database path (default: .)
|
26
|
+
-n, --dbname=NAME - Database name (default: world.db)
|
27
|
+
--verbose - (Debug) Show debug messages
|
28
|
+
--version - Show version
|
29
|
+
|
30
|
+
COMMANDS
|
31
|
+
create - Create DB schema
|
32
|
+
setup, s - Create DB schema 'n' load all world data
|
33
|
+
update, up, u - Update all world data
|
34
|
+
load, l - Load world fixtures
|
35
|
+
logs - Show logs
|
36
|
+
props - Show props
|
37
|
+
stats - Show stats
|
38
|
+
test - (Debug) Test command suite
|
39
|
+
help - Shows a list of commands or help for one command
|
40
|
+
~~~
|
41
|
+
|
42
|
+
|
43
|
+
### `setup` Command
|
44
|
+
|
45
|
+
~~~
|
46
|
+
NAME
|
47
|
+
setup - Create DB schema 'n' load all world data
|
48
|
+
|
49
|
+
SYNOPSIS
|
50
|
+
worlddb [global options] setup [command options] NAME
|
51
|
+
|
52
|
+
COMMAND OPTIONS
|
53
|
+
-i, --include=PATH - World data path (default: .)
|
54
|
+
|
55
|
+
EXAMPLES
|
56
|
+
worlddb setup --include ./world.db
|
57
|
+
worlddb setup us --include ./world.db
|
58
|
+
~~~
|
59
|
+
|
60
|
+
|
61
|
+
### `update` Command
|
62
|
+
|
63
|
+
~~~
|
64
|
+
NAME
|
65
|
+
update - Update all world data
|
66
|
+
|
67
|
+
SYNOPSIS
|
68
|
+
worlddb [global options] update [command options] NAME
|
69
|
+
|
70
|
+
COMMAND OPTIONS
|
71
|
+
--delete - Delete all world data records
|
72
|
+
-i, --include=PATH - World data path (default: .)
|
73
|
+
|
74
|
+
EXAMPLES
|
75
|
+
worlddb update --include ./world.db
|
76
|
+
worlddb update --include ./world.db --delete
|
77
|
+
~~~
|
78
|
+
|
79
|
+
|
80
|
+
### `load` Command
|
81
|
+
|
82
|
+
~~~
|
83
|
+
NAME
|
84
|
+
load - Load world fixtures
|
85
|
+
|
86
|
+
SYNOPSIS
|
87
|
+
worlddb [global options] load [command options] NAME
|
88
|
+
|
89
|
+
COMMAND OPTIONS
|
90
|
+
--delete - Delete all world data records
|
91
|
+
-i, --include=PATH - World data path (default: .)
|
92
|
+
|
93
|
+
EXAMPLES
|
94
|
+
worlddb load --include ./world.db europe/countries
|
95
|
+
~~~
|
35
96
|
|
36
97
|
|
37
98
|
|
@@ -53,10 +114,10 @@ world.db Command Line Tool in Ruby
|
|
53
114
|
# => [ 'Wien', 'Niederösterreich', 'Oberösterreich', ... ]
|
54
115
|
|
55
116
|
at.cities.by_pop
|
56
|
-
# => [ 'Wien', 'Graz', 'Linz', 'Salzburg', ... ]
|
117
|
+
# => [ 'Wien', 'Graz', 'Linz', 'Salzburg', 'Innsbruck' ... ]
|
57
118
|
|
58
119
|
|
59
|
-
|
120
|
+
`City` Model - Example:
|
60
121
|
|
61
122
|
c = City.find_by! key: 'wien'
|
62
123
|
c.name
|
@@ -81,7 +142,7 @@ world.db Command Line Tool in Ruby
|
|
81
142
|
# => 'North America'
|
82
143
|
|
83
144
|
|
84
|
-
|
145
|
+
`Tag` Model - Example:
|
85
146
|
|
86
147
|
euro = Tag.find_by! key: 'euro'
|
87
148
|
euro.countries.count
|
@@ -93,7 +154,7 @@ world.db Command Line Tool in Ruby
|
|
93
154
|
flanders.regions.count
|
94
155
|
# => 5
|
95
156
|
flanders.regions
|
96
|
-
# => ['Antwerpen', 'Brabant Wallon', 'Limburg', 'Oost-Vlaanderen',
|
157
|
+
# => ['Antwerpen', 'Brabant Wallon', 'Limburg', 'Oost-Vlaanderen', 'West-Vlaanderen']
|
97
158
|
flanders.regions.first.country.name
|
98
159
|
# => 'Belgium'
|
99
160
|
|
data/Rakefile
CHANGED
@@ -17,7 +17,7 @@ Hoe.spec 'worlddb' do
|
|
17
17
|
self.extra_deps = [
|
18
18
|
['props'], # settings / prop(ertie)s / env / INI
|
19
19
|
['logutils'], # logging
|
20
|
-
['textutils', '>= 0.
|
20
|
+
['textutils', '>= 0.9.2'], # e.g. >= 0.6 && <= 1.0 ## will include logutils, props
|
21
21
|
['tagutils'], # tags n categories for activerecord
|
22
22
|
|
23
23
|
## 3rd party
|
@@ -16,11 +16,16 @@ class Continent < ActiveRecord::Base
|
|
16
16
|
def on_create
|
17
17
|
place_rec = Place.create!( name: name, kind: place_kind )
|
18
18
|
self.place_id = place_rec.id
|
19
|
+
|
20
|
+
self.slug = TextUtils.slugify( name ) if slug.blank?
|
19
21
|
end
|
20
22
|
|
21
23
|
def on_update
|
22
24
|
## fix/todo: check - if name or kind changed - only update if changed ?? why? why not??
|
23
25
|
place.update_attributes!( name: name, kind: place_kind )
|
26
|
+
|
27
|
+
## check if name changed -- possible?
|
28
|
+
## update slug too??
|
24
29
|
end
|
25
30
|
|
26
31
|
def place_kind # use place_kind_of_code ??
|
@@ -45,14 +45,20 @@ class Country < ActiveRecord::Base
|
|
45
45
|
before_create :on_create
|
46
46
|
before_update :on_update
|
47
47
|
|
48
|
+
|
48
49
|
def on_create
|
49
50
|
place_rec = Place.create!( name: name, kind: place_kind )
|
50
|
-
self.place_id = place_rec.id
|
51
|
+
self.place_id = place_rec.id
|
52
|
+
|
53
|
+
self.slug = TextUtils.slugify( name ) if slug.blank?
|
51
54
|
end
|
52
|
-
|
55
|
+
|
53
56
|
def on_update
|
54
57
|
## fix/todo: check - if name or kind changed - only update if changed ?? why? why not??
|
55
58
|
place.update_attributes!( name: name, kind: place_kind )
|
59
|
+
|
60
|
+
## check if name changed -- possible?
|
61
|
+
## update slug too??
|
56
62
|
end
|
57
63
|
|
58
64
|
def place_kind # use place_kind_of_code ??
|
@@ -87,6 +93,11 @@ class Country < ActiveRecord::Base
|
|
87
93
|
end
|
88
94
|
|
89
95
|
|
96
|
+
def to_path( opts={} )
|
97
|
+
# e.g. europe/at-austria
|
98
|
+
"#{continent.slug}/#{key}-#{slug}"
|
99
|
+
end
|
100
|
+
|
90
101
|
|
91
102
|
def self.create_or_update_from_values( values, more_attribs={} )
|
92
103
|
|
data/lib/worlddb/schema.rb
CHANGED
@@ -62,6 +62,7 @@ end
|
|
62
62
|
|
63
63
|
create_table :continents do |t|
|
64
64
|
t.string :name, null: false
|
65
|
+
t.string :slug, null: false # auto-generate default
|
65
66
|
t.string :key, null: false
|
66
67
|
t.references :place, null: false
|
67
68
|
t.string :alt_names # comma separated list of alternate names (synonyms)
|
@@ -75,6 +76,7 @@ add_index :continents, :key, unique: true
|
|
75
76
|
|
76
77
|
create_table :countries do |t|
|
77
78
|
t.string :name, null: false
|
79
|
+
t.string :slug, null: false # auto-generate default
|
78
80
|
t.string :key, null: false
|
79
81
|
t.references :place, null: false
|
80
82
|
t.string :code, null: false # short three letter code (FIFA country code e.g. ITA)
|
data/lib/worlddb/version.rb
CHANGED
data/lib/worlddb.rb
CHANGED
data/test/test_model_country.rb
CHANGED
@@ -9,6 +9,16 @@ class TestModelCountry < MiniTest::Unit::TestCase
|
|
9
9
|
WorldDb.delete!
|
10
10
|
end
|
11
11
|
|
12
|
+
def test_to_path
|
13
|
+
eu = Continent.create!( key: 'eu', name: 'Europe' )
|
14
|
+
assert_equal 'europe', eu.slug
|
15
|
+
|
16
|
+
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', area: 83_871, pop: 8_414_638, continent: eu )
|
17
|
+
assert_equal 'austria', at.slug
|
18
|
+
|
19
|
+
assert_equal 'europe/at-austria', at.to_path
|
20
|
+
end
|
21
|
+
|
12
22
|
def test_load_values
|
13
23
|
|
14
24
|
new_attributes = {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: worlddb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: props
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.9.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.9.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: tagutils
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,7 +168,6 @@ files:
|
|
168
168
|
- lib/worlddb/readers/usage.rb
|
169
169
|
- lib/worlddb/schema.rb
|
170
170
|
- lib/worlddb/stats.rb
|
171
|
-
- lib/worlddb/utils.rb
|
172
171
|
- lib/worlddb/version.rb
|
173
172
|
- test/helper.rb
|
174
173
|
- test/test_fixture_matchers.rb
|
data/lib/worlddb/utils.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
######
|
4
|
-
# fix:
|
5
|
-
# move to textutils ???
|
6
|
-
|
7
|
-
class Time
|
8
|
-
|
9
|
-
def self.cet( str ) # central european time (cet) + central european summer time (cest)
|
10
|
-
ActiveSupport::TimeZone['Vienna'].parse( str )
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.eet( str ) # eastern european time (eet) + 2 hours
|
14
|
-
ActiveSupport::TimeZone['Bucharest'].parse( str )
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.cst( str ) # central standard time (cst) - 6 hours
|
18
|
-
ActiveSupport::TimeZone['Mexico City'].parse( str )
|
19
|
-
end
|
20
|
-
|
21
|
-
end # class Time
|
22
|
-
|