class RBT::Compile::Shell
Constants
- DEFAULT_SHOW_N_PROGRAMS_THAT_WERE_LAST_UPDATED
#¶ ↑
DEFAULT_SHOW_N_PROGRAMS_THAT_WERE_LAST_UPDATED
¶ ↑#¶ ↑
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
Public Class Methods
[](i = '')
click to toggle source
new( i = nil, run_already = true )
click to toggle source
Public Instance Methods
display_colourized_comment(i)
click to toggle source
do_autocompile()
click to toggle source
#¶ ↑
do_autocompile
¶ ↑
#¶ ↑
# File lib/rbt/shell/shell.rb, line 228 def do_autocompile require 'rbt/toplevel_methods/swift_return_version_of_this_program.rb' e e 'The method '+orange('do_autocompile()')+' will attempt to '\ 'compile several programs.' e e 'The target directory is currently hardcoded towards `'+sdir('/Programs/')+'`.' e 'This will change at a later time, to allow any directory as the main' e '--prefix= in use.' e e 'This method will first check the locally available latest version of' e 'the programs that are to be compiled.' e e 'Compilation will only happen if the program in the Cookbooks directory' e 'is more recent than the locally available program.' e array = %i( sed awk ) array.each {|this_program| version_in_the_cookbooks_file = RBT.return_version_of(this_program) e 'TODO' e 'The local version of '+this_program.to_s+' is: '+ sfancy(version_in_the_cookbooks_file) e 'We still have to compare this to the local version available on' e 'this computer.' } end
do_compile_this_program(i)
click to toggle source
#¶ ↑
do_compile_this_program
¶ ↑
#¶ ↑
# File lib/rbt/shell/shell.rb, line 156 def do_compile_this_program(i) i.strip! if i.include? ' ' # ===================================================================== # # In this case we need to determine what the user wants. # ===================================================================== # splitted = i.split(' ') first = splitted.first last = splitted.last case last # ===================================================================== # # === trad # ===================================================================== # when 'trad' notify_the_user_that_this_program_will_be_compiled_next(first) RBT::Compile.new(first) {{ prefix: 'trad' }} return end end notify_the_user_that_this_program_will_be_compiled_next(i) if @use_this_prefix RBT::Compile.new(i) {{ prefix: @use_this_prefix }} else RBT::Compile.new(i) end end
edit_this_file( i = @all_arguments )
click to toggle source
#¶ ↑
edit_this_file
(edit tag)¶ ↑
This method can be used to quickly edit a .yml file from within the compile-shell.
#¶ ↑
# File lib/rbt/shell/shell.rb, line 305 def edit_this_file( i = @all_arguments ) if i.is_a? Array i.each {|entry| edit_this_file(entry) } else i = i.dup if i.frozen? i << '.yml' unless i.end_with? '.yml' unless i.include? '/' i.prepend RBT.individual_cookbooks_directory? end i.prepend('nano ') esystem i end end
input?()
click to toggle source
notify_the_user_that_input_can_be_passed_in_now()
click to toggle source
notify_the_user_that_this_program_will_be_compiled_next(i)
click to toggle source
#¶ ↑
notify_the_user_that_this_program_will_be_compiled_next
¶ ↑
This is just a notification - for the actual compile-action you have to add the code after an invocation to this method here.
#¶ ↑
# File lib/rbt/shell/shell.rb, line 149 def notify_the_user_that_this_program_will_be_compiled_next(i) opnn; e "Next compiling `#{sfancy(i.strip)}`." end
obtain_user_input()
click to toggle source
#¶ ↑
obtain_user_input
¶ ↑
#¶ ↑
# File lib/rbt/shell/shell.rb, line 107 def obtain_user_input if @can_we_use_readline @user_input = Readline.readline('', true) # ===================================================================== # # Next ignore empty input. # ===================================================================== # Readline::HISTORY.pop if @user_input.strip.empty? else # else use $stdin @user_input = $stdin.gets.chomp end end
query_the_prefix_in_use()
click to toggle source
remove_this_entry_from_the_database(i)
click to toggle source
#¶ ↑
remove_this_entry_from_the_database
¶ ↑
#¶ ↑
# File lib/rbt/shell/shell.rb, line 258 def remove_this_entry_from_the_database(i) database_location = rbt_logs?+'database_storing_compile_times.yml' if File.exist? database_location old_dataset = YAML.load_file(database_location) old_dataset.reject! {|key, value| key == i } e 'Storing the dataset into the file '+sfile(database_location)+'.' write_what_into( YAML.dump(old_dataset), database_location ) else opnn; e "No file exists at `#{sfile(database_location)}`." end end
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::Base#reset
# File lib/rbt/shell/shell.rb, line 57 def reset super() begin require 'readline' rescue LoadError; end @namespace = NAMESPACE @can_we_use_readline = Object.const_defined? :Readline # ======================================================================= # # If the following variable is set to true, then the Shell will # ask for user-input. This is the default. # ======================================================================= # @run_the_main_loop = true @use_this_prefix = nil end
return_compile_time()
click to toggle source
run()
click to toggle source
run_main_loop()
click to toggle source
#¶ ↑
run_main_loop
¶ ↑
#¶ ↑
# File lib/rbt/shell/shell.rb, line 122 def run_main_loop notify_the_user_that_input_can_be_passed_in_now loop { # ===================================================================== # # First, we have to obtain the user input. # ===================================================================== # obtain_user_input i = @user_input if i.include? ' ' splitted = i.split(' ') @all_arguments = splitted[1 .. -1].join(' ').strip i = splitted.first else @all_arguments = nil end a = @all_arguments menu(i) { a } } end
set_input(i = '')
click to toggle source
set_use_this_prefix(i)
click to toggle source
show_available_programs()
click to toggle source
show_compile_time()
click to toggle source
show_help()
click to toggle source
#¶ ↑
show_help
(help tag)¶ ↑
#¶ ↑
# File lib/rbt/shell/help.rb, line 16 def show_help opnn; e 'These help options are available:' e display_colourized_comment ' show_compile_time # (1) show the '\ 'compile-time statistics (also aliased to '+ slateblue('stats?')+teal(')')+Colours.rev display_colourized_comment ' available? # (2) show the available programs' display_colourized_comment ' last_update? # (3) show when the last update '\ 'of the last 100 programs happened' display_colourized_comment ' autocompile # (4) try to autocompile '\ 'several programs' display_colourized_comment ' edit # (5) to edit a .yml file (recipe)' display_colourized_comment ' remove_entry aclocal # (6) remove the entry '\ '"aclocal" from the database of compiled programs' e end
show_last_update( n_last_programs = DEFAULT_SHOW_N_PROGRAMS_THAT_WERE_LAST_UPDATED )
click to toggle source
#¶ ↑
show_last_update
¶ ↑
#¶ ↑
# File lib/rbt/shell/shell.rb, line 204 def show_last_update( n_last_programs = DEFAULT_SHOW_N_PROGRAMS_THAT_WERE_LAST_UPDATED ) if n_last_programs.is_a? Array n_last_programs = n_last_programs.first end if n_last_programs.nil? n_last_programs = DEFAULT_SHOW_N_PROGRAMS_THAT_WERE_LAST_UPDATED # Default value. end n_last_programs = n_last_programs.to_i if n_last_programs.is_a? String array = Cookbooks::ShowLastUpdated.dataset? result = array[0 .. (n_last_programs - 1)] # -1 because Array start at 0. result.each_with_index {|inner_array, index| index += 1 # ["alock", "01 Jul 2011", 55] name_of_the_program = inner_array.first last_updated_when = inner_array[1] padded_index = ("#{index})").rjust(4,' ') e simp(padded_index)+' '+sfancy((name_of_the_program+':').ljust(30))+ 'Last updated: '+orange(last_updated_when) } end