class RBT::Cookbooks::CreateDatabase

Public Class Methods

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

initialize

#
# File lib/rbt/sql/create_database.rb, line 47
def initialize(
    optional_input = nil,
    run_already    = true
  )
  reset
  set_input(
    optional_input
  )
  case run_already
  # ======================================================================= #
  # === :do_not_report
  # ======================================================================= #
  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/sql/create_database.rb, line 96
def _(i)
  @_ << i+N
end
data?() click to toggle source
#

data?

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

display_generated_file

This is an optional method.

#
# File lib/rbt/sql/create_database.rb, line 146
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/sql/create_database.rb, line 132
def populate_database
  available_programs?.each {|the_program|
    @query = action(:SanitizeCookbook, the_program) { :fast }
    @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/sql/create_database.rb, line 110
def report_result
  e @_ if shall_we_report?
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/sql/create_database.rb, line 69
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @_
  # ======================================================================= #
  @_ = ''.dup
  # ======================================================================= #
  # === @shall_we_report
  # ======================================================================= #
  @shall_we_report = true
  # ======================================================================= #
  # === @query
  # ======================================================================= #
  @query = action(:SanitizeCookbook, :do_not_run_yet) { :fast }
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/sql/create_database.rb, line 164
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/sql/create_database.rb, line 124
def save_result
  opne "#{rev}We will now save the result into #{sfile(save_where?)}#{rev}."
  save_file(data?, save_where?)
end
save_where?() click to toggle source
#

save_where?

#
# File lib/rbt/sql/create_database.rb, line 157
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/sql/create_database.rb, line 89
def set_input(i = nil)
  @input = i
end
shall_we_report?() click to toggle source
#

shall_we_report?

#
# File lib/rbt/sql/create_database.rb, line 103
def shall_we_report?
  @shall_we_report
end