class RBT::Cookbooks::CreateDatabase

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

new( optional_input = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/create_database.rb, line 51
def initialize(
    optional_input = nil,
    run_already    = true
  )
  reset
  set_input(
    optional_input
  )
  case run_already
  when :do_not_report
    @shall_we_report = false
    run_already = true
  end
  run if run_already
end

Public Instance Methods

_(i) click to toggle source
#

_

#
# File lib/rbt/utility_scripts/create_database.rb, line 88
def _(i)
  @_ << i+N
end
data?() click to toggle source
#

data?

#
# File lib/rbt/utility_scripts/create_database.rb, line 109
def data?
  @_
end
display_generated_file() click to toggle source
#

display_generated_file

This is an optional method.

#
# File lib/rbt/utility_scripts/create_database.rb, line 138
def display_generated_file
  if File.exist? save_where?
    cliner {
      e File.readlines(save_where?)
    }
  end
end
file?()
Alias for: save_where?
populate_database() click to toggle source
#

populate_database

#
# File lib/rbt/utility_scripts/create_database.rb, line 124
def populate_database
  available_programs?.each {|the_program|
    @query = RBT::Cookbooks::Cookbook.new(the_program) { :bypass_menu }
    @query.feedback
    what = InsertInto[@name_of_the_table, @query.program_path?]
    append_what_into(what, file?)
  }
end
report_result() click to toggle source
#

report_result

#
# File lib/rbt/utility_scripts/create_database.rb, line 102
def report_result
  e @_ if shall_we_report?
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/create_database.rb, line 70
def reset
  super()
  @_ = ''
  @shall_we_report = true
  @query = Cookbooks::Cookbook.new(:do_not_run_yet)
  @namespace = NAMESPACE
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/create_database.rb, line 156
def run
  if Object.const_defined? :SqlParadise # The functionality depends on SqlParadise.
    _ SqlParadise::CreateDatabase['cookbooks']
    # ===================================================================== #
    # Populate the table next.
    # ===================================================================== #
    dataset = RBT.registered_cookbook_entries?
    dataset.map! {|entry| entry+' varchar(120)' }
    @name_of_the_table = 'cookbooks'
    _ CreateTable[@name_of_the_table]
    entries_in_the_table = '('+dataset.join(', ')+')'
    _ InsertInto[@name_of_the_table, entries_in_the_table]
    report_result
    save_result
    populate_database # We add our programs next.
  end
end
save_result() click to toggle source
#

save_result

#
# File lib/rbt/utility_scripts/create_database.rb, line 116
def save_result
  opnn; e "We will now save the result into #{sfile(save_where?)}"
  save_file(data?, save_where?)
end
save_where?() click to toggle source
#

save_where?

#
# File lib/rbt/utility_scripts/create_database.rb, line 149
def save_where?
  "#{temp_dir?}database_for_programs.sql"
end
Also aliased as: file?
set_input(i = nil) click to toggle source
#

set_input

#
# File lib/rbt/utility_scripts/create_database.rb, line 81
def set_input(i = nil)
  @input = i
end
shall_we_report?() click to toggle source
#

shall_we_report?

#
# File lib/rbt/utility_scripts/create_database.rb, line 95
def shall_we_report?
  @shall_we_report
end