worlddb 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/worlddb.rb +2 -5
- data/lib/worlddb/cli/main.rb +43 -26
- data/lib/worlddb/cli/version.rb +1 -1
- data/lib/worlddb/console.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0ee622f7795692c31ce82e14cc4f453c42ff5bf
|
4
|
+
data.tar.gz: 41f42c5c60836963f8ccd3cfff5578a3e161d941
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3b9cb495f1546e9bc2e4731e0eaaacf8ceca539d3fcb0a38fa32a8ef4463ca4fc1f016d72a3010ea8dd872f158cb7d99e97c6f2f0ac785f8a058ee30f9c212d
|
7
|
+
data.tar.gz: 551684e3cce842b078b7daecc1fd4950443ef4d86d29966751f4b3ee07fc228027517a8cc5b31685decee0db23a52507f2e148941361b42df747515a9da839b3
|
data/lib/worlddb.rb
CHANGED
@@ -4,22 +4,19 @@ require 'worlddb/models' # NOTE: depends on core (aka worlddb-models)
|
|
4
4
|
|
5
5
|
|
6
6
|
require 'gli'
|
7
|
-
require 'logutils/activerecord' # add support for logging to db
|
8
|
-
|
9
7
|
|
10
8
|
# our own code
|
11
9
|
|
12
10
|
require 'worlddb/cli/version' # version always goes first
|
13
11
|
|
14
|
-
# additional for cli only
|
15
12
|
require 'worlddb/cli/opts'
|
13
|
+
require 'worlddb/cli/main'
|
16
14
|
|
17
15
|
|
18
16
|
module WorldDb
|
19
17
|
|
20
18
|
def self.main
|
21
|
-
|
22
|
-
## Runner.new.run(ARGV) - old code
|
19
|
+
exit Tool.new.run(ARGV)
|
23
20
|
end
|
24
21
|
|
25
22
|
end # module WorldDb
|
data/lib/worlddb/cli/main.rb
CHANGED
@@ -1,17 +1,49 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
### NOTE: wrap gli config into a class
|
4
|
+
## see github.com/davetron5000/gli/issues/153
|
5
5
|
|
6
6
|
|
7
|
+
module WorldDb
|
7
8
|
|
8
|
-
|
9
|
+
class Tool
|
10
|
+
def initialize
|
11
|
+
LogUtils::Logger.root.level = :info # set logging level to info
|
12
|
+
end
|
9
13
|
|
10
|
-
|
14
|
+
def run( args )
|
15
|
+
puts WorldDbCli.banner
|
16
|
+
|
17
|
+
Toolii.logger = LogUtils::Logger.root
|
18
|
+
Toolii.opts = WorldDb::Opts.new
|
19
|
+
Toolii.run( args )
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
class Toolii
|
25
|
+
extend GLI::App
|
11
26
|
|
27
|
+
def self.logger=(value) @@logger=value; end
|
28
|
+
def self.logger() @@logger; end
|
12
29
|
|
13
|
-
|
14
|
-
|
30
|
+
## todo: find a better name e.g. change to settings? config? safe_opts? why? why not?
|
31
|
+
def self.opts=(value) @@opts = value; end
|
32
|
+
def self.opts() @@opts; end
|
33
|
+
|
34
|
+
def self.connect_to_db( options )
|
35
|
+
puts "working directory: #{Dir.pwd}"
|
36
|
+
|
37
|
+
WorldDb.connect( adapter: 'sqlite3',
|
38
|
+
database: "#{options.db_path}/#{options.db_name}" )
|
39
|
+
|
40
|
+
LogDb.setup # turn on logging to db (that is, log to logs table in db)
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
program_desc 'world.db command line tool'
|
45
|
+
|
46
|
+
version WorldDbCli::VERSION
|
15
47
|
|
16
48
|
=begin
|
17
49
|
### add to help use new sections
|
@@ -28,11 +60,6 @@ Further information:
|
|
28
60
|
=end
|
29
61
|
|
30
62
|
|
31
|
-
|
32
|
-
## todo: find a better name e.g. change to settings? config? safe_opts? why? why not?
|
33
|
-
opts = WorldDb::Opts.new
|
34
|
-
|
35
|
-
|
36
63
|
### global option (required)
|
37
64
|
## todo: add check that path is valid?? possible?
|
38
65
|
|
@@ -54,18 +81,6 @@ switch [:q, :quiet], negatable: false
|
|
54
81
|
|
55
82
|
|
56
83
|
|
57
|
-
def connect_to_db( options )
|
58
|
-
puts WorldDbCli.banner
|
59
|
-
|
60
|
-
puts "working directory: #{Dir.pwd}"
|
61
|
-
|
62
|
-
WorldDb.connect( adapter: 'sqlite3',
|
63
|
-
database: "#{options.db_path}/#{options.db_name}" )
|
64
|
-
|
65
|
-
LogDb.setup # turn on logging to db (that is, log to logs table in db)
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
84
|
desc 'Create DB schema'
|
70
85
|
command [:create] do |c|
|
71
86
|
c.action do |g,o,args|
|
@@ -232,8 +247,6 @@ pre do |g,c,o,args|
|
|
232
247
|
opts.merge_gli_options!( g )
|
233
248
|
opts.merge_gli_options!( o )
|
234
249
|
|
235
|
-
puts WorldDbCli.banner
|
236
|
-
|
237
250
|
if opts.verbose?
|
238
251
|
LogUtils::Logger.root.level = :debug
|
239
252
|
end
|
@@ -260,4 +273,8 @@ on_error do |e|
|
|
260
273
|
end
|
261
274
|
|
262
275
|
|
263
|
-
exit run(ARGV)
|
276
|
+
### exit run(ARGV) ## note: use Toolii.run( ARGV ) outside of class
|
277
|
+
|
278
|
+
end # class Toolii
|
279
|
+
end # module WorldDb
|
280
|
+
|
data/lib/worlddb/cli/version.rb
CHANGED
data/lib/worlddb/console.rb
CHANGED
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.
|
4
|
+
version: 2.2.0
|
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-12-
|
11
|
+
date: 2014-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: worlddb-models
|