class Torque::RecordPathnameSettings
Generates the pathname to use for the record file of the release notes
Public Class Methods
new(output_dir, project, custom, iterations, fs)
click to toggle source
@param output_dir The path to the release notes output directory @param project The project id @param custom True if this is a run with custom date settings, else false @param fs An instance of the FileSystem
class
# File lib/torque/record_pathname_settings.rb, line 14 def initialize(output_dir, project, custom, iterations, fs) @output_dir = output_dir @project = project @custom = custom @iterations = iterations @fs = fs end
Public Instance Methods
get_path()
click to toggle source
@return The path to the record file, generating one if it does not exist
# File lib/torque/record_pathname_settings.rb, line 24 def get_path generate_record_path if !@path @path end
Private Instance Methods
current_date_string()
click to toggle source
A string representing the current date: YYYY-MM-DD
# File lib/torque/record_pathname_settings.rb, line 85 def current_date_string Date.today.strftime("%Y-%m-%d") end
generate_record_path()
click to toggle source
Generates a value for @path
# File lib/torque/record_pathname_settings.rb, line 33 def generate_record_path if @custom path_for_custom_date_range elsif @iterations path_for_iterations else path_for_default end end
path_for_custom_date_range()
click to toggle source
The path to the record of the release notes file if a custom date range was used
# File lib/torque/record_pathname_settings.rb, line 44 def path_for_custom_date_range title = "#{@project}-#{current_date_string}" title += "-custom" path_base = "#{@output_dir}/previous/#{title}" path_to_test = "#{path_base}.txt" # If the first pathname tried is not in use, use it if !(@fs.path_exist? path_to_test) @path=path_to_test # Else, will append "1", "2", "3"... to the end of the pathname, returning the first name that is not in use else i=1 while true path_to_test = "#{path_base}#{i}.txt" if !(@fs.path_exist? path_to_test) @path=path_to_test break end i+=1 end end @path end
path_for_default()
click to toggle source
The path to the record of the release notes file if default dates were used
# File lib/torque/record_pathname_settings.rb, line 78 def path_for_default title = "#{@project}-#{current_date_string}" @path = "#{@output_dir}/previous/#{title}.txt" @path end
path_for_iterations()
click to toggle source
# File lib/torque/record_pathname_settings.rb, line 70 def path_for_iterations title = "#{@project}-#{current_date_string}" title += "-iter-#{@iterations}" @path = "#{@output_dir}/previous/#{title}.txt" @path end