Top Level Namespace
Defined Under Namespace
Modules: WorldDb Classes: Time
Constant Summary collapse
- Tag =
shortcuts for models
WorldDb::Models::Tag
- Tagging =
WorldDb::Models::Tagging
- Country =
WorldDb::Models::Country
- Region =
WorldDb::Models::Region
- City =
WorldDb::Models::City
- Prop =
WorldDb::Models::Prop
- 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' )
- WorldDB =
fix: remove old alias for WorldDb
WorldDb
Instance Method Summary collapse
- #connect_to_db(options) ⇒ Object
- #find_world_db_path_from_gemfile_gitref! ⇒ Object
-
#worlddb ⇒ Object
for use to run with interactive ruby (irb) e.g.
Instance Method Details
#connect_to_db(options) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/worlddb/cli/main.rb', line 53 def connect_to_db( ) puts WorldDb. puts "working directory: #{Dir.pwd}" db_config = { :adapter => 'sqlite3', :database => "#{.db_path}/#{.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 |
#find_world_db_path_from_gemfile_gitref! ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/worlddb/data/fixtures.rb', line 4 def find_world_db_path_from_gemfile_gitref! puts "[debug] find_world_db_path..." puts "load path:" pp $LOAD_PATH candidates = [] $LOAD_PATH.each do |path| # nb: avoid matching /world.db.ruby/ (e.g. gem "worlddb", "0.10.0", :path => "../world.db.ruby") if path =~ /\/(world\.db-[a-z0-9]+)|(world\.db)\// candidates << path.dup end end puts "found candidates:" pp candidates cand = candidates[0] puts "cand before: #{cand}" ## nb: *? is non-greedy many operator ## todo: why not just cut off trailing /lib - is it good enough?? # it's easier regex = /(\/world\.db.*?)(\/.*)/ cand = cand.sub( regex ) do |_| puts "cutting off >>#{$2}<<" $1 end puts "cand after: #{cand}" ## todo:exit with error if not found!!! cand end |
#worlddb ⇒ Object
for use to run with interactive ruby (irb)
e.g. irb -r worlddb/console
4 |
# File 'lib/worlddb/console.rb', line 4 require 'worlddb' |