beerdb 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/Rakefile +2 -1
- data/bin/beerdb +1 -1
- data/lib/beerdb/cli/main.rb +11 -78
- data/lib/beerdb/cli/opts.rb +0 -5
- data/lib/beerdb/cli/version.rb +3 -3
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17f9cc74689ce9d1208acaab5188304387681738
|
4
|
+
data.tar.gz: 66ca767ba0474ff0f8ba87226f07e5466c005bc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85c93d3258a2c2c5ba40e9cf6ea791ff851ed5385f87153d5e5fed5656b3ef22680af9501e1ab951d47af04697bbf16d3fe541209587e1a88864d24ce0d54b38
|
7
|
+
data.tar.gz: b1ad9f90444df6d7070f8191866626780787107d251ec8db1c1102d4aa073e6f50b763cd81a68a5c1d1e787c43e8036adec03bb14c8ba96f0349dd80a33acab6
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require './lib/beerdb/cli/version.rb'
|
|
4
4
|
|
5
5
|
Hoe.spec 'beerdb' do
|
6
6
|
|
7
|
-
self.version =
|
7
|
+
self.version = BeerDbTool::VERSION
|
8
8
|
|
9
9
|
self.summary = 'beerdb - beer.db command line tool'
|
10
10
|
self.description = summary
|
@@ -20,6 +20,7 @@ Hoe.spec 'beerdb' do
|
|
20
20
|
|
21
21
|
self.extra_deps = [
|
22
22
|
['beerdb-models', '>= 1.1.1'],
|
23
|
+
['beerdb-note', '>= 0.0.1' ], ## (auto-)add notes extension / addon too
|
23
24
|
|
24
25
|
['datafile', '>= 0.2.5'],
|
25
26
|
['fetcher', '>= 0.4.5'],
|
data/bin/beerdb
CHANGED
data/lib/beerdb/cli/main.rb
CHANGED
@@ -12,7 +12,7 @@ module BeerDb
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def run( args )
|
15
|
-
puts
|
15
|
+
puts BeerDbTool.banner
|
16
16
|
Toolii.run( args )
|
17
17
|
end
|
18
18
|
end
|
@@ -32,15 +32,8 @@ module BeerDb
|
|
32
32
|
def self.connect_to_db( options )
|
33
33
|
puts "working directory: #{Dir.pwd}"
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
database: "#{options.db_path}/#{options.db_name}"
|
38
|
-
}
|
39
|
-
|
40
|
-
puts "Connecting to db using settings: "
|
41
|
-
pp config
|
42
|
-
|
43
|
-
BeerDb.connect( config )
|
35
|
+
BeerDb.connect( adapter: 'sqlite3',
|
36
|
+
database: "#{options.db_path}/#{options.db_name}" )
|
44
37
|
|
45
38
|
LogDb.setup # start logging to db (that is, save logs in logs table in db)
|
46
39
|
end
|
@@ -53,7 +46,7 @@ opts = BeerDb::Opts.new
|
|
53
46
|
|
54
47
|
|
55
48
|
program_desc 'beer.db command line tool'
|
56
|
-
version
|
49
|
+
version BeerDbTool::VERSION
|
57
50
|
|
58
51
|
|
59
52
|
### global option (required)
|
@@ -110,6 +103,7 @@ command [:read,:r] do |c|
|
|
110
103
|
end # action
|
111
104
|
end # command setup
|
112
105
|
|
106
|
+
|
113
107
|
desc "Download datasets; use ./Datafile - zips get downloaded to ./tmp"
|
114
108
|
command [:download,:dl] do |c|
|
115
109
|
|
@@ -131,7 +125,7 @@ command [:new,:n] do |c|
|
|
131
125
|
|
132
126
|
c.action do |g,o,args|
|
133
127
|
|
134
|
-
## todo: required template name (defaults to
|
128
|
+
## todo: required template name (defaults to at)
|
135
129
|
setup = args[0] || 'at'
|
136
130
|
|
137
131
|
worker = Fetcher::Worker.new
|
@@ -178,33 +172,6 @@ command [:create] do |c|
|
|
178
172
|
end # command create
|
179
173
|
|
180
174
|
|
181
|
-
desc "Create DB schema 'n' load all world and beer data"
|
182
|
-
arg_name 'NAME' # optional setup profile name
|
183
|
-
command [:setup,:s] do |c|
|
184
|
-
|
185
|
-
c.desc 'Beer data path'
|
186
|
-
c.arg_name 'PATH'
|
187
|
-
c.default_value opts.data_path
|
188
|
-
c.flag [:i,:include]
|
189
|
-
|
190
|
-
c.desc 'World data path'
|
191
|
-
c.arg_name 'PATH'
|
192
|
-
c.flag [:worldinclude] ## todo: use --world-include - how? find better name? add :'world-include' ???
|
193
|
-
|
194
|
-
c.action do |g,o,args|
|
195
|
-
|
196
|
-
connect_to_db( opts )
|
197
|
-
|
198
|
-
## todo: document optional setup profile arg (defaults to all)
|
199
|
-
setup = args[0] || 'all'
|
200
|
-
|
201
|
-
BeerDb.create_all
|
202
|
-
|
203
|
-
WorldDb.read_all( opts.world_data_path )
|
204
|
-
BeerDb.read_setup( "setups/#{setup}", opts.data_path )
|
205
|
-
puts 'Done.'
|
206
|
-
end # action
|
207
|
-
end # command setup
|
208
175
|
|
209
176
|
|
210
177
|
desc 'Update all beer data'
|
@@ -261,43 +228,6 @@ end # command load
|
|
261
228
|
|
262
229
|
|
263
230
|
|
264
|
-
## fix/todo: add server alias (serve/server)
|
265
|
-
|
266
|
-
desc 'Start web service (HTTP JSON API)'
|
267
|
-
command [:serve,:server] do |c|
|
268
|
-
|
269
|
-
c.action do |g,o,args|
|
270
|
-
|
271
|
-
connect_to_db( opts )
|
272
|
-
|
273
|
-
# NB: server (HTTP service) not included in standard default require
|
274
|
-
require 'beerdb/service'
|
275
|
-
|
276
|
-
# make sure connections get closed after every request e.g.
|
277
|
-
#
|
278
|
-
# after do
|
279
|
-
# ActiveRecord::Base.connection.close
|
280
|
-
# end
|
281
|
-
#
|
282
|
-
|
283
|
-
puts 'before add middleware ConnectionManagement'
|
284
|
-
BeerDb::Service.use ActiveRecord::ConnectionAdapters::ConnectionManagement
|
285
|
-
puts 'after add middleware ConnectionManagement'
|
286
|
-
## todo: check if we can check on/dump middleware stack
|
287
|
-
|
288
|
-
## rack middleware might not work with multi-threaded thin web server; close it ourselfs
|
289
|
-
BeerDb::Service.after do
|
290
|
-
puts " #{Thread.current.object_id} -- make sure db connections gets closed after request"
|
291
|
-
# todo: check if connection is open - how?
|
292
|
-
ActiveRecord::Base.connection.close
|
293
|
-
end
|
294
|
-
|
295
|
-
BeerDb::Service.run!
|
296
|
-
|
297
|
-
puts 'Done.'
|
298
|
-
end
|
299
|
-
end # command serve
|
300
|
-
|
301
231
|
|
302
232
|
desc 'Show stats'
|
303
233
|
command :stats do |c|
|
@@ -318,8 +248,10 @@ command :props do |c|
|
|
318
248
|
|
319
249
|
connect_to_db( opts )
|
320
250
|
|
321
|
-
|
322
|
-
|
251
|
+
## fix: use ConfDb.dump or similar
|
252
|
+
ConfDb::Models::Prop.all.each do |prop|
|
253
|
+
puts "#{prop.key} | #{prop.value}"
|
254
|
+
end
|
323
255
|
|
324
256
|
puts 'Done.'
|
325
257
|
end
|
@@ -332,6 +264,7 @@ command :logs do |c|
|
|
332
264
|
|
333
265
|
connect_to_db( opts )
|
334
266
|
|
267
|
+
## fix: use LogDb.dump or similar
|
335
268
|
LogDb::Models::Log.all.each do |log|
|
336
269
|
puts "[#{log.level}] -- #{log.msg}"
|
337
270
|
end
|
data/lib/beerdb/cli/opts.rb
CHANGED
@@ -9,7 +9,6 @@ class Opts
|
|
9
9
|
@verbose = true if options[:verbose] == true
|
10
10
|
|
11
11
|
@data_path = options[:include] if options[:include].present?
|
12
|
-
@world_data_path = options[:worldinclude] if options[:worldinclude].present?
|
13
12
|
end
|
14
13
|
|
15
14
|
|
@@ -40,10 +39,6 @@ class Opts
|
|
40
39
|
@data_path || '.'
|
41
40
|
end
|
42
41
|
|
43
|
-
def world_data_path
|
44
|
-
@world_data_path # NB: option has no default; return nil
|
45
|
-
end
|
46
|
-
|
47
42
|
end # class Opts
|
48
43
|
|
49
44
|
end # module BeerDb
|
data/lib/beerdb/cli/version.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
# Note: BeerDb::VERSION gets used by core, that is, beerdb-models
|
4
4
|
|
5
5
|
|
6
|
-
module
|
6
|
+
module BeerDbTool # todo/check - rename to BeerDbCli or BeerDbCommands or BeerDbShell ??
|
7
7
|
|
8
8
|
MAJOR = 1
|
9
9
|
MINOR = 0
|
10
|
-
PATCH =
|
10
|
+
PATCH = 1
|
11
11
|
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
12
12
|
|
13
13
|
def self.version
|
@@ -22,4 +22,4 @@ module BeerDbCli # todo/check - rename to BeerDbTool or BeerDbCommands or Bee
|
|
22
22
|
"#{File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )}"
|
23
23
|
end
|
24
24
|
|
25
|
-
end # module
|
25
|
+
end # module BeerDbTool
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beerdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.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: 2017-08-
|
11
|
+
date: 2017-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: beerdb-models
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: beerdb-note
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.1
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: datafile
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|