Top Level Namespace

Includes:
GLI::App

Defined Under Namespace

Modules: TagDb, WorldDb

Constant Summary collapse

Prop =

shortcuts for models

ConfDb::Model::Prop
Tag =
TagDb::Model::Tag
Tagging =
TagDb::Model::Tagging
Continent =
WorldDb::Model::Continent
Country =
WorldDb::Model::Country
Region =
WorldDb::Model::Region
City =
WorldDb::Model::City
DB_CONFIG =

connect to db

{
  adapter:  'sqlite3',
  database: 'world.db'
}
AT =

local variables (e.g. at) not working; use constants instead (e.g. AT)

Country.find_by_key( 'at' )
DE =
Country.find_by_key( 'de' )
EN =
Country.find_by_key( 'en' )
GB =
Country.find_by_key( 'gb' )
EU =
Country.find_by_key( 'eu' )
US =
Country.find_by_key( 'us' )
CA =
Country.find_by_key( 'ca' )
MX =
Country.find_by_key( 'mx' )
NYC =

some cities

City.find_by_key( 'newyork' )
LON =
City.find_by_key( 'london' )
VIE =
City.find_by_key( 'wien' )
EURO =

todo: add some predefined tags (e.g. europe, america, g8, euro, etc.)

Tag.find_by_key( 'euro' )
EUROPE =
Tag.find_by_key( 'europe' )
ASIA =
Tag.find_by_key( 'asia' )
PACIFIC =
Tag.find_by_key( 'pacific' )

Instance Method Summary collapse

Instance Method Details

#active_recordObject

todo: add sqlite3? etc.



22
# File 'lib/worlddb.rb', line 22

require 'active_record'

#connect_to_db(options) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/worlddb/cli/main.rb', line 62

def connect_to_db( options )
  puts WorldDb.banner

  puts "working directory: #{Dir.pwd}"

  db_config = {
    :adapter  => 'sqlite3',
    :database => "#{options.db_path}/#{options.db_name}"
  }

  puts "Connecting to db using settings: "
  pp db_config

  ActiveRecord::Base.establish_connection( db_config )
  
  LogDb.setup  # turn on logging to db
end

#verboseObject

todo: use -w for short form? check ruby interpreter if in use too?



55
# File 'lib/worlddb/cli/main.rb', line 55

switch [:verbose], negatable: false

#worlddbObject

for use to run with interactive ruby (irb)

e.g.  irb -r worlddb/console


4
# File 'lib/worlddb/console.rb', line 4

require 'worlddb'