worlddb 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -106,32 +106,11 @@ EOS
106
106
  end
107
107
  end
108
108
 
109
- dump_stats
110
- dump_props
109
+ WorldDB.stats
111
110
 
112
111
  puts 'Done.'
113
112
 
114
113
  end # method run
115
114
 
116
-
117
- def dump_stats
118
- # todo: use %5d or similar to format string
119
- puts "Stats:"
120
- puts " #{Country.count} countries"
121
- puts " #{Region.count} regions"
122
- puts " #{City.count} cities"
123
- puts " #{Tag.count} tags"
124
- puts " #{Tagging.count} taggings"
125
- end
126
-
127
-
128
- def dump_props
129
- # todo: use %5 or similar to format string
130
- puts "Props:"
131
- Prop.order( 'created_at asc' ).all.each do |prop|
132
- puts " #{prop.key} / #{prop.value} || #{prop.created_at}"
133
- end
134
- end
135
-
136
115
  end # class Runner
137
116
  end # module WorldDB
@@ -36,9 +36,23 @@ class Reader
36
36
 
37
37
  end
38
38
 
39
+
39
40
  ############################
40
41
  # load from file system
41
42
 
43
+ def load_with_include_path( name, include_path )
44
+ if name =~ /\/countries/
45
+ load_countries_with_include_path( name, include_path )
46
+ elsif name =~ /\/([a-z]{2})\/cities/
47
+ load_cities_with_include_path( $1, name, include_path )
48
+ elsif name =~ /\/([a-z]{2})\/regions/
49
+ load_regions_with_include_path( $1, name, include_path )
50
+ else
51
+ puts "*** error: unknown world.db fixture type >#{name}<"
52
+ # todo/fix: exit w/ error
53
+ end
54
+ end
55
+
42
56
  def load_countries_with_include_path( name, include_path )
43
57
  load_fixtures_with_include_path_for( Country, name, include_path )
44
58
  end
@@ -1,5 +1,5 @@
1
1
 
2
2
  module WorldDB
3
- VERSION = '0.3.1'
3
+ VERSION = '0.3.2'
4
4
  end
5
5
 
data/lib/worlddb.rb CHANGED
@@ -157,7 +157,40 @@ module WorldDB
157
157
  Deleter.new.run
158
158
  end # method delete!
159
159
 
160
-
160
+ class Stats
161
+ include WorldDB::Models
162
+
163
+ def tables
164
+ puts "Stats:"
165
+ puts " #{'%5d' % Country.count} countries"
166
+ puts " #{'%5d' % Region.count} regions"
167
+ puts " #{'%5d' % City.count} cities"
168
+ puts " #{'%5d' % Tag.count} tags"
169
+ puts " #{'%5d' % Tagging.count} taggings"
170
+ end
171
+
172
+ def props
173
+ puts "Props:"
174
+ Prop.order( 'created_at asc' ).all.each do |prop|
175
+ puts " #{prop.key} / #{prop.value} || #{prop.created_at}"
176
+ end
177
+ end
178
+ end
179
+
180
+ def self.stats
181
+ stats = Stats.new
182
+ stats.tables
183
+ stats.props
184
+ end
185
+
186
+ def self.tables
187
+ Stats.new.tables
188
+ end
189
+
190
+ def self.props
191
+ Stats.new.props
192
+ end
193
+
161
194
  end # module WorldDB
162
195
 
163
196
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worlddb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gerald Bauer