data_sampler 0.0.6 → 1.0.0

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.
@@ -32,6 +32,11 @@ module DataSampler
32
32
  warn " Discovered #{new_dependencies} new dependencies" if new_dependencies > 0
33
33
  end while new_dependencies > 0
34
34
  warn "Referential integrity obtained"
35
+
36
+ warn "Final sample contains:"
37
+ @table_samples.values.each do |table_sample|
38
+ warn " #{table_sample.size} row(s) from `#{table_sample.table_name}`"
39
+ end
35
40
  @computed = true
36
41
  end
37
42
 
@@ -22,6 +22,10 @@ module DataSampler
22
22
  @sample
23
23
  end
24
24
 
25
+ def size
26
+ @sampled ? @sample.size : @size
27
+ end
28
+
25
29
  def fulfil(dependency)
26
30
  return 0 if fulfilled?(dependency)
27
31
  where = dependency.keys.collect { |col, val| "#{@connection.quote_column_name col} = #{@connection.quote val}" } * ' AND '
@@ -60,7 +64,7 @@ module DataSampler
60
64
  deps_in_progress = @pending_dependencies
61
65
  @pending_dependencies = Set.new
62
66
  deps_in_progress.each do |dependency|
63
- raise "Table sample for #{dependency.table_name} not found" unless table_samples[dependency.table_name]
67
+ raise "Table sample for `#{dependency.table_name}` not found" unless table_samples[dependency.table_name]
64
68
  newly_added += table_samples[dependency.table_name].fulfil(dependency)
65
69
  end
66
70
  newly_added
@@ -96,6 +100,7 @@ module DataSampler
96
100
  sql += " ORDER BY #{@connection.quote_column_name pk} DESC" unless pk.nil?
97
101
  sql += " LIMIT #{count}"
98
102
  @connection.select_all(sql).each { |row| add(row) }
103
+ @sampled = true
99
104
  rescue ActiveRecord::StatementInvalid => e
100
105
  # Don't choke on unknown table engines, such as Sphinx
101
106
  []
@@ -1,3 +1,3 @@
1
1
  module DataSampler
2
- VERSION = "0.0.6"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_sampler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: