Module: WineDb

Defined in:
lib/winedb.rb,
lib/winedb/reader.rb,
lib/winedb/schema.rb,
lib/winedb/version.rb,
lib/winedb/models/shop.rb,
lib/winedb/models/wine.rb,
lib/winedb/models/grape.rb,
lib/winedb/models/family.rb,
lib/winedb/models/tavern.rb,
lib/winedb/models/winery.rb,
lib/winedb/models/forward.rb,
lib/winedb/models/variety.rb,
lib/winedb/models/vintage.rb,
lib/winedb/models/vineyard.rb

Defined Under Namespace

Modules: Matcher, Model Classes: CreateDb, Reader

Constant Summary collapse

VERSION =
'0.1.6'
Models =

note: for convenciene (and compatibility) add alias Models for Model namespace

e.g lets you use include WineDb::Models
Model

Class Method Summary collapse

Class Method Details



42
43
44
# File 'lib/winedb.rb', line 42

def self.banner
  "winedb/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
end

.createObject



55
56
57
58
59
# File 'lib/winedb.rb', line 55

def self.create
  CreateDb.new.up

  WineDb::Model::Prop.create!( key: 'db.schema.wine.version', value: VERSION )
end

.data_pathObject



50
51
52
# File 'lib/winedb.rb', line 50

def self.data_path
  "#{root}/data"
end

.delete!Object



82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/winedb.rb', line 82

def self.delete!
  ## fix/todo: move into deleter class (see worlddb,sportdb etc.)
  Model::Grape.delete_all
  Model::Family.delete_all
  Model::Variety.delete_all
  Model::Vineyard.delete_all
  Model::Shop.delete_all
  Model::Tavern.delete_all
  Model::Vintage.delete_all
  Model::Wine.delete_all
  Model::Winery.delete_all
end

.read(ary, include_path) ⇒ Object



62
63
64
65
66
67
# File 'lib/winedb.rb', line 62

def self.read( ary, include_path )
  reader = Reader.new( include_path )
  ary.each do |name|
    reader.load( name )
  end
end

.read_all(include_path, opts = {}) ⇒ Object

load all builtins (using plain text reader); helper for convenience



74
75
76
# File 'lib/winedb.rb', line 74

def self.read_all( include_path, opts={} )  # load all builtins (using plain text reader); helper for convenience
  read_setup( 'setups/all', include_path, opts )
end

.read_builtinObject

method read_all



78
79
80
# File 'lib/winedb.rb', line 78

def self.read_builtin
  read_setup( 'setups/all', data_path )
end

.read_setup(setup, include_path, opts = {}) ⇒ Object



69
70
71
72
# File 'lib/winedb.rb', line 69

def self.read_setup( setup, include_path, opts={} )
  reader = Reader.new( include_path, opts )
  reader.load_setup( setup )
end

.rootObject



46
47
48
# File 'lib/winedb.rb', line 46

def self.root
  "#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
end

.tablesObject



95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/winedb.rb', line 95

def self.tables
  ## fix/todo: move into stats class (see worlddb,sportdb etc.)
  puts "  #{Model::Grape.count} grapes"
  puts "  #{Model::Family.count} (wine) families"
  puts "  #{Model::Variety.count} (wine) varieties"
  puts "  #{Model::Vineyard.count} vineyards"
  puts "  #{Model::Shop.count} shops (vinothek/enotecia)"
  puts "  #{Model::Tavern.count} taverns (heurige)"
  puts "  #{Model::Vintage.count} vintages"
  puts "  #{Model::Wine.count} wines"
  puts "  #{Model::Winery.count} wineries"
end