class RBT::Cookbooks::LocalCheckForLatest

Constants

STORE_HERE
#

STORE_HERE

Specify where to store the results.

#

Public Class Methods

new( run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/cookbooks/local_check_for_latest.rb, line 38
def initialize(
    run_already = true
  )
  reset
  run if run_already
end

Public Instance Methods

all_files?() click to toggle source
#

all_files?

#
# File lib/rbt/cookbooks/local_check_for_latest.rb, line 74
def all_files?
  @all_files
end
get_all_local_files() click to toggle source
#

get_all_local_files

#
# File lib/rbt/cookbooks/local_check_for_latest.rb, line 114
def get_all_local_files
  @all_files = Dir.glob(@source_directory).sort
end
get_available_programs() click to toggle source
#

get_avilable_programs

#
# File lib/rbt/cookbooks/local_check_for_latest.rb, line 140
def get_available_programs
  @available_programs = available_programs?
end
is_latest?(input) click to toggle source
#

is_latest?

The input to this method is something like:

/home/x/src/zsh/zsh-4.3.10.tar.bz2
#
# File lib/rbt/cookbooks/local_check_for_latest.rb, line 152
def is_latest?(input)
  short_name = ProgramInformation.return_name(input).downcase
  @cookbook_dataset.seek(short_name)
  _ = @cookbook_dataset.is_included?
  # The above is by default always true. Hence we must set it to false
  # in case ! .full_path == input
  the_path = @cookbook_dataset.full_path
  e the_path
  _ = false unless the_path == input
  return _
end
iterate_over_available_programs() click to toggle source
#

iterate_over_available_programs

When we have stored all available programs in the array @available_programs we can continue to iterate through it.

#
# File lib/rbt/cookbooks/local_check_for_latest.rb, line 84
def iterate_over_available_programs
  @available_programs.each { |program|
    cliner {
      @save_this_string_to_file << N+N
      _ = '   ---> '+program
      @save_this_string_to_file << _+N
      opne _
      all_files?.each { |long, short|
        if program == short
          if is_latest?(long)
            _ = long+' this is the latest version locally. You should keep it.'
            # Explanation: We don't store what we should keep, we only store
            # what we should remove, as suggestion to the user.
            # @save_this_string_to_file << _+N
            # Disabled the above APR 2011.
            e _
          else
            _ = "#{long} is quite old. You could consider deleting it."
            @save_this_string_to_file << "#{_}#{N}"
            opnwarn _
          end
        end
      }
    }
  }
end
reset() click to toggle source
#

reset (reset tag)

Initialize our variables here.

#
Calls superclass method RBT::Base#reset
# File lib/rbt/cookbooks/local_check_for_latest.rb, line 50
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @store_where
  # ======================================================================= #
  @store_where = STORE_HERE
  # ======================================================================= #
  # === @source_directory
  # ======================================================================= #
  @source_directory = source_directory?+'*/**'
  # ======================================================================= #
  # === @save_this_string_to_file
  # ======================================================================= #
  @save_this_string_to_file = ''.dup # we save this string to the file.
  # ======================================================================= #
  # === @cookbook_dataset
  # ======================================================================= #
  @cookbook_dataset = RBT::Cookbooks::SanitizeCookbook.new(:do_not_run_yet) { :fast }
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/cookbooks/local_check_for_latest.rb, line 167
def run
  reset
  get_available_programs # From the cookbook yaml file.
  get_all_local_files
  iterate_over_available_programs
  save_data_to_file
end
save_data_to_file() click to toggle source
#

save_data_to_file

Remove the file, then save the data into @store_where.

#
# File lib/rbt/cookbooks/local_check_for_latest.rb, line 130
def save_data_to_file
  opne 'Storing data into:'
  e "  #{sfile(store_where?)}"
  remove_file(store_where?)
  write_what_into(@save_this_string_to_file, store_where?)
end
store_where?() click to toggle source
#

store_where?

#
# File lib/rbt/cookbooks/local_check_for_latest.rb, line 121
def store_where?
  @store_where
end