class RBT::RegisterProgramFilesIntoYamlDatabase
Constants
- DEFAULT_INPUT_DIRECTORY
#¶ ↑
DEFAULT_INPUT_DIRECTORY
¶ ↑#¶ ↑
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
Public Class Methods
batch()
click to toggle source
#¶ ↑
RBT::RegisterProgramFilesIntoYamlDatabase.batch
¶ ↑
This method will run through all entries at /Programs, and register it.
#¶ ↑
# File lib/rbt/utility_scripts/register_program_files_into_yaml_database.rb, line 274 def self.batch files = Dir["#{RBT.programs_directory?}*"].map {|entry| entry << '/Current/'} files.sort.each {|entry| e "Working on #{sfancy(entry)} next." e RBT::RegisterProgramFilesIntoYamlDatabase.new(entry) e } end
new( i = nil, run_already = true )
click to toggle source
Public Instance Methods
entries?()
click to toggle source
#¶ ↑
entries?¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/register_program_files_into_yaml_database.rb, line 132 def entries? @entries end
Also aliased as: files?
fetch_entries()
click to toggle source
#¶ ↑
fetch_entries
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/register_program_files_into_yaml_database.rb, line 151 def fetch_entries opnn; e "Obtaining all files from `#{sdir(where?)}`." path = "#{@register_where}**/**" _ = Dir[path] # ======================================================================= # # Select only files: # ======================================================================= # _.select! {|entry| File.file? entry } @entries = _ end
register_into_yaml_file()
click to toggle source
#¶ ↑
register_into_yaml_file
¶ ↑
This method will use the Current symlink.
#¶ ↑
# File lib/rbt/utility_scripts/register_program_files_into_yaml_database.rb, line 188 def register_into_yaml_file # This will register @array_register_these_files finally _ = register_where? set_versioned_directory(_) if (_.count('/') < 3) and !_.end_with?('Current/') _ << 'Current/' unless File.symlink?(_) and return_pwd.include?(programs_dir?) # Try to re-create the Symlink here if we are in the /Programs directory. target = @register_where target = File.dirname(target) if target.end_with? 'Current/' if File.directory? target Dir.chdir(target) target = get_directories_from(target).sort.first set_versioned_directory(target) if target remove_directory('Current') if File.directory?('Current') # Must be a Symlink. symlink(target.chop, _.chop) # .chop to get rid of '/'. end else opnn; e sdir(target)+swarn(' is not a directory.') end end end _ << 'yaml/' mkdir _ unless File.directory? _ # The directory should exist. # ======================================================================= # # We will store in a yaml/ subdirectory, in a file called # registered_files.yml # ======================================================================= # registered_files = rds("#{_}registered_files.yml") if run_simulation? e "We would now remove #{simp(registered_files.to_s)} if we" e 'would not be in simulation mode.' else # ===================================================================== # # Get rid of the old .yml file, if it exists. # ===================================================================== # remove(registered_files) if File.exist? registered_files end unless run_simulation? if @entries.empty? opne 'We will not store the registered files as' opne 'the dataset is empty.' else opne 'Storing dataset ('+sfancy(registered_files.size.to_s)+ ' files) into:' opne ' `'+sfile(registered_files)+'`.' _ = @entries.map {|entry| entry.sub(/#{@register_where}/,'') } _.reject! {|entry| entry.include? 'registered_files.yml' } # Reject self-name. _.reject! {|entry| entry.end_with? 'Resources/full_configure_command' or entry.end_with? 'Resources/full_configure_command.md' or entry.end_with? 'Resources/Architecture' } _.map! {|entry| entry.gsub(/#{Regexp.quote(@versioned_directory)}/,'') } unless _.empty? save_what_into( YAML.dump(_), registered_files ) end end end end
register_where?()
click to toggle source
#¶ ↑
register_where?¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/register_program_files_into_yaml_database.rb, line 165 def register_where? @register_where end
Also aliased as: where?
report_files()
click to toggle source
reset()
click to toggle source
run()
click to toggle source
run_simulation=(i)
click to toggle source
run_simulation?()
click to toggle source
#¶ ↑
run_simulation
?¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/register_program_files_into_yaml_database.rb, line 172 def run_simulation? @run_simulation end
Also aliased as: run_simulation
set_register_where( i = DEFAULT_INPUT_DIRECTORY )
click to toggle source
#¶ ↑
set_register_where
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/register_program_files_into_yaml_database.rb, line 91 def set_register_where( i = DEFAULT_INPUT_DIRECTORY ) i = DEFAULT_INPUT_DIRECTORY if i.nil? i = i.to_s.dup # Get a copy here. Must be a String. case i # case tag # ========================================================================= # # === register_program_files --batch # ========================================================================= # when /^-?-?batch$/ self.class.batch # ========================================================================= # # === register_program_files --pwd # # This entry point can, for example, be invokved in a directory such # as /Programs/Htop/Current. # ========================================================================= # when /^-?-?pwd$/,'pwd','PWD','Dir.pwd','cwd','HERE' # Handle pwd i = Dir.pwd end i = rds(i) i << '/' unless i.end_with? '/' # ========================================================================= # # Append 'Current/'. A proper target must end with 'Current/', since # that is the symlink on GoboLinux. # ========================================================================= # unless i.count('/') > 2 i << 'Current/' unless i.include? 'Current/' end # ========================================================================= # # i.delete!('-') if i.include? '-' # Added Aug 2014. # ^^^ Disabled as of Sep 2017. If we want to use this, then we may have # to use a configuration setting for the whole RBT project. If this is # done, then we can re-enable the above, but for now, it stays disabled. # ========================================================================= # @register_where = i end
set_versioned_directory(i)
click to toggle source
#¶ ↑
set_versioned_directory
¶ ↑
We need to keep track here so that we can get rid of the version string of the directory when we save into the yaml file.
#¶ ↑
# File lib/rbt/utility_scripts/register_program_files_into_yaml_database.rb, line 142 def set_versioned_directory(i) i = i.to_s.dup i << '/' unless i.end_with? '/' @versioned_directory = i end