worlddb 1.8.2 → 2.0.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.
- checksums.yaml +7 -0
- data/{History.md → HISTORY.md} +0 -0
- data/Manifest.txt +22 -5
- data/README.md +62 -2
- data/Rakefile +14 -6
- data/lib/worlddb.rb +34 -12
- data/lib/worlddb/cli/main.rb +159 -111
- data/lib/worlddb/cli/opts.rb +15 -48
- data/lib/worlddb/console.rb +6 -5
- data/lib/worlddb/deleter.rb +5 -3
- data/lib/worlddb/matcher.rb +16 -5
- data/lib/worlddb/models/city.rb +66 -30
- data/lib/worlddb/models/city_comp.rb +27 -0
- data/lib/worlddb/models/continent.rb +30 -8
- data/lib/worlddb/models/continent_comp.rb +24 -0
- data/lib/worlddb/models/country.rb +60 -36
- data/lib/worlddb/models/country_comp.rb +29 -0
- data/lib/worlddb/models/forward.rb +53 -0
- data/lib/worlddb/models/lang.rb +9 -7
- data/lib/worlddb/models/lang_comp.rb +23 -0
- data/lib/worlddb/models/name.rb +13 -0
- data/lib/worlddb/models/place.rb +16 -0
- data/lib/worlddb/models/region.rb +34 -12
- data/lib/worlddb/models/region_comp.rb +26 -0
- data/lib/worlddb/models/tagdb/tag.rb +16 -0
- data/lib/worlddb/models/tagdb/tagging.rb +15 -0
- data/lib/worlddb/models/usage.rb +10 -6
- data/lib/worlddb/reader.rb +31 -158
- data/lib/worlddb/readers/base.rb +41 -0
- data/lib/worlddb/readers/city.rb +18 -0
- data/lib/worlddb/readers/country.rb +17 -0
- data/lib/worlddb/readers/lang.rb +43 -0
- data/lib/worlddb/readers/region.rb +17 -0
- data/lib/worlddb/readers/usage.rb +35 -0
- data/lib/worlddb/schema.rb +100 -65
- data/lib/worlddb/stats.rb +9 -3
- data/lib/worlddb/utils.rb +3 -0
- data/lib/worlddb/version.rb +1 -6
- data/test/helper.rb +13 -3
- data/test/test_model_city.rb +60 -0
- data/test/test_model_comp.rb +48 -0
- data/test/test_model_country.rb +43 -0
- data/test/test_model_region.rb +50 -0
- data/test/test_models.rb +35 -0
- metadata +113 -37
- data/lib/worlddb/models/prop.rb +0 -32
- data/lib/worlddb/models/tag.rb +0 -33
- data/lib/worlddb/models/tagging.rb +0 -13
- data/test/test_values.rb +0 -114
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7bcd0cfff41045906128dcc7c1d4a21a161f97f8
|
4
|
+
data.tar.gz: 77b2b023d09ffd92a1f6b409dc12cea150f4204a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 15bb7a864dcb23fcfb99f15c64c83cdc8a2f0d17e1f51ea59ac81f581114ccca9f647d7e6ed9a3dcba58847d4768a0171f2cc3c7a43c294ebd4dab246e1fadc3
|
7
|
+
data.tar.gz: fa1f5a379da46acd7ce1b250b98ab61a41a1d8e7940420758c5c7631adf4ce8d0b55c4eef3ad64cb4ae91b59e6f27ba85395c75cadf433291a42c4a92c6f6a6c
|
data/{History.md → HISTORY.md}
RENAMED
File without changes
|
data/Manifest.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
HISTORY.md
|
2
2
|
Manifest.txt
|
3
3
|
README.md
|
4
4
|
Rakefile
|
@@ -10,19 +10,36 @@ lib/worlddb/console.rb
|
|
10
10
|
lib/worlddb/deleter.rb
|
11
11
|
lib/worlddb/matcher.rb
|
12
12
|
lib/worlddb/models/city.rb
|
13
|
+
lib/worlddb/models/city_comp.rb
|
13
14
|
lib/worlddb/models/continent.rb
|
15
|
+
lib/worlddb/models/continent_comp.rb
|
14
16
|
lib/worlddb/models/country.rb
|
17
|
+
lib/worlddb/models/country_comp.rb
|
18
|
+
lib/worlddb/models/forward.rb
|
15
19
|
lib/worlddb/models/lang.rb
|
16
|
-
lib/worlddb/models/
|
20
|
+
lib/worlddb/models/lang_comp.rb
|
21
|
+
lib/worlddb/models/name.rb
|
22
|
+
lib/worlddb/models/place.rb
|
17
23
|
lib/worlddb/models/region.rb
|
18
|
-
lib/worlddb/models/
|
19
|
-
lib/worlddb/models/
|
24
|
+
lib/worlddb/models/region_comp.rb
|
25
|
+
lib/worlddb/models/tagdb/tag.rb
|
26
|
+
lib/worlddb/models/tagdb/tagging.rb
|
20
27
|
lib/worlddb/models/usage.rb
|
21
28
|
lib/worlddb/reader.rb
|
29
|
+
lib/worlddb/readers/base.rb
|
30
|
+
lib/worlddb/readers/city.rb
|
31
|
+
lib/worlddb/readers/country.rb
|
32
|
+
lib/worlddb/readers/lang.rb
|
33
|
+
lib/worlddb/readers/region.rb
|
34
|
+
lib/worlddb/readers/usage.rb
|
22
35
|
lib/worlddb/schema.rb
|
23
36
|
lib/worlddb/stats.rb
|
24
37
|
lib/worlddb/utils.rb
|
25
38
|
lib/worlddb/version.rb
|
26
39
|
test/helper.rb
|
27
40
|
test/test_fixture_matchers.rb
|
28
|
-
test/
|
41
|
+
test/test_model_city.rb
|
42
|
+
test/test_model_comp.rb
|
43
|
+
test/test_model_country.rb
|
44
|
+
test/test_model_region.rb
|
45
|
+
test/test_models.rb
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ world.db Command Line Tool in Ruby
|
|
11
11
|
|
12
12
|
## Usage Command Line
|
13
13
|
|
14
|
-
world.db command line tool, version
|
14
|
+
world.db command line tool, version 2.0.0
|
15
15
|
|
16
16
|
Commands:
|
17
17
|
create Create DB schema
|
@@ -34,10 +34,70 @@ world.db Command Line Tool in Ruby
|
|
34
34
|
-t, --trace Display backtrace when an error occurs
|
35
35
|
|
36
36
|
|
37
|
+
|
37
38
|
## Usage Models
|
38
39
|
|
40
|
+
`Country` Model - Example:
|
39
41
|
|
40
|
-
|
42
|
+
at = Country.find_by! key: 'at'
|
43
|
+
at.name
|
44
|
+
# => 'Austria'
|
45
|
+
at.pop
|
46
|
+
# => 8_414_638
|
47
|
+
at.area
|
48
|
+
# => 83_871
|
49
|
+
|
50
|
+
at.regions.count
|
51
|
+
# => 9
|
52
|
+
at.regions
|
53
|
+
# => [ 'Wien', 'Niederösterreich', 'Oberösterreich', ... ]
|
54
|
+
|
55
|
+
at.cities.by_pop
|
56
|
+
# => [ 'Wien', 'Graz', 'Linz', 'Salzburg', ... ]
|
57
|
+
|
58
|
+
|
59
|
+
'City' Model - Example:
|
60
|
+
|
61
|
+
c = City.find_by! key: 'wien'
|
62
|
+
c.name
|
63
|
+
# => 'Wien'
|
64
|
+
c.country.name
|
65
|
+
# => 'Austria'
|
66
|
+
c.country.continent.name
|
67
|
+
# => 'Europe'
|
68
|
+
|
69
|
+
la = City.find_by! key: 'losangeles'
|
70
|
+
la.name
|
71
|
+
# => 'Los Angeles'
|
72
|
+
la.region.name
|
73
|
+
# => 'California'
|
74
|
+
la.region.key
|
75
|
+
# => 'ca'
|
76
|
+
la.country.name
|
77
|
+
# => 'United States'
|
78
|
+
la.country.key
|
79
|
+
# => 'us'
|
80
|
+
la.country.continent.name
|
81
|
+
# => 'North America'
|
82
|
+
|
83
|
+
|
84
|
+
'Tag' Model - Example:
|
85
|
+
|
86
|
+
euro = Tag.find_by! key: 'euro'
|
87
|
+
euro.countries.count
|
88
|
+
# => 17
|
89
|
+
euro.countries
|
90
|
+
# => ['Austria, 'Belgium', 'Cyprus', ... ]
|
91
|
+
|
92
|
+
flanders = Tag.find_by! key: 'flanders'
|
93
|
+
flanders.regions.count
|
94
|
+
# => 5
|
95
|
+
flanders.regions
|
96
|
+
# => ['Antwerpen', 'Brabant Wallon', 'Limburg', 'Oost-Vlaanderen', ... ]
|
97
|
+
flanders.regions.first.country.name
|
98
|
+
# => 'Belgium'
|
99
|
+
|
100
|
+
and so on.
|
41
101
|
|
42
102
|
|
43
103
|
## Install
|
data/Rakefile
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
require 'hoe'
|
2
2
|
require './lib/worlddb/version.rb'
|
3
3
|
|
4
|
-
## NB: plugin (hoe-manifest) not required; just used for future testing/development
|
5
|
-
### Hoe::plugin :manifest # more options for manifests (in the future; not yet)
|
6
|
-
|
7
4
|
|
8
5
|
Hoe.spec 'worlddb' do
|
9
6
|
|
@@ -18,12 +15,23 @@ Hoe.spec 'worlddb' do
|
|
18
15
|
self.email = 'openmundi@googlegroups.com'
|
19
16
|
|
20
17
|
self.extra_deps = [
|
21
|
-
['
|
22
|
-
['
|
23
|
-
['
|
18
|
+
['props'], # settings / prop(ertie)s / env / INI
|
19
|
+
['logutils'], # logging
|
20
|
+
['textutils', '>= 0.8.7'], # e.g. >= 0.6 && <= 1.0 ## will include logutils, props
|
21
|
+
['tagutils'], # tags n categories for activerecord
|
22
|
+
|
23
|
+
## 3rd party
|
24
|
+
['gli', '>= 2.9'],
|
25
|
+
['activerecord'] # NB: will include activesupport,etc.
|
24
26
|
### ['sqlite3', '~> 1.3'] # NB: install on your own; remove dependency
|
25
27
|
]
|
26
28
|
|
29
|
+
# switch extension to .markdown for gihub formatting
|
30
|
+
# -- NB: auto-changed when included in manifest
|
31
|
+
self.readme_file = 'README.md'
|
32
|
+
self.history_file = 'HISTORY.md'
|
33
|
+
|
34
|
+
|
27
35
|
self.licenses = ['Public Domain']
|
28
36
|
|
29
37
|
self.spec_extras = {
|
data/lib/worlddb.rb
CHANGED
@@ -18,32 +18,48 @@ require 'active_record' ## todo: add sqlite3? etc.
|
|
18
18
|
|
19
19
|
require 'logutils'
|
20
20
|
require 'textutils'
|
21
|
+
require 'tagutils'
|
22
|
+
require 'props'
|
23
|
+
require 'props/db' # includes ConfDb (ConfDb::Model::Prop, etc.)
|
21
24
|
|
22
25
|
|
23
26
|
# our own code
|
24
27
|
|
28
|
+
require 'worlddb/version' # always goes first
|
25
29
|
|
30
|
+
require 'worlddb/utils'
|
26
31
|
|
27
|
-
require 'worlddb/
|
32
|
+
require 'worlddb/models/forward'
|
28
33
|
|
29
|
-
require 'worlddb/
|
30
|
-
require 'worlddb/models/
|
34
|
+
require 'worlddb/models/name'
|
35
|
+
require 'worlddb/models/place'
|
31
36
|
require 'worlddb/models/continent'
|
37
|
+
require 'worlddb/models/continent_comp'
|
32
38
|
require 'worlddb/models/country'
|
39
|
+
require 'worlddb/models/country_comp'
|
33
40
|
require 'worlddb/models/region'
|
41
|
+
require 'worlddb/models/region_comp'
|
34
42
|
require 'worlddb/models/city'
|
35
|
-
require 'worlddb/models/
|
36
|
-
require 'worlddb/models/tagging'
|
43
|
+
require 'worlddb/models/city_comp'
|
37
44
|
require 'worlddb/models/lang'
|
45
|
+
require 'worlddb/models/lang_comp'
|
38
46
|
require 'worlddb/models/usage'
|
39
47
|
|
40
|
-
|
41
|
-
|
42
|
-
|
48
|
+
require 'worlddb/models/tagdb/tag'
|
49
|
+
require 'worlddb/models/tagdb/tagging'
|
50
|
+
|
43
51
|
|
44
52
|
|
45
53
|
require 'worlddb/schema' # NB: requires worlddb/models (include WorldDB::Models)
|
46
54
|
require 'worlddb/matcher'
|
55
|
+
|
56
|
+
require 'worlddb/readers/base'
|
57
|
+
require 'worlddb/readers/lang'
|
58
|
+
require 'worlddb/readers/usage'
|
59
|
+
require 'worlddb/readers/country'
|
60
|
+
require 'worlddb/readers/region'
|
61
|
+
require 'worlddb/readers/city'
|
62
|
+
|
47
63
|
require 'worlddb/reader'
|
48
64
|
require 'worlddb/deleter'
|
49
65
|
require 'worlddb/stats'
|
@@ -52,7 +68,7 @@ require 'worlddb/stats'
|
|
52
68
|
module WorldDb
|
53
69
|
|
54
70
|
def self.banner
|
55
|
-
"worlddb
|
71
|
+
"worlddb/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
56
72
|
end
|
57
73
|
|
58
74
|
def self.root
|
@@ -63,10 +79,10 @@ module WorldDb
|
|
63
79
|
require 'worlddb/cli/main'
|
64
80
|
## Runner.new.run(ARGV) - old code
|
65
81
|
end
|
66
|
-
|
82
|
+
|
67
83
|
def self.create
|
68
84
|
CreateDb.new.up
|
69
|
-
|
85
|
+
ConfDb::Model::Prop.create!( key: 'db.schema.world.version', value: VERSION )
|
70
86
|
end
|
71
87
|
|
72
88
|
|
@@ -94,7 +110,8 @@ module WorldDb
|
|
94
110
|
Deleter.new.run
|
95
111
|
end # method delete!
|
96
112
|
|
97
|
-
|
113
|
+
####
|
114
|
+
## todo: remove stats ??? why? why not? better use .tables
|
98
115
|
def self.stats
|
99
116
|
stats = Stats.new
|
100
117
|
stats.tables
|
@@ -106,11 +123,16 @@ module WorldDb
|
|
106
123
|
end
|
107
124
|
|
108
125
|
def self.props
|
126
|
+
### fix: use ConfDb.props delegate or similar !!!
|
109
127
|
Stats.new.props
|
110
128
|
end
|
111
129
|
|
112
130
|
end # module WorldDb
|
113
131
|
|
132
|
+
###########################################
|
133
|
+
# fix: remove old alias for WorldDb ??
|
134
|
+
WorldDB = WorldDb
|
135
|
+
|
114
136
|
|
115
137
|
if __FILE__ == $0
|
116
138
|
WorldDb.main
|
data/lib/worlddb/cli/main.rb
CHANGED
@@ -1,24 +1,22 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'gli'
|
4
|
+
|
5
|
+
include GLI::App
|
4
6
|
|
5
|
-
|
6
|
-
require 'worlddb/cli/opts'
|
7
|
-
|
8
|
-
LogUtils::Logger.root.level = :info # set logging level to info
|
7
|
+
# our own code / additional for cli only
|
9
8
|
|
9
|
+
require 'logutils/db' # add support for logging to db
|
10
|
+
require 'worlddb/cli/opts'
|
10
11
|
|
11
|
-
program :name, 'worlddb'
|
12
|
-
program :version, WorldDb::VERSION
|
13
|
-
program :description, "world.db command line tool, version #{WorldDb::VERSION}"
|
14
12
|
|
13
|
+
program_desc 'world.db command line tool'
|
15
14
|
|
16
|
-
|
17
|
-
default_command :load
|
15
|
+
version WorldDb::VERSION
|
18
16
|
|
19
|
-
program :help_formatter, Commander::HelpFormatter::TerminalCompact
|
20
17
|
|
21
|
-
|
18
|
+
LogUtils::Logger.root.level = :info # set logging level to info
|
19
|
+
logger = LogUtils::Logger.root
|
22
20
|
|
23
21
|
=begin
|
24
22
|
### add to help use new sections
|
@@ -35,19 +33,30 @@ Further information:
|
|
35
33
|
=end
|
36
34
|
|
37
35
|
|
36
|
+
|
38
37
|
## todo: find a better name e.g. change to settings? config? safe_opts? why? why not?
|
39
|
-
|
38
|
+
opts = WorldDb::Opts.new
|
39
|
+
|
40
40
|
|
41
41
|
### global option (required)
|
42
42
|
## todo: add check that path is valid?? possible?
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
desc 'Database path'
|
45
|
+
arg_name 'PATH'
|
46
|
+
default_value opts.db_path
|
47
|
+
flag [:d, :dbpath]
|
48
|
+
|
49
|
+
desc 'Database name'
|
50
|
+
arg_name 'NAME'
|
51
|
+
default_value opts.db_name
|
52
|
+
flag [:n, :dbname]
|
53
|
+
|
54
|
+
desc '(Debug) Show debug messages'
|
55
|
+
switch [:verbose], negatable: false ## todo: use -w for short form? check ruby interpreter if in use too?
|
56
|
+
|
57
|
+
desc 'Only show warnings, errors and fatal messages'
|
58
|
+
switch [:q, :quiet], negatable: false
|
47
59
|
|
48
|
-
global_option '-q', '--quiet', "Only show warnings, errors and fatal messages"
|
49
|
-
### todo/fix: just want --debug/--verbose flag (no single letter option wanted) - fix
|
50
|
-
global_option '-w', '--verbose', "Show debug messages"
|
51
60
|
|
52
61
|
|
53
62
|
def connect_to_db( options )
|
@@ -69,144 +78,144 @@ def connect_to_db( options )
|
|
69
78
|
end
|
70
79
|
|
71
80
|
|
72
|
-
|
73
|
-
|
74
|
-
c.
|
75
|
-
|
81
|
+
desc 'Create DB schema'
|
82
|
+
command [:create] do |c|
|
83
|
+
c.action do |g,o,args|
|
84
|
+
|
85
|
+
connect_to_db( opts )
|
86
|
+
|
87
|
+
LogDb.create
|
88
|
+
ConfDb.create
|
89
|
+
TagDb.create
|
90
|
+
WorldDb.create
|
76
91
|
|
77
|
-
|
78
|
-
|
92
|
+
puts 'Done.'
|
93
|
+
end # action
|
94
|
+
end # command create
|
95
|
+
|
96
|
+
|
97
|
+
desc "Create DB schema 'n' load all world data"
|
98
|
+
arg_name 'NAME' # optional setup profile name
|
99
|
+
command [:setup,:s] do |c|
|
100
|
+
|
101
|
+
c.desc 'World data path'
|
102
|
+
c.arg_name 'PATH'
|
103
|
+
c.default_value opts.data_path
|
104
|
+
c.flag [:i,:include]
|
79
105
|
|
80
|
-
|
81
|
-
|
106
|
+
c.action do |g,o,args|
|
107
|
+
|
108
|
+
connect_to_db( opts )
|
109
|
+
|
110
|
+
## todo: document optional setup profile arg (defaults to all)
|
111
|
+
setup = args[0] || 'all'
|
82
112
|
|
83
113
|
LogDb.create
|
114
|
+
ConfDb.create
|
115
|
+
TagDb.create
|
84
116
|
WorldDb.create
|
117
|
+
|
118
|
+
WorldDb.read_setup( "setups/#{setup}", opts.data_path )
|
119
|
+
|
85
120
|
puts 'Done.'
|
86
121
|
end # action
|
87
|
-
end # command
|
122
|
+
end # command setup
|
88
123
|
|
89
|
-
|
90
|
-
|
91
|
-
|
124
|
+
desc 'Update all world data'
|
125
|
+
arg_name 'NAME' # optional setup profile name
|
126
|
+
command [:update,:up,:u] do |c|
|
92
127
|
|
93
|
-
c.
|
128
|
+
c.desc 'World data path'
|
129
|
+
c.arg_name 'PATH'
|
130
|
+
c.default_value opts.data_path
|
131
|
+
c.flag [:i,:include]
|
94
132
|
|
95
|
-
c.
|
133
|
+
c.desc 'Delete all world data records'
|
134
|
+
c.switch [:delete], negatable: false
|
96
135
|
|
97
|
-
|
98
|
-
LogUtils::Logger.root.level = :debug if options.verbose.present?
|
136
|
+
c.action do |g,o,args|
|
99
137
|
|
100
|
-
|
101
|
-
connect_to_db( myopts )
|
138
|
+
connect_to_db( opts )
|
102
139
|
|
103
|
-
|
104
|
-
|
140
|
+
## todo: document optional setup profile arg (defaults to all)
|
141
|
+
setup = args[0] || 'all'
|
142
|
+
|
143
|
+
if o[:delete].present?
|
144
|
+
## todo/fix: also delete TagDb.delete!
|
105
145
|
WorldDb.delete!
|
106
|
-
else
|
107
|
-
LogDb.create
|
108
|
-
WorldDb.create
|
109
146
|
end
|
110
147
|
|
111
|
-
WorldDb.
|
148
|
+
WorldDb.read_setup( "setups/#{setup}", opts.data_path )
|
149
|
+
|
112
150
|
puts 'Done.'
|
113
151
|
end # action
|
114
|
-
end
|
152
|
+
end # command setup
|
115
153
|
|
116
|
-
command :load do |c|
|
117
|
-
## todo: how to specify many fixutes <>... ??? in syntax
|
118
|
-
c.syntax = 'worlddb load [options] <fixtures>'
|
119
|
-
c.description = 'Load fixtures'
|
120
154
|
|
121
|
-
c.option '--country KEY', String, "Default country for regions 'n' cities"
|
122
|
-
|
123
|
-
### todd/check - type flags still needed? dispatch using name and convention?
|
124
|
-
c.option '--countries', 'Use country plain text fixture reader'
|
125
|
-
c.option '--regions', 'Use regions plain text fixture reader'
|
126
|
-
c.option '--cities', 'Use cities plain text fixture reader'
|
127
155
|
|
128
|
-
|
156
|
+
desc 'Load world fixtures'
|
157
|
+
arg_name 'NAME' # multiple fixture names - todo/fix: use multiple option
|
158
|
+
command [:load, :l] do |c|
|
129
159
|
|
130
|
-
c.
|
160
|
+
c.desc 'Delete all world data records'
|
161
|
+
c.switch [:delete], negatable: false
|
131
162
|
|
132
|
-
|
133
|
-
LogUtils::Logger.root.level = :debug if options.verbose.present?
|
163
|
+
c.action do |g,o,args|
|
134
164
|
|
135
|
-
|
136
|
-
connect_to_db( myopts )
|
165
|
+
connect_to_db( opts )
|
137
166
|
|
138
|
-
|
167
|
+
if o[:delete].present?
|
168
|
+
## todo/fix: also delete TagDb.delete!
|
169
|
+
WorldDb.delete!
|
170
|
+
end
|
171
|
+
|
172
|
+
reader = WorldDb::Reader.new( opts.data_path )
|
139
173
|
|
140
|
-
# read plain text country/region/city fixtures
|
141
|
-
reader = WorldDb::Reader.new( myopts.data_path )
|
142
174
|
args.each do |arg|
|
143
|
-
name = arg
|
144
|
-
|
145
|
-
if myopts.countries?
|
146
|
-
reader.load_countries( name )
|
147
|
-
elsif myopts.regions?
|
148
|
-
reader.load_regions( myopts.country, name )
|
149
|
-
elsif myopts.cities?
|
150
|
-
reader.load_cities( myopts.country, name )
|
151
|
-
else
|
152
|
-
reader.load( name )
|
153
|
-
## todo: issue a warning here; no fixture type specified; assume country?
|
154
|
-
end
|
155
|
-
|
175
|
+
name = arg # File.basename( arg, '.*' )
|
176
|
+
reader.load( name )
|
156
177
|
end # each arg
|
157
|
-
|
178
|
+
|
158
179
|
puts 'Done.'
|
159
180
|
end
|
160
181
|
end # command load
|
161
182
|
|
162
183
|
|
184
|
+
desc 'Show stats'
|
163
185
|
command :stats do |c|
|
164
|
-
c.
|
165
|
-
c.description = 'Show stats'
|
166
|
-
c.action do |args, options|
|
186
|
+
c.action do |g,o,args|
|
167
187
|
|
168
|
-
|
169
|
-
LogUtils::Logger.root.level = :debug if options.verbose.present?
|
188
|
+
connect_to_db( opts )
|
170
189
|
|
171
|
-
myopts.merge_commander_options!( options.__hash__ )
|
172
|
-
connect_to_db( myopts )
|
173
|
-
|
174
190
|
WorldDb.tables
|
175
|
-
|
191
|
+
TagDb.tables
|
192
|
+
|
176
193
|
puts 'Done.'
|
177
194
|
end
|
178
195
|
end
|
179
196
|
|
180
197
|
|
198
|
+
desc 'Show props'
|
181
199
|
command :props do |c|
|
182
|
-
c.
|
183
|
-
c.description = 'Show props'
|
184
|
-
c.action do |args, options|
|
200
|
+
c.action do |g,o,args|
|
185
201
|
|
186
|
-
|
187
|
-
LogUtils::Logger.root.level = :debug if options.verbose.present?
|
188
|
-
|
189
|
-
myopts.merge_commander_options!( options.__hash__ )
|
190
|
-
connect_to_db( myopts )
|
202
|
+
connect_to_db( opts )
|
191
203
|
|
204
|
+
### fix: use ConfDb.dump or similar (for reuse) !!!
|
192
205
|
WorldDb.props
|
193
|
-
|
206
|
+
|
194
207
|
puts 'Done.'
|
195
208
|
end
|
196
209
|
end
|
197
210
|
|
198
211
|
|
212
|
+
desc 'Show logs'
|
199
213
|
command :logs do |c|
|
200
|
-
c.
|
201
|
-
c.description = 'Show logs'
|
202
|
-
c.action do |args, options|
|
214
|
+
c.action do |g,o,args|
|
203
215
|
|
204
|
-
|
205
|
-
LogUtils::Logger.root.level = :debug if options.verbose.present?
|
216
|
+
connect_to_db( opts )
|
206
217
|
|
207
|
-
|
208
|
-
connect_to_db( myopts )
|
209
|
-
|
218
|
+
### fix: use LogDb.dump or similar (for reuse) !!!!
|
210
219
|
LogDb::Models::Log.all.each do |log|
|
211
220
|
puts "[#{log.level}] -- #{log.msg}"
|
212
221
|
end
|
@@ -216,18 +225,57 @@ command :logs do |c|
|
|
216
225
|
end
|
217
226
|
|
218
227
|
|
219
|
-
|
228
|
+
desc '(Debug) Test command suite'
|
220
229
|
command :test do |c|
|
221
|
-
c.
|
222
|
-
|
223
|
-
c.action do |args, options|
|
230
|
+
c.action do |g,o,args|
|
231
|
+
|
224
232
|
puts "hello from test command"
|
225
233
|
puts "args (#{args.class.name}):"
|
226
234
|
pp args
|
227
|
-
puts "
|
228
|
-
pp
|
229
|
-
puts "
|
230
|
-
pp
|
235
|
+
puts "o (#{o.class.name}):"
|
236
|
+
pp o
|
237
|
+
puts "g (#{g.class.name}):"
|
238
|
+
pp g
|
239
|
+
|
240
|
+
LogUtils::Logger.root.debug 'test debug msg'
|
241
|
+
LogUtils::Logger.root.info 'test info msg'
|
242
|
+
LogUtils::Logger.root.warn 'test warn msg'
|
243
|
+
|
231
244
|
puts 'Done.'
|
232
245
|
end
|
233
246
|
end
|
247
|
+
|
248
|
+
|
249
|
+
pre do |g,c,o,args|
|
250
|
+
opts.merge_gli_options!( g )
|
251
|
+
opts.merge_gli_options!( o )
|
252
|
+
|
253
|
+
puts WorldDb.banner
|
254
|
+
|
255
|
+
if opts.verbose?
|
256
|
+
LogUtils::Logger.root.level = :debug
|
257
|
+
end
|
258
|
+
|
259
|
+
logger.debug "Executing #{c.name}"
|
260
|
+
true
|
261
|
+
end
|
262
|
+
|
263
|
+
post do |global,c,o,args|
|
264
|
+
logger.debug "Executed #{c.name}"
|
265
|
+
true
|
266
|
+
end
|
267
|
+
|
268
|
+
|
269
|
+
on_error do |e|
|
270
|
+
puts
|
271
|
+
puts "*** error: #{e.message}"
|
272
|
+
|
273
|
+
if opts.verbose?
|
274
|
+
puts e.backtrace
|
275
|
+
end
|
276
|
+
|
277
|
+
false # skip default error handling
|
278
|
+
end
|
279
|
+
|
280
|
+
|
281
|
+
exit run(ARGV)
|