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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9b04e3e102e14c97044c018ad3fdeb210120fcf
4
- data.tar.gz: 7500c45d9013183766d9ef85f24d79238b275ade
3
+ metadata.gz: e0ee622f7795692c31ce82e14cc4f453c42ff5bf
4
+ data.tar.gz: 41f42c5c60836963f8ccd3cfff5578a3e161d941
5
5
  SHA512:
6
- metadata.gz: 7f0dce7d75e23232b6807b8098bee330cf3c57292302fc142978ee0e665f8af22f91479bd51899339caf21ace1f977f2e7f7a81f3abbd99d4e6e598d9b23469a
7
- data.tar.gz: d933d6e0f68f77e00cda45c1771a840414fe04d0ec41cea704984fe82b64a4af7529d8dbd92f51a0a16f3e7d0a741f3a8f9cc468f168f73915621409977bd1c3
6
+ metadata.gz: b3b9cb495f1546e9bc2e4731e0eaaacf8ceca539d3fcb0a38fa32a8ef4463ca4fc1f016d72a3010ea8dd872f158cb7d99e97c6f2f0ac785f8a058ee30f9c212d
7
+ data.tar.gz: 551684e3cce842b078b7daecc1fd4950443ef4d86d29966751f4b3ee07fc228027517a8cc5b31685decee0db23a52507f2e148941361b42df747515a9da839b3
@@ -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
- require 'worlddb/cli/main'
22
- ## Runner.new.run(ARGV) - old code
19
+ exit Tool.new.run(ARGV)
23
20
  end
24
21
 
25
22
  end # module WorldDb
@@ -1,17 +1,49 @@
1
1
  # encoding: utf-8
2
2
 
3
-
4
- include GLI::App
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
- program_desc 'world.db command line tool'
9
+ class Tool
10
+ def initialize
11
+ LogUtils::Logger.root.level = :info # set logging level to info
12
+ end
9
13
 
10
- version WorldDbCli::VERSION
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
- LogUtils::Logger.root.level = :info # set logging level to info
14
- logger = LogUtils::Logger.root
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
+
@@ -6,7 +6,7 @@
6
6
  module WorldDbCli # todo/check - rename to WorldDbTool or WorldDbCommands or WorldDbShell ??
7
7
 
8
8
  MAJOR = 2 ## todo: namespace inside version or something - why? why not??
9
- MINOR = 1
9
+ MINOR = 2
10
10
  PATCH = 0
11
11
  VERSION = [MAJOR,MINOR,PATCH].join('.')
12
12
 
@@ -4,6 +4,7 @@
4
4
  ## for use to run with interactive ruby (irb)
5
5
  ## e.g. irb -r worlddb/console
6
6
 
7
+ require 'logger'
7
8
  require 'worlddb/models'
8
9
 
9
10
 
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.1.0
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-05 00:00:00.000000000 Z
11
+ date: 2014-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: worlddb-models