Module: WorldDb

Defined in:
lib/worlddb/models/forward.rb,
lib/worlddb.rb,
lib/worlddb/stats.rb,
lib/worlddb/reader.rb,
lib/worlddb/schema.rb,
lib/worlddb/deleter.rb,
lib/worlddb/matcher.rb,
lib/worlddb/version.rb,
lib/worlddb/cli/opts.rb,
lib/worlddb/patterns.rb,
lib/worlddb/stats_comp.rb,
lib/worlddb/models/city.rb,
lib/worlddb/models/lang.rb,
lib/worlddb/models/name.rb,
lib/worlddb/models/place.rb,
lib/worlddb/models/usage.rb,
lib/worlddb/readers/base.rb,
lib/worlddb/readers/city.rb,
lib/worlddb/readers/lang.rb,
lib/worlddb/models/region.rb,
lib/worlddb/readers/usage.rb,
lib/worlddb/models/country.rb,
lib/worlddb/readers/region.rb,
lib/worlddb/readers/country.rb,
lib/worlddb/models/city_comp.rb,
lib/worlddb/models/continent.rb,
lib/worlddb/models/lang_comp.rb,
lib/worlddb/models/region_comp.rb,
lib/worlddb/models/country_comp.rb,
lib/worlddb/models/continent_comp.rb

Overview

forward references

require first to resolve circular references

Defined Under Namespace

Modules: Matcher, Model Classes: BaseReader, CityReader, CountryReader, CreateDb, Deleter, LangReader, Opts, Reader, RegionReader, Stats, UsageReader

Constant Summary collapse

VERSION =

sync version w/ sport.db - why? why not?

'2.0.2'
COUNTRY_KEY_PATTERN =

about ruby regexps

try the rubular - Ruby regular expression editor and tester

-> http://rubular.com
 code -> ??  by ??

Jeff Avallone’s Regexper - Shows State-Automata Diagrams

try -> http://regexper.com
  code -> https://github.com/javallone/regexper

Regular Expressions | The Bastards Book of Ruby by Dan Nguyen

ruby.bastardsbook.com/chapters/regexes/

move to notes regex|patterns on geraldb.github.io ??

'^[a-z]{2,3}$'
COUNTRY_KEY_PATTERN_MESSAGE =

allow two AND three letter keys e.g. at, mx, eng, sco, etc.

"expected two or three lowercase letters a-z /#{COUNTRY_KEY_PATTERN}/"
COUNTRY_CODE_PATTERN =
'^[A-Z_]{3}$'
COUNTRY_CODE_PATTERN_MESSAGE =
"expected three uppercase letters A-Z (and _) /#{COUNTRY_CODE_PATTERN}/"
REGION_KEY_PATTERN =
'^[a-z]+$'
REGION_KEY_PATTERN_MESSAGE =
"expected one or more lowercase letters a-z /#{REGION_KEY_PATTERN}/"
REGION_CODE_PATTERN =
'^[A-Z_]{2,3}$'
REGION_CODE_PATTERN_MESSAGE =
"expected two or three uppercase letters A-Z (and _) /#{REGION_CODE_PATTERN}/"
CITY_KEY_PATTERN =
'^[a-z]{3,}$'
CITY_KEY_PATTERN_MESSAGE =
"expected three or more lowercase letters a-z' /#{CITY_KEY_PATTERN}/"
CITY_CODE_PATTERN =
'^[A-Z_]{3}$'
CITY_CODE_PATTERN_MESSAGE =
"expected three uppercase letters A-Z (and _)' /#{CITY_CODE_PATTERN}/"
LANG_KEY_PATTERN =
'^[a-z]{2}$'
LANG_KEY_PATTERN_MESSAGE =
"expected two lowercase letters a-z' /#{LANG_KEY_PATTERN}/"
Models =

note: convenience alias for Model lets you use include WorldDb::Models

Model

Class Method Summary collapse

Class Method Details



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

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

.createObject



83
84
85
86
# File 'lib/worlddb.rb', line 83

def self.create
  CreateDb.new.up
  ConfDb::Model::Prop.create!( key: 'db.schema.world.version', value: VERSION )
end

.delete!Object

delete ALL records (use with care!)



108
109
110
111
# File 'lib/worlddb.rb', line 108

def self.delete!
  puts '*** deleting world table records/data...'
  Deleter.new.run
end

.mainObject



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

def self.main
  require 'worlddb/cli/main'
  ## Runner.new.run(ARGV) - old code
end

.propsObject



125
126
127
128
# File 'lib/worlddb.rb', line 125

def self.props
  ### fix: use ConfDb.props delegate or similar !!!
  Stats.new.props
end

.read(ary, include_path) ⇒ Object



89
90
91
92
93
94
# File 'lib/worlddb.rb', line 89

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



102
103
104
# File 'lib/worlddb.rb', line 102

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_setup(setup, include_path, opts = {}) ⇒ Object



97
98
99
100
# File 'lib/worlddb.rb', line 97

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

.rootObject



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

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

.statsObject

todo: remove stats ??? why? why not? better use .tables



115
116
117
118
119
# File 'lib/worlddb.rb', line 115

def self.stats
  stats = Stats.new
  stats.tables
  ### stats.props
end

.tablesObject



121
122
123
# File 'lib/worlddb.rb', line 121

def self.tables
  Stats.new.tables
end