Class: IndexChecker::TaskDefinition::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/index_checker/task_definition/base.rb

Direct Known Subclasses

GeneralReport

Class Method Summary collapse

Class Method Details

.gem_root_pathObject



39
40
41
# File 'lib/index_checker/task_definition/base.rb', line 39

def gem_root_path
  __FILE__.gsub('lib/index_checker/task_definition/base.rb', '')
end

.open_file_in_browser(path) ⇒ Object



27
28
29
# File 'lib/index_checker/task_definition/base.rb', line 27

def open_file_in_browser(path)
  Launchy.open(path)
end

.postgres_connectionObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/index_checker/task_definition/base.rb', line 7

def postgres_connection
  dbname = IndexChecker.dbname
  user = IndexChecker.user
  password = IndexChecker.password

  puts "You are connecting to #{dbname} database as #{user} role"
  begin
    PG.connect(dbname: dbname, user: user, password: password)
  rescue Exception => e
    puts e
  end
end

.result_file_pathObject



35
36
37
# File 'lib/index_checker/task_definition/base.rb', line 35

def result_file_path
  "#{Rails.root}/index_checker/general_report.html"
end

.result_template_pathObject



31
32
33
# File 'lib/index_checker/task_definition/base.rb', line 31

def result_template_path
  "#{gem_root_path}lib/report_template.html.erb"
end

.write_results_to_fileObject



20
21
22
23
24
25
# File 'lib/index_checker/task_definition/base.rb', line 20

def write_results_to_file
  template = File.read(result_template_path)
  html_result = ERB.new(template).result(binding)

  File.write(result_file_path, html_result)
end