Sha256: 8e1fcd693557e9d5c64270c9880f9c7e836e206aff96fcde5ae74bf1f42b8947
Contents?: true
Size: 1.51 KB
Versions: 42
Compression:
Stored size: 1.51 KB
Contents
## for use to run with interactive ruby (irb) ## e.g. irb -r sportdb/console require 'beerdb' # some ruby stdlibs require 'logger' require 'pp' # pretty printer require 'uri' require 'json' require 'yaml' ## shortcuts for models Beer = BeerDb::Models::Beer Brewery = BeerDb::Models::Brewery Tag = WorldDb::Models::Tag Tagging = WorldDb::Models::Tagging Continent = WorldDb::Models::Continent Country = WorldDb::Models::Country Region = WorldDb::Models::Region City = WorldDb::Models::City Prop = WorldDb::Models::Prop ## connect to db DB_CONFIG = { adapter: 'sqlite3', database: 'beer.db' } pp DB_CONFIG ActiveRecord::Base.establish_connection( DB_CONFIG ) ## test drive puts "Welcome to beer.db, version #{BeerDb::VERSION} (world.db, version #{WorldDb::VERSION})!" BeerDb.tables puts "Ready." ## add some predefined shortcuts ##### some countries AT = Country.find_by_key( 'at' ) DE = Country.find_by_key( 'de' ) EN = Country.find_by_key( 'en' ) US = Country.find_by_key( 'us' ) MX = Country.find_by_key( 'mx' ) ### some cities WIEN = City.find_by_key( 'wien' ) ### some regions NO = Region.find_by_key_and_country_id( 'no', AT.id ) # at - niederoesterreich OO = Region.find_by_key_and_country_id( 'oo', AT.id ) # at - oberoesterreich #### some beers ## to be done ### some breweries OTTAKRINGER = Brewery.find_by_key( 'ottakringer' ) SCHWECHAT = Brewery.find_by_key( 'schwechat' ) ## turn on activerecord logging to console ActiveRecord::Base.logger = Logger.new( STDOUT )
Version data entries
42 entries across 42 versions & 1 rubygems
Version | Path |
---|---|
beerdb-0.3.0 | lib/beerdb/console.rb |
beerdb-0.2.0 | lib/beerdb/console.rb |