worlddb 2.0.9 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +1 -1
  3. data/Manifest.txt +1 -38
  4. data/README.md +0 -67
  5. data/Rakefile +7 -11
  6. data/lib/worlddb.rb +8 -187
  7. data/lib/worlddb/cli/main.rb +3 -8
  8. data/lib/worlddb/{version.rb → cli/version.rb} +9 -7
  9. data/lib/worlddb/console.rb +5 -10
  10. metadata +10 -110
  11. data/.gemtest +0 -0
  12. data/lib/worlddb/deleter.rb +0 -32
  13. data/lib/worlddb/matcher.rb +0 -143
  14. data/lib/worlddb/models/city.rb +0 -240
  15. data/lib/worlddb/models/city_comp.rb +0 -27
  16. data/lib/worlddb/models/continent.rb +0 -41
  17. data/lib/worlddb/models/continent_comp.rb +0 -24
  18. data/lib/worlddb/models/country.rb +0 -328
  19. data/lib/worlddb/models/country_code.rb +0 -41
  20. data/lib/worlddb/models/country_comp.rb +0 -35
  21. data/lib/worlddb/models/forward.rb +0 -57
  22. data/lib/worlddb/models/lang.rb +0 -18
  23. data/lib/worlddb/models/lang_comp.rb +0 -23
  24. data/lib/worlddb/models/name.rb +0 -13
  25. data/lib/worlddb/models/place.rb +0 -16
  26. data/lib/worlddb/models/region.rb +0 -176
  27. data/lib/worlddb/models/region_comp.rb +0 -26
  28. data/lib/worlddb/models/tagdb/tag.rb +0 -16
  29. data/lib/worlddb/models/tagdb/tagging.rb +0 -15
  30. data/lib/worlddb/models/usage.rb +0 -17
  31. data/lib/worlddb/patterns.rb +0 -54
  32. data/lib/worlddb/reader.rb +0 -224
  33. data/lib/worlddb/reader_file.rb +0 -86
  34. data/lib/worlddb/reader_zip.rb +0 -160
  35. data/lib/worlddb/readers/city.rb +0 -81
  36. data/lib/worlddb/readers/country.rb +0 -78
  37. data/lib/worlddb/readers/lang.rb +0 -107
  38. data/lib/worlddb/readers/region.rb +0 -79
  39. data/lib/worlddb/readers/usage.rb +0 -98
  40. data/lib/worlddb/schema.rb +0 -202
  41. data/lib/worlddb/stats.rb +0 -31
  42. data/test/helper.rb +0 -29
  43. data/test/test_fixture_matchers.rb +0 -112
  44. data/test/test_model_city.rb +0 -60
  45. data/test/test_model_comp.rb +0 -48
  46. data/test/test_model_country.rb +0 -53
  47. data/test/test_model_region.rb +0 -50
  48. data/test/test_models.rb +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f834f636b29a1231453e74665621584e008559d3
4
- data.tar.gz: ac4fa3099c8d7862b87ee474fe5e942e4679a93a
3
+ metadata.gz: e9b04e3e102e14c97044c018ad3fdeb210120fcf
4
+ data.tar.gz: 7500c45d9013183766d9ef85f24d79238b275ade
5
5
  SHA512:
6
- metadata.gz: d616d30efdda6a37fe07dc07e39e3fabc97b769839fb2eaf294dd4708afda4981fac8968a16b0c33c2dc43daedc796b10572966ab4510e1e20c7aa57cbdba5d4
7
- data.tar.gz: 9d8bce8fb4ad6eac3a65b7daa0697b11ccb1276464d9758a291d4b00e50ccbe65d0b976d726f66ec4e220eb007a99c76a01164fdb594828d1d972f8a50bac80b
6
+ metadata.gz: 7f0dce7d75e23232b6807b8098bee330cf3c57292302fc142978ee0e665f8af22f91479bd51899339caf21ace1f977f2e7f7a81f3abbd99d4e6e598d9b23469a
7
+ data.tar.gz: d933d6e0f68f77e00cda45c1771a840414fe04d0ec41cea704984fe82b64a4af7529d8dbd92f51a0a16f3e7d0a741f3a8f9cc468f168f73915621409977bd1c3
data/HISTORY.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.0.1 / 2012-11-05
1
+ ### 0.0.1 / 2014-12-05
2
2
 
3
3
  * Everything is new. First release
4
4
 
@@ -6,42 +6,5 @@ bin/worlddb
6
6
  lib/worlddb.rb
7
7
  lib/worlddb/cli/main.rb
8
8
  lib/worlddb/cli/opts.rb
9
+ lib/worlddb/cli/version.rb
9
10
  lib/worlddb/console.rb
10
- lib/worlddb/deleter.rb
11
- lib/worlddb/matcher.rb
12
- lib/worlddb/models/city.rb
13
- lib/worlddb/models/city_comp.rb
14
- lib/worlddb/models/continent.rb
15
- lib/worlddb/models/continent_comp.rb
16
- lib/worlddb/models/country.rb
17
- lib/worlddb/models/country_code.rb
18
- lib/worlddb/models/country_comp.rb
19
- lib/worlddb/models/forward.rb
20
- lib/worlddb/models/lang.rb
21
- lib/worlddb/models/lang_comp.rb
22
- lib/worlddb/models/name.rb
23
- lib/worlddb/models/place.rb
24
- lib/worlddb/models/region.rb
25
- lib/worlddb/models/region_comp.rb
26
- lib/worlddb/models/tagdb/tag.rb
27
- lib/worlddb/models/tagdb/tagging.rb
28
- lib/worlddb/models/usage.rb
29
- lib/worlddb/patterns.rb
30
- lib/worlddb/reader.rb
31
- lib/worlddb/reader_file.rb
32
- lib/worlddb/reader_zip.rb
33
- lib/worlddb/readers/city.rb
34
- lib/worlddb/readers/country.rb
35
- lib/worlddb/readers/lang.rb
36
- lib/worlddb/readers/region.rb
37
- lib/worlddb/readers/usage.rb
38
- lib/worlddb/schema.rb
39
- lib/worlddb/stats.rb
40
- lib/worlddb/version.rb
41
- test/helper.rb
42
- test/test_fixture_matchers.rb
43
- test/test_model_city.rb
44
- test/test_model_comp.rb
45
- test/test_model_country.rb
46
- test/test_model_region.rb
47
- test/test_models.rb
data/README.md CHANGED
@@ -95,72 +95,6 @@ EXAMPLES
95
95
  ~~~
96
96
 
97
97
 
98
-
99
- ## Usage Models
100
-
101
- `Country` Model - Example:
102
-
103
- at = Country.find_by! key: 'at'
104
- at.name
105
- # => 'Austria'
106
- at.pop
107
- # => 8_414_638
108
- at.area
109
- # => 83_871
110
-
111
- at.regions.count
112
- # => 9
113
- at.regions
114
- # => [ 'Wien', 'Niederösterreich', 'Oberösterreich', ... ]
115
-
116
- at.cities.by_pop
117
- # => [ 'Wien', 'Graz', 'Linz', 'Salzburg', 'Innsbruck' ... ]
118
-
119
-
120
- `City` Model - Example:
121
-
122
- c = City.find_by! key: 'wien'
123
- c.name
124
- # => 'Wien'
125
- c.country.name
126
- # => 'Austria'
127
- c.country.continent.name
128
- # => 'Europe'
129
-
130
- la = City.find_by! key: 'losangeles'
131
- la.name
132
- # => 'Los Angeles'
133
- la.region.name
134
- # => 'California'
135
- la.region.key
136
- # => 'ca'
137
- la.country.name
138
- # => 'United States'
139
- la.country.key
140
- # => 'us'
141
- la.country.continent.name
142
- # => 'North America'
143
-
144
-
145
- `Tag` Model - Example:
146
-
147
- euro = Tag.find_by! key: 'euro'
148
- euro.countries.count
149
- # => 17
150
- euro.countries
151
- # => ['Austria, 'Belgium', 'Cyprus', ... ]
152
-
153
- flanders = Tag.find_by! key: 'flanders'
154
- flanders.regions.count
155
- # => 5
156
- flanders.regions
157
- # => ['Antwerpen', 'Brabant Wallon', 'Limburg', 'Oost-Vlaanderen', 'West-Vlaanderen']
158
- flanders.regions.first.country.name
159
- # => 'Belgium'
160
-
161
- and so on.
162
-
163
-
164
98
  ## Install
165
99
 
166
100
  Just install the gem:
@@ -182,4 +116,3 @@ Use it as you please with no restrictions whatsoever.
182
116
 
183
117
  Send them along to the [Open Mundi (world.db) Database Forum/Mailing List](http://groups.google.com/group/openmundi).
184
118
  Thanks!
185
-
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
1
  require 'hoe'
2
- require './lib/worlddb/version.rb'
2
+ require './lib/worlddb/cli/version.rb'
3
3
 
4
4
 
5
5
  Hoe.spec 'worlddb' do
6
6
 
7
- self.version = WorldDb::VERSION
7
+ self.version = WorldDbCli::VERSION
8
8
 
9
9
  self.summary = "worlddb - world.db command line tool"
10
10
  self.description = summary
@@ -15,16 +15,12 @@ Hoe.spec 'worlddb' do
15
15
  self.email = 'openmundi@googlegroups.com'
16
16
 
17
17
  self.extra_deps = [
18
- ['props'], # settings / prop(ertie)s / env / INI
19
- ['logutils'], # logging
20
- ['textutils', '>= 0.9.9'], # e.g. >= 0.6 && <= 1.0 ## will include logutils, props
21
- ['tagutils'], # tags n categories for activerecord
18
+ ['worlddb-models', '>=2.1.0'],
19
+ ### ['worlddb-service'],
22
20
 
23
21
  ## 3rd party
24
- ['gli', '>= 2.9'],
25
- ['rubyzip'], ## todo: pull in via textutils ??
26
- ['activerecord'] # NB: will include activesupport,etc.
27
- ### ['sqlite3', '~> 1.3'] # NB: install on your own; remove dependency
22
+ ['gli', '>= 2.12.2'],
23
+ ['sqlite3'] # Note: will include sqlite for activerecord; use worlddb-models for apps etc.
28
24
  ]
29
25
 
30
26
  # switch extension to .markdown for gihub formatting
@@ -36,7 +32,7 @@ Hoe.spec 'worlddb' do
36
32
  self.licenses = ['Public Domain']
37
33
 
38
34
  self.spec_extras = {
39
- :required_ruby_version => '>= 1.9.2'
35
+ required_ruby_version: '>= 1.9.2'
40
36
  }
41
37
 
42
38
  end
@@ -1,74 +1,18 @@
1
- ###
2
- # NB: for local testing run like:
3
- #
4
- # 1.9.x: ruby -Ilib lib/worlddb.rb
1
+ # encoding: utf-8
5
2
 
6
- # core and stlibs
3
+ require 'worlddb/models' # NOTE: depends on core (aka worlddb-models)
7
4
 
8
- require 'pp'
9
- require 'logger'
10
- require 'optparse'
11
- require 'fileutils'
12
- require 'uri'
13
- require 'erb'
14
- require 'json'
15
- require 'yaml'
16
5
 
17
-
18
- # 3rd party gems / libs
19
-
20
- require 'zip' ## rubyzip gem
21
-
22
- require 'active_record' ## todo: add sqlite3? etc.
23
-
24
- require 'logutils'
25
- require 'textutils'
26
- require 'tagutils'
27
- require 'props'
28
- require 'props/db' # includes ConfDb (ConfDb::Model::Prop, etc.)
6
+ require 'gli'
7
+ require 'logutils/activerecord' # add support for logging to db
29
8
 
30
9
 
31
10
  # our own code
32
11
 
33
- require 'worlddb/version' # always goes first
34
-
35
- require 'worlddb/patterns' # regex patterns (constants)
36
- require 'worlddb/models/forward'
37
-
38
- require 'worlddb/models/name'
39
- require 'worlddb/models/place'
40
- require 'worlddb/models/continent'
41
- require 'worlddb/models/continent_comp'
42
- require 'worlddb/models/country'
43
- require 'worlddb/models/country_comp'
44
- require 'worlddb/models/country_code'
45
- require 'worlddb/models/region'
46
- require 'worlddb/models/region_comp'
47
- require 'worlddb/models/city'
48
- require 'worlddb/models/city_comp'
49
- require 'worlddb/models/lang'
50
- require 'worlddb/models/lang_comp'
51
- require 'worlddb/models/usage'
12
+ require 'worlddb/cli/version' # version always goes first
52
13
 
53
- require 'worlddb/models/tagdb/tag'
54
- require 'worlddb/models/tagdb/tagging'
55
-
56
-
57
-
58
- require 'worlddb/schema' # NB: requires worlddb/models (include WorldDB::Models)
59
- require 'worlddb/matcher'
60
-
61
- require 'worlddb/readers/lang'
62
- require 'worlddb/readers/usage'
63
- require 'worlddb/readers/country'
64
- require 'worlddb/readers/region'
65
- require 'worlddb/readers/city'
66
-
67
- require 'worlddb/reader'
68
- require 'worlddb/reader_file'
69
- require 'worlddb/reader_zip'
70
- require 'worlddb/deleter'
71
- require 'worlddb/stats'
14
+ # additional for cli only
15
+ require 'worlddb/cli/opts'
72
16
 
73
17
 
74
18
  module WorldDb
@@ -78,130 +22,7 @@ module WorldDb
78
22
  ## Runner.new.run(ARGV) - old code
79
23
  end
80
24
 
81
- def self.create
82
- CreateDb.new.up
83
- ConfDb::Model::Prop.create!( key: 'db.schema.world.version', value: VERSION )
84
- end
85
-
86
- def self.create_all
87
- LogDb.create # add logs table
88
- ConfDb.create # add props table
89
- TagDb.create # add tags, taggings table
90
- WorldDb.create
91
- end
92
-
93
-
94
- def self.read( ary, include_path )
95
- reader = Reader.new( include_path )
96
- ary.each do |name|
97
- reader.load( name )
98
- end
99
- end
100
-
101
-
102
- def self.read_setup( setup, include_path, opts={} )
103
- reader = Reader.new( include_path, opts )
104
- reader.load_setup( setup )
105
- end
106
-
107
- def self.read_setup_from_zip( zip_name, setup, include_path, opts={} ) ## todo/check - use a better (shorter) name ??
108
- reader = ZipReader.new( zip_name, include_path, opts )
109
- reader.load_setup( setup )
110
- reader.close
111
- end
112
-
113
- def self.read_all( include_path, opts={} ) # load all builtins (using plain text reader); helper for convenience
114
- read_setup( 'setups/all', include_path, opts )
115
- end # method read_all
116
-
117
-
118
- # delete ALL records (use with care!)
119
- def self.delete!
120
- puts '*** deleting world table records/data...'
121
- Deleter.new.run
122
- end # method delete!
123
-
124
- def self.delete_all!( opts={} )
125
- LogDb.delete!
126
- ConfDb.delete!
127
- TagDb.delete!
128
- WorldDb.delete!
129
- end
130
-
131
-
132
- ####
133
- ## todo: remove stats ??? why? why not? better use .tables
134
- def self.stats
135
- Stats.new.tables
136
- end
137
-
138
- def self.tables
139
- Stats.new.tables
140
- end
141
-
142
-
143
- def self.connect( db_config={} )
144
-
145
- if db_config.empty?
146
- puts "ENV['DATBASE_URL'] - >#{ENV['DATABASE_URL']}<"
147
-
148
- ### change default to ./sport.db ?? why? why not?
149
- db = URI.parse( ENV['DATABASE_URL'] || 'sqlite3:///world.db' )
150
-
151
- if db.scheme == 'postgres'
152
- config = {
153
- adapter: 'postgresql',
154
- host: db.host,
155
- port: db.port,
156
- username: db.user,
157
- password: db.password,
158
- database: db.path[1..-1],
159
- encoding: 'utf8'
160
- }
161
- else # assume sqlite3
162
- config = {
163
- adapter: db.scheme, # sqlite3
164
- database: db.path[1..-1] # world.db (NB: cut off leading /, thus 1..-1)
165
- }
166
- end
167
- else
168
- config = db_config # use passed in config hash
169
- end
170
-
171
- ## todo/check: use if defined?( JRUBY_VERSION ) instead ??
172
- if RUBY_PLATFORM =~ /java/ && config[:adapter] == 'sqlite3'
173
- # quick hack for JRuby sqlite3 support via jdbc
174
- puts "jruby quick hack - adding jdbc libs for jruby sqlite3 database support"
175
- require 'jdbc/sqlite3'
176
- require 'active_record/connection_adapters/jdbc_adapter'
177
- require 'active_record/connection_adapters/jdbcsqlite3_adapter'
178
- end
179
-
180
- puts "Connecting to db using settings: "
181
- pp config
182
- ActiveRecord::Base.establish_connection( config )
183
- # ActiveRecord::Base.logger = Logger.new( STDOUT )
184
- end
185
-
186
-
187
- def self.setup_in_memory_db
188
-
189
- # Database Setup & Config
190
- ActiveRecord::Base.logger = Logger.new( STDOUT )
191
- ## ActiveRecord::Base.colorize_logging = false - no longer exists - check new api/config setting?
192
-
193
- self.connect( adapter: 'sqlite3',
194
- database: ':memory:' )
195
-
196
- ## build schema
197
- WorldDb.create_all
198
- end # setup_in_memory_db (using SQLite :memory:)
199
-
200
25
  end # module WorldDb
201
26
 
202
27
 
203
- if __FILE__ == $0
204
- WorldDb.main
205
- else
206
- puts WorldDb.banner # say hello
207
- end
28
+ WorldDb.main if __FILE__ == $0
@@ -1,18 +1,13 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'gli'
4
3
 
5
4
  include GLI::App
6
5
 
7
- # our own code / additional for cli only
8
-
9
- require 'logutils/db' # add support for logging to db
10
- require 'worlddb/cli/opts'
11
6
 
12
7
 
13
8
  program_desc 'world.db command line tool'
14
9
 
15
- version WorldDb::VERSION
10
+ version WorldDbCli::VERSION
16
11
 
17
12
 
18
13
  LogUtils::Logger.root.level = :info # set logging level to info
@@ -60,7 +55,7 @@ switch [:q, :quiet], negatable: false
60
55
 
61
56
 
62
57
  def connect_to_db( options )
63
- puts WorldDb.banner
58
+ puts WorldDbCli.banner
64
59
 
65
60
  puts "working directory: #{Dir.pwd}"
66
61
 
@@ -237,7 +232,7 @@ pre do |g,c,o,args|
237
232
  opts.merge_gli_options!( g )
238
233
  opts.merge_gli_options!( o )
239
234
 
240
- puts WorldDb.banner
235
+ puts WorldDbCli.banner
241
236
 
242
237
  if opts.verbose?
243
238
  LogUtils::Logger.root.level = :debug
@@ -1,10 +1,13 @@
1
+ # encoding: utf-8
1
2
 
2
- module WorldDb
3
+ # Note: WorldDb::VERSION gets used by core, that is, worlddb-models
4
+
5
+
6
+ module WorldDbCli # todo/check - rename to WorldDbTool or WorldDbCommands or WorldDbShell ??
3
7
 
4
- # sync version w/ sport.db n friends - why? why not?
5
8
  MAJOR = 2 ## todo: namespace inside version or something - why? why not??
6
- MINOR = 0
7
- PATCH = 9
9
+ MINOR = 1
10
+ PATCH = 0
8
11
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
12
 
10
13
  def self.version
@@ -16,8 +19,7 @@ module WorldDb
16
19
  end
17
20
 
18
21
  def self.root
19
- "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
22
+ "#{File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )}"
20
23
  end
21
24
 
22
- end
23
-
25
+ end # module WorldDbCli