class RBT::GUI::LibUI::CompileProgram

Constants

HEIGHT
#

HEIGHT

#
TITLE
#

TITLE

#
WIDTH
#

WIDTH

#

Public Class Methods

new( run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 44
def initialize(
    run_already = true
  )
  reset
  run if run_already
end

Public Instance Methods

compile_object?() click to toggle source
#

compile_object?

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 150
def compile_object?
  @compile_object
end
compile_which_program?() click to toggle source
#

compile_which_program?

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 157
def compile_which_program?
  @entry_compile_this_program.text?
end
create_a_new_compile_object() click to toggle source
#

create_a_new_compile_object

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 254
def create_a_new_compile_object
  # ======================================================================= #
  # === @compile_object
  #
  # Create a new compile-object. We will re-use it lateron.
  # ======================================================================= #
  @compile_object = RBT::CompileViaSQLDatabase.new(nil, :do_not_run_yet)
end
create_skeleton() click to toggle source
#

create_skeleton (create tag, skeleton tag)

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 61
def create_skeleton
  # ======================================================================= #
  # === @window
  # ======================================================================= #
  @window = ui_padded_main_window(title?, width?, height?, 0)
  create_the_entries
  create_the_buttons
  create_the_grid
  create_the_labels
end
create_the_buttons() click to toggle source
#

create_the_buttons (buttons tag)

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 95
def create_the_buttons
  # ======================================================================= #
  # === @button_do_compile_the_program
  # ======================================================================= #
  @button_do_compile_the_program = button(
    'Compile the program'
  )
  @button_do_compile_the_program.on_clicked {
    ensure_that_the_prefix_is_not_a_symbol
    ensure_that_the_prefix_entry_has_a_trailing_forward_slash
    do_compile_this_program
  }
end
create_the_entries() click to toggle source
#

create_the_entries (entries tag, entry tag)

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 123
def create_the_entries
  # ======================================================================= #
  # === @entry_target_prefix
  # ======================================================================= #
  @entry_target_prefix = entry('/usr/')
  # ======================================================================= #
  # === @entry_compile_this_program
  # ======================================================================= #
  @entry_compile_this_program = entry
  @entry_compile_this_program.on_changed {|something|
    proc { |pointer|
      evaluate_the_current_input(@entry_compile_this_program, pointer)
    }
  }
  @entry_location_of_the_database = entry
end
create_the_grid() click to toggle source
#

create_the_grid

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 85
def create_the_grid
  # ======================================================================= #
  # === @grid
  # ======================================================================= #
  @grid = padded_grid
end
create_the_labels() click to toggle source
#

create_the_labels (labels tag, label tag)

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 75
def create_the_labels
  # ======================================================================= #
  # === @label_file_size_of_the_source_archive
  # ======================================================================= #
  @label_file_size_of_the_source_archive = text('File size of the source archive: ')
end
determine_the_location_of_the_compile_database() click to toggle source
#

determine_the_location_of_the_compile_database

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 266
def determine_the_location_of_the_compile_database
  target = @compile_object.database_location?.to_s
  unless File.directory? File.dirname(target)
    mkdir(File.dirname(target))
  end
  @entry_location_of_the_database.set_text(target)
end
do_compile_this_program( text = compile_which_program? ) click to toggle source
#

do_compile_this_program (compile tag)

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 164
def do_compile_this_program(
    text = compile_which_program?
  )
  text = text.dup
  if text and text.include?('-')
    text.delete!('-')
  end
  require 'rbt/compile_via_sql_database/compile_via_sql_database.rb'
  @compile_object.set_compile_this_program(text)
  @compile_object.set_prefix(prefix?)
  if @compile_object.is_this_program_included? text
    Thread.new {
      _ = @compile_object.assumed_local_file_path_for?(text)
      if File.exist? _
        @label_file_size_of_the_source_archive.set_text(
          'File size of the source archive: '+
          (File.size(_) / 1000).round(2).to_s+' kb'
        )
      end
      @compile_object.do_the_actual_compilation
      message_box(
        text: "Finished compiling `#{text}` into the "\
              "prefix #{prefix?}"\
              "!\n\n Hopefully everything worked ok-ish."
      )
    }
  else
    message_box(
        text: 'The program `'+text+'` is NOT included. '\
              'Make sure the program is registered in '\
              'the RBT project.'
      )
  end
end
do_compile_via_this_program(i) click to toggle source
#

do_compile_via_this_program

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 209
def do_compile_via_this_program(i)
  ensure_that_the_prefix_is_not_a_symbol
  ensure_that_the_prefix_entry_has_a_trailing_forward_slash
  set_compile_this_program(i)
  do_compile_this_program
end
ensure_that_the_prefix_entry_has_a_trailing_forward_slash() click to toggle source
#

ensure_that_the_prefix_entry_has_a_trailing_forward_slash

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 219
def ensure_that_the_prefix_entry_has_a_trailing_forward_slash
  _ = prefix?
  unless _.end_with? '/'
    @entry_target_prefix.set_text("#{_}/")
  end
end
ensure_that_the_prefix_is_not_a_symbol() click to toggle source
#

ensure_that_the_prefix_is_not_a_symbol

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 229
def ensure_that_the_prefix_is_not_a_symbol
  _ = @entry_target_prefix.text?
  if _.start_with? ':'
    _ = _.delete(':')
    case _
    when 'appdir'
      try_to_compile_this_program = compile_which_program?
      # =================================================================== #
      # We must use SQL here to determine the assumed version.
      # But first we will specify a default.
      # =================================================================== #
      assumed_version = '1.0.0'
      assumed_version = @compile_object.assumed_version_of_this_program?(try_to_compile_this_program)
      use_this_prefix = RBT.return_appdir_prefix(
        try_to_compile_this_program+'-'+
        assumed_version
      )
      @entry_target_prefix.set_text(use_this_prefix)
    end
  end
end
evaluate_the_current_input(entry, pointer) click to toggle source
#

evaluate_the_current_input

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 112
def evaluate_the_current_input(entry, pointer)
  text = entry.text?
  if text and text.end_with?('#')
    entry.set_text( without_trailing_comment(text) )
    do_compile_via_this_program(entry.text?)
  end
end
prefix?() click to toggle source
#

prefix?

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 202
def prefix?
  @entry_target_prefix.text?.to_s
end
reset() click to toggle source
#

reset (reset tag)

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 54
def reset
  title_width_height(TITLE, WIDTH, HEIGHT)
end
run() click to toggle source
#

run

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 277
def run
  create_skeleton_then_connect_skeleton
  create_a_new_compile_object
  determine_the_location_of_the_compile_database
  outer_vbox = padded_vbox
  outer_vbox.add_hsep

  #                         widget, left, top, xspan, yspan, hexpand, halign, vexpand, valign
  @grid.left( text('Compile this program → ') )
  @grid.right( @entry_compile_this_program )
  @grid.right( @button_do_compile_the_program )
  @grid.new_row
  @grid.left(text('The SQL database is kept at the following location:'), :default, :default, 3)
  @grid.new_row
  @grid.left(@entry_location_of_the_database, :default, :default, 3)
  @grid.new_row
  @grid.left( text('Use this target prefix → ') )
  @grid.right(@entry_target_prefix, :default, :default, 2)
  @grid.new_row
  @grid.left(
    @label_file_size_of_the_source_archive
  )
  @grid.new_row
  @grid.left(
    text('n registered programs are available in the SQL database → ')
  )
  n_programs_available = compile_object?.n_programs_available?
  @grid.right( text(n_programs_available.to_s))
  outer_vbox.minimal(@grid)
  outer_vbox.add_hsep
  outer_vbox.minimal(quit_button)
  outer_vbox.add_hsep
  @window.add(outer_vbox)
  @window.intelligent_exit
end
set_compile_this_program(i) click to toggle source
#

set_compile_this_program

#
# File lib/rbt/gui/libui/compile_via_sql_database/compile_via_sql_database.rb, line 143
def set_compile_this_program(i)
  @entry_compile_this_program.set_text(i.to_s)
end