60 lines
1.6 KiB
Ruby
Executable file
60 lines
1.6 KiB
Ruby
Executable file
#! /usr/bin/ruby
|
|
|
|
=begin
|
|
--------------------------------------------------------------------------------
|
|
|
|
Choose a version from among the subdirectories in the versions directory and
|
|
record that choice.
|
|
|
|
--------------------------------------------------------------------------------
|
|
--------------------------------------------------------------------------------
|
|
=end
|
|
|
|
begin
|
|
require File.expand_path('subscripts/common', File.dirname(__FILE__))
|
|
rescue LoadError => e
|
|
puts e
|
|
end
|
|
|
|
@version_parms_file = "#{@home}/scripts/subscripts/_current_version.rb"
|
|
|
|
# Find out what versions we have available
|
|
def build_version_list()
|
|
@version_names = []
|
|
Dir.foreach("#{@home}/versions") do |filename|
|
|
@version_names.push(filename) unless (filename[0,1] == "_") || (filename[0,1] == ".")
|
|
end
|
|
@version_names.sort!
|
|
raise "Found no version directories." unless @version_names.length > 0
|
|
end
|
|
|
|
# Write the current version to the file
|
|
def write_current_version(name)
|
|
File.open(@version_parms_file, "w") do |file|
|
|
file.puts "# what is the current version under test?"
|
|
file.puts "@version_name = '#{name}'"
|
|
end
|
|
puts "version set to #{name}"
|
|
end
|
|
|
|
#
|
|
# ---------------------------------------------------------
|
|
# MAIN ROUTINE
|
|
# ---------------------------------------------------------
|
|
#
|
|
|
|
build_version_list()
|
|
|
|
puts "Enter version number: "
|
|
@version_names.each_index do |index|
|
|
puts " #{index+1} = #{@version_names[index]}"
|
|
end
|
|
number = STDIN.gets.chomp.to_i
|
|
|
|
if number <= 0 || number > @version_names.length
|
|
puts "UNRECOGNIZED VERSION."
|
|
exit
|
|
end
|
|
|
|
write_current_version(@version_names[number - 1])
|
|
|