beerdb 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +3 -14
- data/README.md +2 -2
- data/lib/beerdb/cli/main.rb +12 -6
- data/lib/beerdb/deleter.rb +8 -5
- data/lib/beerdb/models/beer.rb +4 -18
- data/lib/beerdb/models/brewery.rb +11 -14
- data/lib/beerdb/models/forward.rb +6 -5
- data/lib/beerdb/models/world/city.rb +14 -0
- data/lib/beerdb/models/{country.rb → world/country.rb} +0 -0
- data/lib/beerdb/models/world/region.rb +14 -0
- data/lib/beerdb/reader.rb +11 -5
- data/lib/beerdb/schema.rb +11 -104
- data/lib/beerdb/stats.rb +11 -12
- data/lib/beerdb/version.rb +15 -2
- data/lib/beerdb.rb +12 -184
- data/test/helper.rb +2 -11
- data/test/test_fixture_matchers.rb +0 -1
- metadata +27 -38
- data/lib/beerdb/models/bookmark.rb +0 -33
- data/lib/beerdb/models/city.rb +0 -14
- data/lib/beerdb/models/drink.rb +0 -25
- data/lib/beerdb/models/note.rb +0 -15
- data/lib/beerdb/models/region.rb +0 -14
- data/lib/beerdb/models/user.rb +0 -29
- data/lib/beerdb/server/public/style.css +0 -36
- data/lib/beerdb/server/views/_debug.erb +0 -17
- data/lib/beerdb/server/views/_version.erb +0 -7
- data/lib/beerdb/server/views/debug.erb +0 -3
- data/lib/beerdb/server/views/index.erb +0 -156
- data/lib/beerdb/server/views/layout.erb +0 -15
- data/lib/beerdb/server.rb +0 -248
data/Manifest.txt
CHANGED
@@ -9,28 +9,17 @@ lib/beerdb/cli/opts.rb
|
|
9
9
|
lib/beerdb/console.rb
|
10
10
|
lib/beerdb/deleter.rb
|
11
11
|
lib/beerdb/models/beer.rb
|
12
|
-
lib/beerdb/models/bookmark.rb
|
13
12
|
lib/beerdb/models/brand.rb
|
14
13
|
lib/beerdb/models/brewery.rb
|
15
|
-
lib/beerdb/models/city.rb
|
16
|
-
lib/beerdb/models/country.rb
|
17
|
-
lib/beerdb/models/drink.rb
|
18
14
|
lib/beerdb/models/forward.rb
|
19
|
-
lib/beerdb/models/note.rb
|
20
|
-
lib/beerdb/models/region.rb
|
21
15
|
lib/beerdb/models/tag.rb
|
22
|
-
lib/beerdb/models/
|
16
|
+
lib/beerdb/models/world/city.rb
|
17
|
+
lib/beerdb/models/world/country.rb
|
18
|
+
lib/beerdb/models/world/region.rb
|
23
19
|
lib/beerdb/reader.rb
|
24
20
|
lib/beerdb/schema.rb
|
25
21
|
lib/beerdb/serializers/beer.rb
|
26
22
|
lib/beerdb/serializers/brewery.rb
|
27
|
-
lib/beerdb/server.rb
|
28
|
-
lib/beerdb/server/public/style.css
|
29
|
-
lib/beerdb/server/views/_debug.erb
|
30
|
-
lib/beerdb/server/views/_version.erb
|
31
|
-
lib/beerdb/server/views/debug.erb
|
32
|
-
lib/beerdb/server/views/index.erb
|
33
|
-
lib/beerdb/server/views/layout.erb
|
34
23
|
lib/beerdb/stats.rb
|
35
24
|
lib/beerdb/version.rb
|
36
25
|
test/helper.rb
|
data/README.md
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
beer.db Command Line Tool in Ruby
|
4
4
|
|
5
|
-
* home :: [github.com/
|
6
|
-
* bugs :: [github.com/
|
5
|
+
* home :: [github.com/beerkit/beer.db.ruby](https://github.com/beerkit/beer.db.ruby)
|
6
|
+
* bugs :: [github.com/beerkit/beer.db.ruby/issues](https://github.com/beerkit/beer.db.ruby/issues)
|
7
7
|
* gem :: [rubygems.org/gems/beerdb](https://rubygems.org/gems/beerdb)
|
8
8
|
* rdoc :: [rubydoc.info/gems/beerdb](http://rubydoc.info/gems/beerdb)
|
9
9
|
* forum :: [groups.google.com/group/beerdb](https://groups.google.com/group/beerdb)
|
data/lib/beerdb/cli/main.rb
CHANGED
@@ -79,6 +79,8 @@ command [:create] do |c|
|
|
79
79
|
BeerDb::CreateDbExtrasDrinks.new.up
|
80
80
|
else
|
81
81
|
LogDb.create
|
82
|
+
ConfDb.create
|
83
|
+
TagDb.create
|
82
84
|
WorldDb.create
|
83
85
|
BeerDb.create
|
84
86
|
end
|
@@ -108,9 +110,11 @@ command [:setup,:s] do |c|
|
|
108
110
|
setup = args[0] || 'all'
|
109
111
|
|
110
112
|
LogDb.create
|
113
|
+
ConfDb.create
|
114
|
+
TagDb.create
|
111
115
|
WorldDb.create
|
112
116
|
BeerDb.create
|
113
|
-
|
117
|
+
|
114
118
|
WorldDb.read_all( opts.world_data_path )
|
115
119
|
BeerDb.read_setup( "setups/#{setup}", opts.data_path )
|
116
120
|
puts 'Done.'
|
@@ -182,7 +186,7 @@ command [:serve,:server] do |c|
|
|
182
186
|
connect_to_db( opts )
|
183
187
|
|
184
188
|
# NB: server (HTTP service) not included in standard default require
|
185
|
-
require 'beerdb/
|
189
|
+
require 'beerdb/service'
|
186
190
|
|
187
191
|
# make sure connections get closed after every request e.g.
|
188
192
|
#
|
@@ -192,18 +196,18 @@ command [:serve,:server] do |c|
|
|
192
196
|
#
|
193
197
|
|
194
198
|
puts 'before add middleware ConnectionManagement'
|
195
|
-
BeerDb::
|
199
|
+
BeerDb::Service.use ActiveRecord::ConnectionAdapters::ConnectionManagement
|
196
200
|
puts 'after add middleware ConnectionManagement'
|
197
201
|
## todo: check if we can check on/dump middleware stack
|
198
202
|
|
199
203
|
## rack middleware might not work with multi-threaded thin web server; close it ourselfs
|
200
|
-
BeerDb::
|
204
|
+
BeerDb::Service.after do
|
201
205
|
puts " #{Thread.current.object_id} -- make sure db connections gets closed after request"
|
202
206
|
# todo: check if connection is open - how?
|
203
207
|
ActiveRecord::Base.connection.close
|
204
208
|
end
|
205
209
|
|
206
|
-
BeerDb::
|
210
|
+
BeerDb::Service.run!
|
207
211
|
|
208
212
|
puts 'Done.'
|
209
213
|
end
|
@@ -229,12 +233,14 @@ command :props do |c|
|
|
229
233
|
|
230
234
|
connect_to_db( opts )
|
231
235
|
|
232
|
-
|
236
|
+
### fix: use ConfDb.props or similar !!!
|
237
|
+
### BeerDb.props
|
233
238
|
|
234
239
|
puts 'Done.'
|
235
240
|
end
|
236
241
|
end
|
237
242
|
|
243
|
+
|
238
244
|
desc 'Show logs'
|
239
245
|
command :logs do |c|
|
240
246
|
c.action do |g,o,args|
|
data/lib/beerdb/deleter.rb
CHANGED
@@ -4,15 +4,18 @@ module BeerDb
|
|
4
4
|
|
5
5
|
class Deleter
|
6
6
|
|
7
|
-
include
|
7
|
+
include Models
|
8
8
|
|
9
9
|
def run
|
10
10
|
# for now delete all tables
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
### fix: use if defined? BeerDbNote or similar or/and check if table exist ??
|
13
|
+
### or move to beerdb-note ??
|
14
|
+
|
15
|
+
## Bookmark.delete_all # db model extension - move to its own addon?
|
16
|
+
## Drink.delete_all # db model extension - move to its own addon?
|
17
|
+
## Note.delete_all # db model extension - move to its own addon?
|
18
|
+
## User.delete_all # db model extension - move to its own addon?
|
16
19
|
|
17
20
|
Beer.delete_all
|
18
21
|
Brand.delete_all
|
data/lib/beerdb/models/beer.rb
CHANGED
@@ -19,9 +19,6 @@ class Beer < ActiveRecord::Base
|
|
19
19
|
belongs_to :brewery, :class_name => 'BeerDb::Model::Brewery', :foreign_key => 'brewery_id'
|
20
20
|
|
21
21
|
|
22
|
-
## has_many :taggings, :as => :taggable, :class_name => 'WorldDb::Model::Tagging'
|
23
|
-
## has_many :tags, :through => :taggings, :class_name => 'WorldDb::Model::Tag'
|
24
|
-
|
25
22
|
has_many :taggings, class_name: 'TagDb::Model::Tagging', :as => :taggable
|
26
23
|
has_many :tags, class_name: 'TagDb::Model::Tag', :through => :taggings
|
27
24
|
|
@@ -41,22 +38,10 @@ class Beer < ActiveRecord::Base
|
|
41
38
|
########
|
42
39
|
|
43
40
|
|
44
|
-
def self.rnd # find random beer - fix: use "generic" activerecord helper and include/extend class
|
45
|
-
rnd_offset = rand( Beer.count ) ## NB: call "global" std lib rand
|
46
|
-
Beer.offset( rnd_offset ).limit( 1 )
|
47
|
-
end
|
48
|
-
|
49
41
|
### support old names (read-only) for now (remove later)
|
50
42
|
|
51
|
-
def color
|
52
|
-
|
53
|
-
srm
|
54
|
-
end
|
55
|
-
|
56
|
-
def plato
|
57
|
-
puts "*** depreceated fn api - use og"
|
58
|
-
og
|
59
|
-
end
|
43
|
+
def color() puts "*** depreceated fn api - use srm"; srm; end
|
44
|
+
def plato() puts "*** depreceated fn api - use og"; og; end
|
60
45
|
|
61
46
|
def color=(value)
|
62
47
|
puts "*** depreceated fn api - use srm="
|
@@ -67,7 +52,8 @@ class Beer < ActiveRecord::Base
|
|
67
52
|
puts "*** depreceated fn api - use og="
|
68
53
|
self.og = value
|
69
54
|
end
|
70
|
-
|
55
|
+
|
56
|
+
|
71
57
|
def as_json_v2( opts={} )
|
72
58
|
# NB: do NOT overwrite "default" / builtin as_json, thus, lets use as_json_v2
|
73
59
|
BeerSerializer.new( self ).as_json
|
@@ -21,9 +21,6 @@ class Brewery < ActiveRecord::Base
|
|
21
21
|
has_many :beers, :class_name => 'BeerDb::Model::Beer', :foreign_key => 'brewery_id'
|
22
22
|
has_many :brands, :class_name => 'BeerDb::Model::Brand', :foreign_key => 'brand_id'
|
23
23
|
|
24
|
-
## has_many :taggings, :as => :taggable, :class_name => 'WorldDb::Model::Tagging'
|
25
|
-
## has_many :tags, :through => :taggings, :class_name => 'WorldDb::Model::Tag'
|
26
|
-
|
27
24
|
has_many :taggings, class_name: 'TagDb::Model::Tagging', :as => :taggable
|
28
25
|
has_many :tags, class_name: 'TagDb::Model::Tag', :through => :taggings
|
29
26
|
|
@@ -31,21 +28,21 @@ class Brewery < ActiveRecord::Base
|
|
31
28
|
validates :key, :format => { :with => /\A[a-z][a-z0-9]+\z/, :message => 'expected two or more lowercase letters a-z or 0-9 digits' }
|
32
29
|
|
33
30
|
|
34
|
-
|
35
|
-
rnd_offset = rand( Brewery.count ) ## NB: call "global" std lib rand
|
36
|
-
Brewery.offset( rnd_offset ).limit( 1 )
|
37
|
-
end
|
31
|
+
### support old names (read-only) for now (remove later ??)
|
38
32
|
|
33
|
+
def founded() since; end
|
34
|
+
def founded=(value) self.since = value; end
|
39
35
|
|
40
|
-
|
36
|
+
def opened() since; end
|
37
|
+
def openend=(value) self.since = value; end
|
38
|
+
|
39
|
+
def m?() prod_m == true; end
|
40
|
+
def l?() prod_l == true; end
|
41
|
+
|
42
|
+
## TODO: activerecord supplies brewpub? already? same as attrib; check w/ test case (and remove here)
|
43
|
+
def brewpub?() brewpub == true; end
|
41
44
|
|
42
|
-
def founded
|
43
|
-
since
|
44
|
-
end
|
45
45
|
|
46
|
-
def founded=(value)
|
47
|
-
self.since = value
|
48
|
-
end
|
49
46
|
|
50
47
|
def as_json_v2( opts={} )
|
51
48
|
# NB: do NOT overwrite "default" / builtin as_json, thus, lets use as_json_v2
|
@@ -24,15 +24,16 @@ module BeerDb
|
|
24
24
|
class Brand < ActiveRecord::Base ; end
|
25
25
|
class Brewery < ActiveRecord::Base ; end
|
26
26
|
|
27
|
-
class User < ActiveRecord::Base ; end
|
28
|
-
class Bookmark < ActiveRecord::Base ; end
|
29
|
-
class Drink < ActiveRecord::Base ; end
|
30
|
-
class Note < ActiveRecord::Base ; end
|
31
|
-
|
32
27
|
end # module Model
|
28
|
+
|
29
|
+
## convenience alias (for better english ;-) )
|
30
|
+
## lets you use => include Models (instead of include Model)
|
31
|
+
Models = Model
|
32
|
+
|
33
33
|
end # module BeerDb
|
34
34
|
|
35
35
|
|
36
|
+
|
36
37
|
module WorldDb
|
37
38
|
module Model
|
38
39
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module WorldDb
|
4
|
+
module Model
|
5
|
+
|
6
|
+
class City
|
7
|
+
has_many :beers, :class_name => 'BeerDb::Model::Beer', :foreign_key => 'city_id'
|
8
|
+
has_many :brands, :class_name => 'BeerDb::Model::Brand', :foreign_key => 'city_id'
|
9
|
+
has_many :breweries, :class_name => 'BeerDb::Model::Brewery', :foreign_key => 'city_id'
|
10
|
+
end # class Country
|
11
|
+
|
12
|
+
end # module Model
|
13
|
+
end # module WorldDb
|
14
|
+
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module WorldDb
|
4
|
+
module Model
|
5
|
+
|
6
|
+
class Region
|
7
|
+
has_many :beers, :class_name => 'BeerDb::Model::Beer', :foreign_key => 'region_id'
|
8
|
+
has_many :brands, :class_name => 'BeerDb::Model::Brand', :foreign_key => 'region_id'
|
9
|
+
has_many :breweries, :class_name => 'BeerDb::Model::Brewery', :foreign_key => 'region_id'
|
10
|
+
end # class Region
|
11
|
+
|
12
|
+
end # module Model
|
13
|
+
end # module WorldDb
|
14
|
+
|
data/lib/beerdb/reader.rb
CHANGED
@@ -21,7 +21,6 @@ module Matcher
|
|
21
21
|
match_xxx_for_country_n_region( name, 'breweries', &blk )
|
22
22
|
end
|
23
23
|
|
24
|
-
## todo: autoadd brewpub flag!! use more_attribs??
|
25
24
|
def match_brewpubs_for_country( name, &blk )
|
26
25
|
match_xxx_for_country( name, 'brewpubs', &blk )
|
27
26
|
end
|
@@ -80,12 +79,10 @@ class Reader
|
|
80
79
|
load_breweries_for_country( country_key, name )
|
81
80
|
end
|
82
81
|
elsif match_brewpubs_for_country_n_region( name ) do |country_key, region_key|
|
83
|
-
|
84
|
-
load_breweries_for_country_n_region( country_key, region_key, name )
|
82
|
+
load_breweries_for_country_n_region( country_key, region_key, name, brewpub: true )
|
85
83
|
end
|
86
84
|
elsif match_brewpubs_for_country( name ) do |country_key|
|
87
|
-
|
88
|
-
load_breweries_for_country( country_key, name )
|
85
|
+
load_breweries_for_country( country_key, name, brewpub: true )
|
89
86
|
end
|
90
87
|
else
|
91
88
|
logger.error "unknown beer.db fixture type >#{name}<"
|
@@ -202,6 +199,15 @@ class Reader
|
|
202
199
|
end
|
203
200
|
|
204
201
|
def load_breweries_worker( name, more_attribs={} )
|
202
|
+
|
203
|
+
if name =~ /\(m\)/ # check for (m) mid-size/medium marker -todo- use $?? must be last?
|
204
|
+
more_attribs[ :prod_m ] = true
|
205
|
+
elsif name =~ /\(l\)/ # check for (l) large marker - todo - use $?? must be last?
|
206
|
+
more_attribs[ :prod_l ] = true
|
207
|
+
else
|
208
|
+
## no marker; do nothing
|
209
|
+
end
|
210
|
+
|
205
211
|
reader = ValuesReaderV2.new( name, include_path, more_attribs )
|
206
212
|
|
207
213
|
reader.each_line do |new_attributes, values|
|
data/lib/beerdb/schema.rb
CHANGED
@@ -3,110 +3,8 @@
|
|
3
3
|
module BeerDb
|
4
4
|
|
5
5
|
|
6
|
-
### some more optional migrations
|
7
|
-
#
|
8
|
-
# see beer.db.admin (copied for possible service/api version only)
|
9
|
-
|
10
|
-
|
11
|
-
####
|
12
|
-
# tasting notes (w/ ratings)
|
13
|
-
class CreateDbExtrasNotes < ActiveRecord::Migration
|
14
|
-
|
15
|
-
def up
|
16
|
-
create_table :notes do |t| # join table (user,beer)
|
17
|
-
t.references :beer, :null => false
|
18
|
-
t.references :user, :null => false
|
19
|
-
t.integer :rating, :null => false # 1-10 scala (10 is best)
|
20
|
-
|
21
|
-
t.text :comments
|
22
|
-
t.string :place # location (place) where tasted/drunken
|
23
|
-
|
24
|
-
## todo: add flag for bottle, can, draft
|
25
|
-
|
26
|
-
t.timestamps
|
27
|
-
end
|
28
|
-
end # method up
|
29
|
-
|
30
|
-
def down
|
31
|
-
raise ActiveRecord::IrreversibleMigration
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
#################
|
38
|
-
# +1 - beer drink log; track beers
|
39
|
-
class CreateDbExtrasDrinks < ActiveRecord::Migration
|
40
|
-
|
41
|
-
def up
|
42
|
-
create_table :drinks do |t| # join table (user,beer)
|
43
|
-
t.references :beer, :null => false
|
44
|
-
t.references :user, :null => false
|
45
|
-
t.datetime :drunk_at ## , :null => false # todo: pre-set if nil to created_at?
|
46
|
-
|
47
|
-
t.string :place # location (place) where tasted/drunken
|
48
|
-
|
49
|
-
## todo: add flag for bottle, can, draft
|
50
|
-
|
51
|
-
t.timestamps
|
52
|
-
end
|
53
|
-
end # method up
|
54
|
-
|
55
|
-
def down
|
56
|
-
raise ActiveRecord::IrreversibleMigration
|
57
|
-
end
|
58
|
-
|
59
|
-
end # class CreateDrinks
|
60
|
-
|
61
|
-
class CreateDbExtrasBookmarks < ActiveRecord::Migration
|
62
|
-
|
63
|
-
def up
|
64
|
-
create_table :bookmarks do |t| # join table (user,beer/brewery)
|
65
|
-
t.references :bookmarkable, :polymorphic => true # todo: check add :null => false is possible/needed?
|
66
|
-
t.references :user, :null => false
|
67
|
-
t.boolean :yes, :null => false, :default => false # like/favorite/top
|
68
|
-
t.boolean :no, :null => false, :default => false # dislike/flop/blacklisted
|
69
|
-
t.boolean :wish, :null => false, :default => false # e.g wish == false == drunk / wishlist (beer not yet drunken/tasted)
|
70
|
-
|
71
|
-
t.timestamps
|
72
|
-
end
|
73
|
-
end # method up
|
74
|
-
|
75
|
-
def down
|
76
|
-
raise ActiveRecord::IrreversibleMigration
|
77
|
-
end
|
78
|
-
|
79
|
-
end # class CreateBookmarks
|
80
|
-
|
81
|
-
|
82
|
-
class CreateDbExtrasUsers < ActiveRecord::Migration
|
83
|
-
|
84
|
-
def up
|
85
|
-
create_table :users do |t|
|
86
|
-
t.string :key, :null => false # import/export key
|
87
|
-
t.string :name, :null => false
|
88
|
-
t.string :email, :null => false
|
89
|
-
t.boolean :admin, :null => false, :default => false
|
90
|
-
t.boolean :guest, :null => false, :default => false
|
91
|
-
t.boolean :active, :null => false, :default => true
|
92
|
-
|
93
|
-
t.timestamps
|
94
|
-
end
|
95
|
-
end # method up
|
96
|
-
|
97
|
-
def down
|
98
|
-
raise ActiveRecord::IrreversibleMigration
|
99
|
-
end
|
100
|
-
|
101
|
-
end # class CreateUsers
|
102
|
-
|
103
|
-
|
104
|
-
#####################
|
105
|
-
# main migration
|
106
|
-
|
107
6
|
class CreateDb < ActiveRecord::Migration
|
108
7
|
|
109
|
-
|
110
8
|
def up
|
111
9
|
|
112
10
|
create_table :beers do |t|
|
@@ -222,11 +120,20 @@ create_table :breweries do |t|
|
|
222
120
|
t.string :synonyms # comma separated list of synonyms
|
223
121
|
t.string :address
|
224
122
|
t.integer :since
|
123
|
+
### fix: rename back to founded or use opened/closed
|
124
|
+
## fix: add flag for ca./about boolean opened_guess / opened_est / opened_??
|
125
|
+
## ca. / about 1010 marker e.g t.boolean : opened_est (for estimate) or similar!!!
|
225
126
|
## renamed to founded to since
|
226
127
|
## t.integer :founded # year founded/established - todo/fix: rename to since?
|
227
128
|
t.integer :closed # optional; year brewery closed
|
228
129
|
|
229
|
-
## todo: add optional parent brewery (owned_by)
|
130
|
+
## todo: add optional parent brewery (owned_by) ???
|
131
|
+
|
132
|
+
t.boolean :brewpub, :null => false, :default => false
|
133
|
+
t.boolean :prod_m, :null => false, :default => false # prod medium (mid-size/regional brewery)
|
134
|
+
# e.g. > 15_000 barrels (us)
|
135
|
+
t.boolean :prod_l, :null => false, :default => false # prod large
|
136
|
+
# e.g. > 500_000 hl (at), > 6_000_000 barrels (us)
|
230
137
|
|
231
138
|
t.integer :prod # (estimated) annual production/capacity in hl (1hl=100l) e.g. megabrewery 2_000_000, microbrewery 1_000 hl; brewbup 500 hl etc.
|
232
139
|
t.integer :prod_grade # 1/2/3/4/5/6/7/8/9/10/11
|
@@ -285,4 +192,4 @@ end
|
|
285
192
|
|
286
193
|
end # class CreateDb
|
287
194
|
|
288
|
-
end # module BeerDb
|
195
|
+
end # module BeerDb
|
data/lib/beerdb/stats.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module BeerDb
|
4
4
|
|
5
5
|
class Stats
|
6
|
-
include
|
6
|
+
include Models
|
7
7
|
|
8
8
|
def tables
|
9
9
|
puts "Stats:"
|
@@ -11,18 +11,17 @@ module BeerDb
|
|
11
11
|
puts " #{'%5d' % Brand.count} brands"
|
12
12
|
puts " #{'%5d' % Brewery.count} breweries"
|
13
13
|
puts
|
14
|
-
puts " #{'%5d' % User.count} users" # db model extension - move to its own addon?
|
15
|
-
puts " #{'%5d' % Bookmark.count} bookmarks" # db model extension - move to its own addon?
|
16
|
-
puts " #{'%5d' % Drink.count} drinks" # db model extension - move to its own addon?
|
17
|
-
puts " #{'%5d' % Note.count} notes" # db model extension - move to its own addon?
|
18
|
-
end
|
19
14
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
### fix: use if defined? BeerDbNote or similar or/and check if table exist ??
|
16
|
+
### or move to beerdb-note ??
|
17
|
+
|
18
|
+
# puts " #{'%5d' % User.count} users" # db model extension - move to its own addon?
|
19
|
+
# puts " #{'%5d' % Bookmark.count} bookmarks" # db model extension - move to its own addon?
|
20
|
+
# puts " #{'%5d' % Drink.count} drinks" # db model extension - move to its own addon?
|
21
|
+
# puts " #{'%5d' % Note.count} notes" # db model extension - move to its own addon?
|
25
22
|
end
|
23
|
+
|
26
24
|
end # class Stats
|
27
25
|
|
28
|
-
end # module BeerDb
|
26
|
+
end # module BeerDb
|
27
|
+
|
data/lib/beerdb/version.rb
CHANGED
@@ -1,7 +1,20 @@
|
|
1
1
|
|
2
2
|
module BeerDb
|
3
|
-
|
4
|
-
|
3
|
+
MAJOR = 0 ## todo: namespace inside version or something - why? why not??
|
4
|
+
MINOR = 9
|
5
|
+
PATCH = 5
|
6
|
+
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
5
7
|
|
8
|
+
def self.version
|
9
|
+
VERSION
|
10
|
+
end
|
6
11
|
|
12
|
+
def self.banner
|
13
|
+
"beerdb/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.root
|
17
|
+
"#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
|
18
|
+
end
|
19
|
+
end # module BeerDb
|
7
20
|
|