worlddb 1.5.0 → 1.6.0
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.
- data/Rakefile +10 -10
- data/bin/worlddb +1 -1
- data/lib/worlddb/cli/main.rb +19 -19
- data/lib/worlddb/cli/opts.rb +2 -2
- data/lib/worlddb/console.rb +7 -7
- data/lib/worlddb/deleter.rb +3 -3
- data/lib/worlddb/models/city.rb +2 -2
- data/lib/worlddb/models/country.rb +2 -2
- data/lib/worlddb/models/lang.rb +2 -2
- data/lib/worlddb/models/prop.rb +2 -2
- data/lib/worlddb/models/region.rb +2 -2
- data/lib/worlddb/models/tag.rb +5 -5
- data/lib/worlddb/models/tagging.rb +2 -2
- data/lib/worlddb/models/usage.rb +2 -2
- data/lib/worlddb/reader.rb +43 -42
- data/lib/worlddb/schema.rb +10 -14
- data/lib/worlddb/stats.rb +3 -3
- data/lib/worlddb/version.rb +7 -2
- data/lib/worlddb.rb +13 -10
- metadata +12 -12
data/Rakefile
CHANGED
@@ -3,12 +3,12 @@ require 'hoe'
|
|
3
3
|
require './lib/worlddb/version.rb'
|
4
4
|
|
5
5
|
## NB: plugin (hoe-manifest) not required; just used for future testing/development
|
6
|
-
Hoe::plugin :manifest # more options for manifests (in the future; not yet)
|
6
|
+
### Hoe::plugin :manifest # more options for manifests (in the future; not yet)
|
7
7
|
|
8
8
|
|
9
9
|
Hoe.spec 'worlddb' do
|
10
10
|
|
11
|
-
self.version =
|
11
|
+
self.version = WorldDb::VERSION
|
12
12
|
|
13
13
|
self.summary = "worlddb - world.db command line tool"
|
14
14
|
self.description = summary
|
@@ -38,7 +38,7 @@ end
|
|
38
38
|
##
|
39
39
|
## NB: use rake -I ./lib dev:test # fresh import (starts w/ clean wipe out)
|
40
40
|
|
41
|
-
namespace :
|
41
|
+
namespace :worlddb do
|
42
42
|
|
43
43
|
BUILD_DIR = "./build"
|
44
44
|
|
@@ -67,19 +67,19 @@ namespace :dev do
|
|
67
67
|
|
68
68
|
task :create => :env do
|
69
69
|
LogDb.create
|
70
|
-
|
70
|
+
WorldDb.create
|
71
71
|
end
|
72
72
|
|
73
73
|
task :import => :env do
|
74
|
-
|
75
|
-
|
74
|
+
WorldDb.read_setup( 'setups/sport.db.admin', '../world.db', skip_tags: true ) # populate world tables
|
75
|
+
WorldDb.stats
|
76
76
|
end
|
77
77
|
|
78
78
|
|
79
|
-
desc 'worlddb -
|
80
|
-
task :
|
79
|
+
desc 'worlddb - build from scratch'
|
80
|
+
task :build => [:clean, :create, :import]
|
81
81
|
|
82
|
-
desc 'worlddb -
|
82
|
+
desc 'worlddb - update'
|
83
83
|
task :update => [:import]
|
84
84
|
|
85
|
-
end # namespace :
|
85
|
+
end # namespace :worlddb
|
data/bin/worlddb
CHANGED
data/lib/worlddb/cli/main.rb
CHANGED
@@ -9,8 +9,8 @@ LogUtils::Logger.root.level = :info # set logging level to info
|
|
9
9
|
|
10
10
|
|
11
11
|
program :name, 'worlddb'
|
12
|
-
program :version,
|
13
|
-
program :description, "world.db command line tool, version #{
|
12
|
+
program :version, WorldDb::VERSION
|
13
|
+
program :description, "world.db command line tool, version #{WorldDb::VERSION}"
|
14
14
|
|
15
15
|
|
16
16
|
# default_command :help
|
@@ -36,7 +36,7 @@ Further information:
|
|
36
36
|
|
37
37
|
|
38
38
|
## todo: find a better name e.g. change to settings? config? safe_opts? why? why not?
|
39
|
-
myopts =
|
39
|
+
myopts = WorldDb::Opts.new
|
40
40
|
|
41
41
|
### global option (required)
|
42
42
|
## todo: add check that path is valid?? possible?
|
@@ -51,7 +51,7 @@ global_option '-w', '--verbose', "Show debug messages"
|
|
51
51
|
|
52
52
|
|
53
53
|
def connect_to_db( options )
|
54
|
-
puts
|
54
|
+
puts WorldDb.banner
|
55
55
|
|
56
56
|
puts "working directory: #{Dir.pwd}"
|
57
57
|
|
@@ -80,8 +80,8 @@ command :create do |c|
|
|
80
80
|
myopts.merge_commander_options!( options.__hash__ )
|
81
81
|
connect_to_db( myopts )
|
82
82
|
|
83
|
-
|
84
|
-
|
83
|
+
LogDb.create
|
84
|
+
WorldDb.create
|
85
85
|
puts 'Done.'
|
86
86
|
end # action
|
87
87
|
end # command create
|
@@ -102,13 +102,13 @@ command :setup do |c|
|
|
102
102
|
|
103
103
|
if options.delete.present?
|
104
104
|
# w/ delete flag assume tables already exit
|
105
|
-
|
105
|
+
WorldDb.delete!
|
106
106
|
else
|
107
|
-
|
108
|
-
|
107
|
+
LogDb.create
|
108
|
+
WorldDb.create
|
109
109
|
end
|
110
110
|
|
111
|
-
|
111
|
+
WorldDb.read_all( myopts.data_path )
|
112
112
|
puts 'Done.'
|
113
113
|
end # action
|
114
114
|
end # command setup
|
@@ -135,21 +135,21 @@ command :load do |c|
|
|
135
135
|
myopts.merge_commander_options!( options.__hash__ )
|
136
136
|
connect_to_db( myopts )
|
137
137
|
|
138
|
-
|
138
|
+
WorldDb.delete! if options.delete.present?
|
139
139
|
|
140
140
|
# read plain text country/region/city fixtures
|
141
|
-
reader =
|
141
|
+
reader = WorldDb::Reader.new( myopts.data_path )
|
142
142
|
args.each do |arg|
|
143
143
|
name = arg # File.basename( arg, '.*' )
|
144
144
|
|
145
145
|
if myopts.countries?
|
146
|
-
reader.load_countries( name
|
146
|
+
reader.load_countries( name )
|
147
147
|
elsif myopts.regions?
|
148
|
-
reader.load_regions( myopts.country, name
|
148
|
+
reader.load_regions( myopts.country, name )
|
149
149
|
elsif myopts.cities?
|
150
|
-
reader.load_cities( myopts.country, name
|
150
|
+
reader.load_cities( myopts.country, name )
|
151
151
|
else
|
152
|
-
reader.load( name
|
152
|
+
reader.load( name )
|
153
153
|
## todo: issue a warning here; no fixture type specified; assume country?
|
154
154
|
end
|
155
155
|
|
@@ -171,7 +171,7 @@ command :stats do |c|
|
|
171
171
|
myopts.merge_commander_options!( options.__hash__ )
|
172
172
|
connect_to_db( myopts )
|
173
173
|
|
174
|
-
|
174
|
+
WorldDb.tables
|
175
175
|
|
176
176
|
puts 'Done.'
|
177
177
|
end
|
@@ -189,7 +189,7 @@ command :props do |c|
|
|
189
189
|
myopts.merge_commander_options!( options.__hash__ )
|
190
190
|
connect_to_db( myopts )
|
191
191
|
|
192
|
-
|
192
|
+
WorldDb.props
|
193
193
|
|
194
194
|
puts 'Done.'
|
195
195
|
end
|
@@ -207,7 +207,7 @@ command :logs do |c|
|
|
207
207
|
myopts.merge_commander_options!( options.__hash__ )
|
208
208
|
connect_to_db( myopts )
|
209
209
|
|
210
|
-
|
210
|
+
LogDb::Models::Log.all.each do |log|
|
211
211
|
puts "[#{log.level}] -- #{log.msg}"
|
212
212
|
end
|
213
213
|
|
data/lib/worlddb/cli/opts.rb
CHANGED
data/lib/worlddb/console.rb
CHANGED
@@ -14,12 +14,12 @@ require 'yaml'
|
|
14
14
|
|
15
15
|
## shortcuts for models
|
16
16
|
|
17
|
-
Tag =
|
18
|
-
Tagging =
|
19
|
-
Country =
|
20
|
-
Region =
|
21
|
-
City =
|
22
|
-
Prop =
|
17
|
+
Tag = WorldDb::Models::Tag
|
18
|
+
Tagging = WorldDb::Models::Tagging
|
19
|
+
Country = WorldDb::Models::Country
|
20
|
+
Region = WorldDb::Models::Region
|
21
|
+
City = WorldDb::Models::City
|
22
|
+
Prop = WorldDb::Models::Prop
|
23
23
|
|
24
24
|
## connect to db
|
25
25
|
|
@@ -35,7 +35,7 @@ ActiveRecord::Base.establish_connection( DB_CONFIG )
|
|
35
35
|
|
36
36
|
## test drive
|
37
37
|
|
38
|
-
puts "Welcome to world.db, version #{
|
38
|
+
puts "Welcome to world.db, version #{WorldDb::VERSION}!"
|
39
39
|
puts " #{'%6d' % Country.count} countries"
|
40
40
|
puts " #{'%6d' % Region.count} regions"
|
41
41
|
puts " #{'%6d' % City.count} cities"
|
data/lib/worlddb/deleter.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module WorldDb
|
4
4
|
|
5
5
|
class Deleter
|
6
6
|
|
7
7
|
## make models available in worlddb module by default with namespace
|
8
8
|
# e.g. lets you use City instead of Models::City
|
9
|
-
include
|
9
|
+
include WorldDb::Models
|
10
10
|
|
11
11
|
def run
|
12
12
|
# for now delete all tables
|
@@ -23,4 +23,4 @@ module WorldDB
|
|
23
23
|
|
24
24
|
end # class Deleter
|
25
25
|
|
26
|
-
end # module
|
26
|
+
end # module WorldDb
|
data/lib/worlddb/models/city.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module WorldDb::Models
|
4
4
|
|
5
5
|
class City < ActiveRecord::Base
|
6
6
|
self.table_name = 'cities'
|
@@ -111,4 +111,4 @@ class City < ActiveRecord::Base
|
|
111
111
|
|
112
112
|
end # class Cities
|
113
113
|
|
114
|
-
end # module
|
114
|
+
end # module WorldDb::Models
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module WorldDb::Models
|
4
4
|
|
5
5
|
class Country < ActiveRecord::Base
|
6
6
|
self.table_name = 'countries'
|
@@ -96,4 +96,4 @@ class Country < ActiveRecord::Base
|
|
96
96
|
end # class Country
|
97
97
|
|
98
98
|
|
99
|
-
end # module
|
99
|
+
end # module WorldDb::Models
|
data/lib/worlddb/models/lang.rb
CHANGED
data/lib/worlddb/models/prop.rb
CHANGED
data/lib/worlddb/models/tag.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module WorldDb::Models
|
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 => '
|
10
|
-
has_many :countries, :through => :taggings, :source => :taggable, :source_type => '
|
11
|
-
has_many :regions, :through => :taggings, :source => :taggable, :source_type => '
|
9
|
+
has_many :cities, :through => :taggings, :source => :taggable, :source_type => 'WorldDb::Models::City', :class_name => 'City'
|
10
|
+
has_many :countries, :through => :taggings, :source => :taggable, :source_type => 'WorldDb::Models::Country', :class_name => 'Country'
|
11
|
+
has_many :regions, :through => :taggings, :source => :taggable, :source_type => 'WorldDb::Models::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,4 @@ module WorldDB::Models
|
|
29
29
|
|
30
30
|
end # class Tag
|
31
31
|
|
32
|
-
end # module
|
32
|
+
end # module WorldDb::Models
|
data/lib/worlddb/models/usage.rb
CHANGED
data/lib/worlddb/reader.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module WorldDb
|
2
2
|
|
3
3
|
class Reader
|
4
4
|
|
@@ -6,18 +6,9 @@ class Reader
|
|
6
6
|
|
7
7
|
## make models available in sportdb module by default with namespace
|
8
8
|
# e.g. lets you use City instead of Models::City
|
9
|
-
include
|
9
|
+
include WorldDb::Models
|
10
10
|
|
11
|
-
|
12
|
-
## required first arg in ctor!!!
|
13
|
-
## cleanup load_ and remove include_path
|
14
|
-
|
15
|
-
def initialize( opts = {} )
|
16
|
-
## option: do NOT generate/add any tags for countries/regions/cities
|
17
|
-
@skip_tags = opts[:skip_tags].present? ? true : false
|
18
|
-
## option: for now issue warning on update, that is, if key/record (country,region,city) already exists
|
19
|
-
@strict = opts[:strict].present? ? true : false
|
20
|
-
end
|
11
|
+
attr_reader :include_path
|
21
12
|
|
22
13
|
def skip_tags?
|
23
14
|
@skip_tags == true
|
@@ -27,9 +18,19 @@ class Reader
|
|
27
18
|
@strict == true
|
28
19
|
end
|
29
20
|
|
21
|
+
def initialize( include_path, opts = {} )
|
22
|
+
|
23
|
+
@include_path = include_path
|
24
|
+
|
25
|
+
## option: do NOT generate/add any tags for countries/regions/cities
|
26
|
+
@skip_tags = opts[:skip_tags].present? ? true : false
|
27
|
+
## option: for now issue warning on update, that is, if key/record (country,region,city) already exists
|
28
|
+
@strict = opts[:strict].present? ? true : false
|
29
|
+
end
|
30
|
+
|
30
31
|
|
31
|
-
def load_setup( setup
|
32
|
-
ary = load_fixture_setup( setup
|
32
|
+
def load_setup( setup )
|
33
|
+
ary = load_fixture_setup( setup )
|
33
34
|
|
34
35
|
### fix/todo:
|
35
36
|
# use to setups - use comment to remove fixtures
|
@@ -43,13 +44,13 @@ class Reader
|
|
43
44
|
ary = ary - fixture_excludes
|
44
45
|
|
45
46
|
ary.each do |name|
|
46
|
-
load( name
|
47
|
+
load( name )
|
47
48
|
end
|
48
49
|
end # method load_setup
|
49
50
|
|
50
51
|
|
51
52
|
## fix/todo: rename ??
|
52
|
-
def load_fixture_setup( name
|
53
|
+
def load_fixture_setup( name )
|
53
54
|
|
54
55
|
## todo/fix: cleanup quick and dirty code
|
55
56
|
|
@@ -86,34 +87,34 @@ class Reader
|
|
86
87
|
end # load_fixture_setup
|
87
88
|
|
88
89
|
|
89
|
-
def load( name
|
90
|
+
def load( name )
|
90
91
|
|
91
92
|
if name =~ /^lang/
|
92
|
-
load_langs( name
|
93
|
+
load_langs( name )
|
93
94
|
elsif name =~ /\/lang/
|
94
|
-
load_usages( name
|
95
|
+
load_usages( name )
|
95
96
|
elsif name =~ /\/fifa/
|
96
|
-
load_xxx( 'fifa', name
|
97
|
+
load_xxx( 'fifa', name )
|
97
98
|
elsif name =~ /\/iso3/
|
98
|
-
load_xxx( 'iso3', name
|
99
|
+
load_xxx( 'iso3', name )
|
99
100
|
elsif name =~ /\/internet/
|
100
|
-
load_xxx( 'net', name
|
101
|
+
load_xxx( 'net', name )
|
101
102
|
elsif name =~ /\/motor/
|
102
|
-
load_xxx( 'motor', name
|
103
|
+
load_xxx( 'motor', name )
|
103
104
|
elsif name =~ /^tag.*\.(\d)$/
|
104
|
-
load_tags( name,
|
105
|
+
load_tags( name, :grade => $1.to_i )
|
105
106
|
elsif name =~ /^([a-z][a-z\-]+[a-z])\/countries/ # e.g. africa/countries or america/countries
|
106
107
|
### NB: continent changed to regions (e.g. middle-east, caribbean, north-america, etc.)
|
107
108
|
### fix/cleanup/todo:
|
108
109
|
## auto-add continent (from folder structure) as tag
|
109
110
|
## load_countries( name, include_path, :tags => $1 )
|
110
|
-
load_countries( name
|
111
|
+
load_countries( name )
|
111
112
|
elsif name =~ /\/([a-z]{2})\/cities/
|
112
113
|
## auto-add required country code (from folder structure)
|
113
|
-
load_cities( $1, name
|
114
|
+
load_cities( $1, name )
|
114
115
|
elsif name =~ /\/([a-z]{2})\/regions/
|
115
116
|
## auto-add required country code (from folder structure)
|
116
|
-
load_regions( $1, name
|
117
|
+
load_regions( $1, name )
|
117
118
|
else
|
118
119
|
logger.error "unknown world.db fixture type >#{name}<"
|
119
120
|
# todo/fix: exit w/ error
|
@@ -121,29 +122,29 @@ class Reader
|
|
121
122
|
end
|
122
123
|
|
123
124
|
|
124
|
-
def load_countries( name,
|
125
|
-
load_fixtures_for( Country, name,
|
125
|
+
def load_countries( name, more_values={} )
|
126
|
+
load_fixtures_for( Country, name, more_values )
|
126
127
|
end
|
127
128
|
|
128
129
|
|
129
|
-
def load_regions( country_key, name
|
130
|
+
def load_regions( country_key, name )
|
130
131
|
country = Country.find_by_key!( country_key )
|
131
132
|
logger.debug "Country #{country.key} >#{country.title} (#{country.code})<"
|
132
133
|
|
133
|
-
load_fixtures_for( Region, name,
|
134
|
+
load_fixtures_for( Region, name, country_id: country.id )
|
134
135
|
end
|
135
136
|
|
136
137
|
|
137
|
-
def load_cities( country_key, name
|
138
|
+
def load_cities( country_key, name )
|
138
139
|
country = Country.find_by_key!( country_key )
|
139
140
|
logger.debug "Country #{country.key} >#{country.title} (#{country.code})<"
|
140
141
|
|
141
|
-
load_fixtures_for( City, name,
|
142
|
+
load_fixtures_for( City, name, country_id: country.id )
|
142
143
|
end
|
143
144
|
|
144
145
|
|
145
146
|
|
146
|
-
def with_path_for( name
|
147
|
+
def with_path_for( name )
|
147
148
|
## todo: find a better name?
|
148
149
|
# e.g. find_path_for or open_fixture_for ??
|
149
150
|
|
@@ -158,9 +159,9 @@ class Reader
|
|
158
159
|
|
159
160
|
|
160
161
|
|
161
|
-
def load_langs( name
|
162
|
+
def load_langs( name )
|
162
163
|
|
163
|
-
with_path_for( name
|
164
|
+
with_path_for( name ) do |path|
|
164
165
|
|
165
166
|
reader = HashReader.new( path )
|
166
167
|
|
@@ -194,9 +195,9 @@ class Reader
|
|
194
195
|
end # method load_langs
|
195
196
|
|
196
197
|
|
197
|
-
def load_tags( name,
|
198
|
+
def load_tags( name, more_values={} )
|
198
199
|
|
199
|
-
with_path_for( name
|
200
|
+
with_path_for( name ) do |path|
|
200
201
|
|
201
202
|
reader = HashReader.new( path )
|
202
203
|
|
@@ -250,7 +251,7 @@ class Reader
|
|
250
251
|
end # method load_tags
|
251
252
|
|
252
253
|
|
253
|
-
def load_usages( name
|
254
|
+
def load_usages( name )
|
254
255
|
path = "#{include_path}/#{name}.yml"
|
255
256
|
|
256
257
|
puts "*** parsing data '#{name}' (#{path})..."
|
@@ -279,7 +280,7 @@ class Reader
|
|
279
280
|
end
|
280
281
|
|
281
282
|
|
282
|
-
def load_xxx( xxx, name
|
283
|
+
def load_xxx( xxx, name )
|
283
284
|
path = "#{include_path}/#{name}.yml"
|
284
285
|
|
285
286
|
puts "*** parsing data '#{name}' (#{path})..."
|
@@ -297,7 +298,7 @@ class Reader
|
|
297
298
|
|
298
299
|
|
299
300
|
private
|
300
|
-
def load_fixtures_for( clazz, name,
|
301
|
+
def load_fixtures_for( clazz, name, more_values={} ) # load from file system
|
301
302
|
path = "#{include_path}/#{name}.txt"
|
302
303
|
|
303
304
|
puts "*** parsing data '#{name}' (#{path})..."
|
@@ -556,4 +557,4 @@ private
|
|
556
557
|
|
557
558
|
|
558
559
|
end # class Reader
|
559
|
-
end # module
|
560
|
+
end # module WorldDb
|
data/lib/worlddb/schema.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
|
2
|
-
module
|
2
|
+
module WorldDb
|
3
3
|
|
4
|
-
class
|
4
|
+
class CreateDb < ActiveRecord::Migration
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def self.up
|
10
|
-
|
11
|
-
ActiveRecord::Schema.define do
|
6
|
+
def up
|
12
7
|
|
13
8
|
create_table :countries do |t|
|
14
9
|
t.string :title, :null => false
|
@@ -115,18 +110,19 @@ create_table :usages do |t| # join table for countries_langs
|
|
115
110
|
t.timestamps
|
116
111
|
end
|
117
112
|
|
113
|
+
### fix: move to PropDb ? into props gem? why? why not?
|
118
114
|
create_table :props do |t|
|
119
115
|
t.string :key, :null => false
|
120
116
|
t.string :value, :null => false
|
121
117
|
t.timestamps
|
122
118
|
end
|
123
119
|
|
124
|
-
end # block Schema.define
|
125
|
-
|
126
|
-
Prop.create!( key: 'db.schema.world.version', value: WorldDB::VERSION )
|
127
|
-
|
128
120
|
end # method up
|
129
121
|
|
130
|
-
|
122
|
+
def down
|
123
|
+
raise ActiveRecord::IrreversibleMigration
|
124
|
+
end
|
125
|
+
|
126
|
+
end # class CreateDb
|
131
127
|
|
132
|
-
end # module
|
128
|
+
end # module WorldDb
|
data/lib/worlddb/stats.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module WorldDb
|
4
4
|
|
5
5
|
class Stats
|
6
|
-
include
|
6
|
+
include WorldDb::Models
|
7
7
|
|
8
8
|
def tables
|
9
9
|
puts "Stats:"
|
@@ -27,4 +27,4 @@ module WorldDB
|
|
27
27
|
end # class Stats
|
28
28
|
|
29
29
|
|
30
|
-
end # module
|
30
|
+
end # module WorldDb
|
data/lib/worlddb/version.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
|
2
|
-
module
|
3
|
-
VERSION = '1.
|
2
|
+
module WorldDb
|
3
|
+
VERSION = '1.6.0' # sync version w/ sport.db - why? why not?
|
4
4
|
end
|
5
|
+
|
6
|
+
###########################################
|
7
|
+
## fix: remove old alias for WorldDb
|
8
|
+
|
9
|
+
WorldDB = WorldDb
|
data/lib/worlddb.rb
CHANGED
@@ -22,6 +22,8 @@ require 'textutils'
|
|
22
22
|
|
23
23
|
# our own code
|
24
24
|
|
25
|
+
|
26
|
+
|
25
27
|
require 'worlddb/version'
|
26
28
|
|
27
29
|
require 'worlddb/models/prop'
|
@@ -42,7 +44,7 @@ require 'worlddb/data/fixtures'
|
|
42
44
|
|
43
45
|
|
44
46
|
|
45
|
-
module
|
47
|
+
module WorldDb
|
46
48
|
|
47
49
|
def self.banner
|
48
50
|
"worlddb #{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
@@ -58,28 +60,29 @@ module WorldDB
|
|
58
60
|
end
|
59
61
|
|
60
62
|
def self.create
|
61
|
-
|
63
|
+
CreateDb.new.up
|
64
|
+
WorldDb::Models::Prop.create!( key: 'db.schema.world.version', value: VERSION )
|
62
65
|
end
|
63
66
|
|
64
67
|
|
65
68
|
def self.read( ary, include_path )
|
66
|
-
reader = Reader.new
|
69
|
+
reader = Reader.new( include_path )
|
67
70
|
ary.each do |name|
|
68
|
-
reader.load( name
|
71
|
+
reader.load( name )
|
69
72
|
end
|
70
73
|
end
|
71
74
|
|
72
75
|
|
73
76
|
def self.read_setup( setup, include_path, opts={} )
|
74
|
-
reader = Reader.new( opts )
|
75
|
-
reader.load_setup( setup
|
77
|
+
reader = Reader.new( include_path, opts )
|
78
|
+
reader.load_setup( setup )
|
76
79
|
end
|
77
80
|
|
78
81
|
def self.read_all( include_path, opts={} ) # load all builtins (using plain text reader); helper for convenience
|
79
82
|
read_setup( 'setups/all', include_path, opts )
|
80
83
|
end # method read_all
|
81
84
|
|
82
|
-
|
85
|
+
|
83
86
|
# delete ALL records (use with care!)
|
84
87
|
def self.delete!
|
85
88
|
puts '*** deleting world table records/data...'
|
@@ -101,12 +104,12 @@ module WorldDB
|
|
101
104
|
Stats.new.props
|
102
105
|
end
|
103
106
|
|
104
|
-
end # module
|
107
|
+
end # module WorldDb
|
105
108
|
|
106
109
|
|
107
110
|
if __FILE__ == $0
|
108
|
-
|
111
|
+
WorldDb.main
|
109
112
|
else
|
110
113
|
# say hello
|
111
|
-
puts
|
114
|
+
puts WorldDb.banner
|
112
115
|
end
|
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.6.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: 2013-03-
|
12
|
+
date: 2013-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: textutils
|
16
|
-
requirement: &
|
16
|
+
requirement: &82489880 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.5.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *82489880
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: commander
|
27
|
-
requirement: &
|
27
|
+
requirement: &82489650 !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: *82489650
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: activerecord
|
38
|
-
requirement: &
|
38
|
+
requirement: &82489410 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '3.2'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *82489410
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rdoc
|
49
|
-
requirement: &
|
49
|
+
requirement: &82489190 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '3.10'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *82489190
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: hoe
|
60
|
-
requirement: &
|
60
|
+
requirement: &82488960 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '3.3'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *82488960
|
69
69
|
description: worlddb - world.db command line tool
|
70
70
|
email: opensport@googlegroups.com
|
71
71
|
executables:
|