worlddb 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/worlddb/cli/runner.rb +1 -22
- data/lib/worlddb/reader.rb +14 -0
- data/lib/worlddb/version.rb +1 -1
- data/lib/worlddb.rb +34 -1
- metadata +3 -3
data/lib/worlddb/cli/runner.rb
CHANGED
@@ -106,32 +106,11 @@ EOS
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
|
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
|
data/lib/worlddb/reader.rb
CHANGED
@@ -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
|
data/lib/worlddb/version.rb
CHANGED
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