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/reader_zip.rb,
lib/worlddb/stats_comp.rb,
lib/worlddb/models/city.rb,
lib/worlddb/models/lang.rb,
lib/worlddb/models/name.rb,
lib/worlddb/reader_file.rb,
lib/worlddb/models/place.rb,
lib/worlddb/models/usage.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: CityReader, CountryReader, CreateDb, Deleter, LangReader, Opts, Reader, ReaderBase, RegionReader, Stats, UsageReader, ZipReader

Constant Summary collapse

MAJOR =

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

2
MINOR =

todo: namespace inside version or something - why? why not??

0
PATCH =
6
VERSION =
[MAJOR,MINOR,PATCH].join('.')
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[a-z]{2,3}\z'
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[A-Z_]{3}\z'
COUNTRY_CODE_PATTERN_MESSAGE =
"expected three uppercase letters A-Z (and _) /#{COUNTRY_CODE_PATTERN}/"
REGION_KEY_PATTERN =
'\A[a-z]+\z'
REGION_KEY_PATTERN_MESSAGE =
"expected one or more lowercase letters a-z /#{REGION_KEY_PATTERN}/"
REGION_CODE_PATTERN =
'\A[A-Z_]{2,3}\z'
REGION_CODE_PATTERN_MESSAGE =
"expected two or three uppercase letters A-Z (and _) /#{REGION_CODE_PATTERN}/"
CITY_KEY_PATTERN =
'\A[a-z]{3,}\z'
CITY_KEY_PATTERN_MESSAGE =
"expected three or more lowercase letters a-z' /#{CITY_KEY_PATTERN}/"
CITY_CODE_PATTERN =
'\A[A-Z_]{3}\z'
CITY_CODE_PATTERN_MESSAGE =
"expected three uppercase letters A-Z (and _)' /#{CITY_CODE_PATTERN}/"
LANG_KEY_PATTERN =
'\A[a-z]{2}\z'
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



14
15
16
# File 'lib/worlddb/version.rb', line 14

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

.createObject



81
82
83
84
# File 'lib/worlddb.rb', line 81

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!)



112
113
114
115
# File 'lib/worlddb.rb', line 112

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

.mainObject



76
77
78
79
# File 'lib/worlddb.rb', line 76

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

.propsObject



129
130
131
132
# File 'lib/worlddb.rb', line 129

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

.read(ary, include_path) ⇒ Object



87
88
89
90
91
92
# File 'lib/worlddb.rb', line 87

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



106
107
108
# File 'lib/worlddb.rb', line 106

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



95
96
97
98
# File 'lib/worlddb.rb', line 95

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

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

todo/check - use a better (shorter) name ??



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

def self.read_setup_from_zip( zip_name, setup, include_path, opts={} ) ## todo/check - use a better (shorter) name ??
  reader = ZipReader.new( zip_name, include_path, opts )
  reader.load_setup( setup )
  reader.close
end

.rootObject



18
19
20
# File 'lib/worlddb/version.rb', line 18

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

.statsObject

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



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

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

.tablesObject



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

def self.tables
  Stats.new.tables
end

.versionObject



10
11
12
# File 'lib/worlddb/version.rb', line 10

def self.version
  VERSION
end