Module: DataTaster
- Defined in:
- lib/data_taster.rb,
lib/data_taster/helper.rb,
lib/data_taster/sample.rb,
lib/data_taster/flavors.rb,
lib/data_taster/version.rb,
lib/data_taster/detergent.rb,
lib/data_taster/sanitizer.rb,
lib/data_taster/collection.rb,
lib/data_taster/confection.rb
Defined Under Namespace
Modules: Helper
Classes: Collection, Confection, Config, Detergent, Flavors, Sample, Sanitizer
Constant Summary
collapse
- SKIP_CODE =
"skip_processing"
- VERSION =
"0.4.0"
Class Method Summary
collapse
Class Method Details
.config(**args) ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'lib/data_taster.rb', line 23
def self.config(**args)
@config ||= Config.new(
args[:months],
Array.wrap(args[:list] || Rails.root.glob("**/data_taster_export_tables.yml")),
args[:source_client] || raise(ArgumentError, "DataTaster.config missing source_client"),
args[:working_client] || raise(ArgumentError, "DataTaster.config missing working_client"),
args[:include_insert] || false
)
end
|
.logger ⇒ Object
19
20
21
|
# File 'lib/data_taster.rb', line 19
def self.logger
@logger ||= Logger.new($stdout)
end
|
.logger=(logger) ⇒ Object
15
16
17
|
# File 'lib/data_taster.rb', line 15
def self.logger=(logger)
@logger = logger
end
|
.safe_execute(sql, client = DataTaster.config.working_client) ⇒ Object
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/data_taster.rb', line 47
def self.safe_execute(sql, client = DataTaster.config.working_client)
foreign_key_check = client.query("SELECT @@FOREIGN_KEY_CHECKS").first["@@FOREIGN_KEY_CHECKS"]
begin
client.query("SET FOREIGN_KEY_CHECKS=0")
client.query(sql)
ensure
client.query("SET FOREIGN_KEY_CHECKS=#{foreign_key_check};")
end
end
|
.sample! ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/data_taster.rb', line 37
def self.sample!
DataTaster
.config
.source_client
.query("SHOW tables").collect { |t| t[t.keys.first] }
.each do |table_name|
DataTaster::Sample.new(table_name).serve!
end
end
|