Module: Shiba
- Defined in:
- lib/shiba.rb,
lib/shiba/index.rb,
lib/shiba/query.rb,
lib/shiba/fuzzer.rb,
lib/shiba/output.rb,
lib/shiba/console.rb,
lib/shiba/explain.rb,
lib/shiba/version.rb,
lib/shiba/analyzer.rb,
lib/shiba/reviewer.rb,
lib/shiba/backtrace.rb,
lib/shiba/configure.rb,
lib/shiba/connection.rb,
lib/shiba/review/api.rb,
lib/shiba/review/cli.rb,
lib/shiba/index_stats.rb,
lib/shiba/review/diff.rb,
lib/shiba/table_stats.rb,
lib/shiba/query_watcher.rb,
lib/shiba/explain/checks.rb,
lib/shiba/explain/result.rb,
lib/shiba/connection/mysql.rb,
lib/shiba/parsers/bad_parse.rb,
lib/shiba/connection/postgres.rb,
lib/shiba/review/explain_diff.rb,
lib/shiba/explain/check_support.rb,
lib/shiba/explain/mysql_explain.rb,
lib/shiba/review/comment_renderer.rb,
lib/shiba/activerecord_integration.rb,
lib/shiba/explain/postgres_explain.rb,
lib/shiba/parsers/mysql_select_fields.rb,
lib/shiba/parsers/shiba_string_scanner.rb,
lib/shiba/parsers/postgres_explain_index_conditions.rb
Defined Under Namespace
Modules: Backtrace, Configure, Console, Parsers, Review
Classes: ActiveRecordIntegration, Analyzer, ConfigError, Connection, Error, Explain, Fuzzer, Index, IndexStats, Output, Query, QueryWatcher, Reviewer, TableStats
Constant Summary
collapse
- TEMPLATE_FILE =
File.join(File.dirname(__dir__), 'lib/shiba/output/tags.yaml')
- VERSION =
"0.9.4"
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
56
57
58
|
# File 'lib/shiba.rb', line 56
def self.config
@main_config
end
|
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/shiba.rb', line 13
def self.configure(options)
return false if @connection_hash
configure_mysql_defaults(options)
@connection_hash = options.select { |k, v| [ 'default_file', 'default_group', 'server', 'username', 'database', 'host', 'password', 'port'].include?(k) }
@main_config = Configure.read_config_file(options['config'], "config/shiba.yml")
@index_config = Configure.read_config_file(options['index'], "config/shiba_index.yml")
true
end
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/shiba.rb', line 24
def self.configure_mysql_defaults(options)
option_path = Shiba::Configure.mysql_config_path
if option_path
puts "Found config at #{option_path}" if options["verbose"]
options['default_file'] ||= option_path
end
option_file = if options['default_file'] && File.exist?(options['default_file'])
File.read(options['default_file'])
else
""
end
if option_file && !options['default_group']
if option_file.include?("[client]")
options['default_group'] = 'client'
end
if option_file.include?("[mysql]")
options['default_group'] = 'mysql'
end
end
if !options["username"] && !option_file.include?('user')
raise Shiba::ConfigError.new('Required: --username')
end
if !options["database"] && !option_file.include?('database')
raise Shiba::ConfigError.new('Required: --database')
end
end
|
.connection ⇒ Object
64
65
66
67
|
# File 'lib/shiba.rb', line 64
def self.connection
return @connection if @connection
@connection = Shiba::Connection.build(@connection_hash)
end
|
.database ⇒ Object
69
70
71
|
# File 'lib/shiba.rb', line 69
def self.database
@connection_hash['database']
end
|
.index_config ⇒ Object
60
61
62
|
# File 'lib/shiba.rb', line 60
def self.index_config
@index_config
end
|
.path ⇒ Object
77
78
79
|
# File 'lib/shiba.rb', line 77
def self.path
@log_path ||= ENV['SHIBA_DIR'] || try_tmp || use_tmpdir
end
|
.root ⇒ Object
73
74
75
|
# File 'lib/shiba.rb', line 73
def self.root
File.dirname(__dir__)
end
|