worlddb 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7bcd0cfff41045906128dcc7c1d4a21a161f97f8
4
- data.tar.gz: 77b2b023d09ffd92a1f6b409dc12cea150f4204a
3
+ metadata.gz: 6b65594f88cfffccc8acebb72f70c8a159f0567b
4
+ data.tar.gz: 992aee423be6b539415f6dadd8a38dd59a7d32ca
5
5
  SHA512:
6
- metadata.gz: 15bb7a864dcb23fcfb99f15c64c83cdc8a2f0d17e1f51ea59ac81f581114ccca9f647d7e6ed9a3dcba58847d4768a0171f2cc3c7a43c294ebd4dab246e1fadc3
7
- data.tar.gz: fa1f5a379da46acd7ce1b250b98ab61a41a1d8e7940420758c5c7631adf4ce8d0b55c4eef3ad64cb4ae91b59e6f27ba85395c75cadf433291a42c4a92c6f6a6c
6
+ metadata.gz: ab185997dfc12146ed72b4b7e78a38307e1bff1312ce6a0cf65e77c5038446e42da0dde0849031eb43238024331fb6f66d7815cc17fffab34a0f82869188bf49
7
+ data.tar.gz: 15a37472e6017d9609ad4d057a4480d022793f853219d693f35add17d09e1705e6db1e6a181302eee1dd81f894ee1f1108da8df2ac8b023e4746dffd1f1d0ff3
data/Manifest.txt CHANGED
@@ -34,7 +34,6 @@ lib/worlddb/readers/region.rb
34
34
  lib/worlddb/readers/usage.rb
35
35
  lib/worlddb/schema.rb
36
36
  lib/worlddb/stats.rb
37
- lib/worlddb/utils.rb
38
37
  lib/worlddb/version.rb
39
38
  test/helper.rb
40
39
  test/test_fixture_matchers.rb
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/wrolddb](http://rubydoc.info/gems/worlddb)
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
- world.db command line tool, version 2.0.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
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
- 'City' Model - Example:
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
- 'Tag' Model - Example:
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.8.7'], # e.g. >= 0.6 && <= 1.0 ## will include logutils, props
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
 
@@ -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)
@@ -1,4 +1,5 @@
1
1
 
2
2
  module WorldDb
3
- VERSION = '2.0.0' # sync version w/ sport.db - why? why not?
3
+ VERSION = '2.0.1' # sync version w/ sport.db - why? why not?
4
4
  end
5
+
data/lib/worlddb.rb CHANGED
@@ -27,8 +27,6 @@ require 'props/db' # includes ConfDb (ConfDb::Model::Prop, etc.)
27
27
 
28
28
  require 'worlddb/version' # always goes first
29
29
 
30
- require 'worlddb/utils'
31
-
32
30
  require 'worlddb/models/forward'
33
31
 
34
32
  require 'worlddb/models/name'
@@ -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.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-22 00:00:00.000000000 Z
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.8.7
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.8.7
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
-