Class: IndexChecker::TaskDefinition::Base
- Inherits:
-
Object
- Object
- IndexChecker::TaskDefinition::Base
- Defined in:
- lib/index_checker/task_definition/base.rb
Direct Known Subclasses
Class Method Summary collapse
- .gem_root_path ⇒ Object
- .open_file_in_browser(path) ⇒ Object
- .postgres_connection ⇒ Object
- .result_file_path ⇒ Object
- .result_template_path ⇒ Object
- .write_results_to_file ⇒ Object
Class Method Details
.gem_root_path ⇒ Object
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_connection ⇒ Object
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_path ⇒ Object
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_path ⇒ Object
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_file ⇒ Object
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 |