class RBT::Prefix
Constants
- DEFAULT_PREFIX
- USR_PREFIX
#¶ ↑
USR_PREFIX
¶ ↑#¶ ↑
Public Class Methods
new( optional_use_this_program_name = nil, run_already = true ) { || ... }
click to toggle source
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/rbt/prefix/prefix.rb, line 40 def initialize( optional_use_this_program_name = nil, run_already = true ) reset # Must always come first. if optional_use_this_program_name set_original_input(optional_use_this_program_name) set_program(optional_use_this_program_name) end if block_given? yielded = yield case yielded # === :ntrad when :ntrad set_prefix(:ntrad) else run if run_already end else run if run_already end end
Public Instance Methods
<<(i)
click to toggle source
assign_prefix(i)
click to toggle source
#¶ ↑
assign_prefix
¶ ↑
Simply assign the prefix, without any further checking.
#¶ ↑
# File lib/rbt/prefix/prefix.rb, line 261 def assign_prefix(i) case i # ======================================================================= # # === :default # ======================================================================= # when :default, :default_prefix, nil i = DEFAULT_PREFIX end i = i.dup if i.frozen? i.strip! i << '/' unless i.end_with? '/' @internal_hash[:prefix] = i end
clear_program()
click to toggle source
do_use_appdir_prefix_from_this_input( i = program_name_and_program_version? )
Alias for: return_non_traditional_prefix
do_we_want_to_use_an_appdir_prefix?()
click to toggle source
eliminate_hyphens()
click to toggle source
empty?()
click to toggle source
end_with?(i)
click to toggle source
include?(i)
click to toggle source
is_an_appdir_prefix?()
click to toggle source
#¶ ↑
is_an_appdir_prefix?¶ ↑
#¶ ↑
# File lib/rbt/prefix/prefix.rb, line 309 def is_an_appdir_prefix? prefix?.start_with?(program_directory?) end
Also aliased as: makes_use_of_an_appdir_prefix?, appdir?
prefix?()
click to toggle source
program?()
click to toggle source
program_name_and_program_version?()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset¶ ↑
#¶ ↑
Calls superclass method
RBT::LeanPrototype#reset
# File lib/rbt/prefix/prefix.rb, line 66 def reset super() # ======================================================================= # # === :prefix # ======================================================================= # set_prefix(nil) # nil initially. This is our prefix variable. set_program set_be_quiet set_program_version # ======================================================================= # # === @do_we_want_to_use_an_appdir_prefix # # We want to be able to store here whether an AppDir prefix is to # be used. # ======================================================================= # @do_we_want_to_use_an_appdir_prefix = false end
return_non_traditional_prefix( i = program_name_and_program_version? )
click to toggle source
#¶ ↑
return_non_traditional_prefix
¶ ↑
This method will return a proper non-traditional prefix.
#¶ ↑
# File lib/rbt/prefix/prefix.rb, line 334 def return_non_traditional_prefix( i = program_name_and_program_version? ) program_information = ::ProgramInformation::ProgramInformation.new( i, true, be_verbose? ) # bl $RUBY_COOKBOOKS/lib/cookbooks/program_information.rb name = program_information.name.to_s.capitalize.delete('-_').capitalize version = program_information.version i = "#{programs_dir?}#{name}/#{version}/".dup # This has the version name # ======================================================================= # # Ensure that it will always have a trailing '/' token. # ======================================================================= # i << '/' unless i.end_with? '/' # ======================================================================= # # As of May 2014 we get rid of all '-'. # ======================================================================= # i.delete!('-') if i.include? '-' return i # This here should usually return a string like "/Programs/Htop/1.1.0" end
Also aliased as: do_use_appdir_prefix_from_this_input
run()
click to toggle source
set_original_input(i)
click to toggle source
set_prefix( i = program? )
click to toggle source
#¶ ↑
set_prefix
¶ ↑
This methods assigns to the instance variable @internal_hash which keeps the prefix in use. The prefix instance variable is stored in the variable @internal_hash.
Input should include the version, i.e. “htop-1.0” would be a proper input.
#¶ ↑
# File lib/rbt/prefix/prefix.rb, line 195 def set_prefix( i = program? ) case i.to_s # case tag # ======================================================================= # # === gobolinux # # This entry point essentially means "make use of an AppDir-like prefix. # ======================================================================= # when 'gobolinux', 'gobolinux_prefix', 'ntrad', 'false', 'default', 'app_dir_like', /^app(_|-)?dir/ we_will_use_an_appdir_prefix i = return_non_traditional_prefix( program_name_and_program_version? ).to_s # defined in this file here. # ===================================================================== # # As of May 2014 we get rid of all '-' # ===================================================================== # i.delete!('-') if i.include?('-') # ======================================================================= # # === true # ======================================================================= # when 'true', 't', 'trad', 'traditional', 'tra', 'def' # True means "usr" prefix. i = USR_PREFIX else # Else default to USR_PREFIX. # i = USR_PREFIX end assign_prefix(i) if i # Now, simply assign it here. end
set_program(i = nil)
click to toggle source
#¶ ↑
set_program
¶ ↑
Use this method to set the instance variable @internal_hash.
It shall be kept like that. The input can contain a ‘-’.
#¶ ↑
# File lib/rbt/prefix/prefix.rb, line 144 def set_program(i = nil) case i # ======================================================================= # # === :traditional # ======================================================================= # when :traditional, :trad set_prefix(i) i = nil # ======================================================================= # # === :nontrad # ======================================================================= # when :nontrad, :ntrad we_will_use_an_appdir_prefix end @internal_hash[:program] = i # Can contain something like htop. end
Also aliased as: assign
set_program_version(i = '1.0.0')
click to toggle source
strip!()
click to toggle source
sub!(old, new)
click to toggle source
use_appdir_prefix_for_this_program(i)
click to toggle source
use_non_traditional_prefix()
click to toggle source
#¶ ↑
use_non_traditional_prefix
¶ ↑
This method will assign to a non-traditional (gobolinux) prefix.
#¶ ↑
# File lib/rbt/prefix/prefix.rb, line 251 def use_non_traditional_prefix set_prefix(:gobolinux) end
Also aliased as: gobolinux_prefix, enable_non_traditional_compilation
we_will_use_an_appdir_prefix()
click to toggle source
#¶ ↑
we_will_use_an_appdir_prefix
¶ ↑
#¶ ↑
# File lib/rbt/prefix/prefix.rb, line 94 def we_will_use_an_appdir_prefix @do_we_want_to_use_an_appdir_prefix = true end
Also aliased as: do_use_appdir_prefix