module Utilities
Public Instance Methods
ask(question, suggestion)
click to toggle source
# File lib/release/util/utilities.rb, line 31 def ask(question, suggestion) puts echo_with_color "#{question} #{suggestion} : ", 'green' $stdout.flush answer = gets.chomp unless answer == '' return answer end echo_with_color suggestion, 'yellow' suggestion end
echo_with_color(text, color)
click to toggle source
# File lib/release/util/utilities.rb, line 6 def echo_with_color(text, color) print text.send("#{color}") end
help_info(text)
click to toggle source
# File lib/release/util/utilities.rb, line 14 def help_info(text) echo_with_color text, 'yellow' end
next_snapshot(version)
click to toggle source
# File lib/release/util/utilities.rb, line 63 def next_snapshot(version) parts = $version.match(version).captures "#{parts[0]}#{Integer(parts[1])+1}-SNAPSHOT" end
read_file(file_name)
click to toggle source
# File lib/release/util/utilities.rb, line 53 def read_file(file_name) File.open(file_name).read end
right_padding(string,length)
click to toggle source
# File lib/release/util/utilities.rb, line 68 def right_padding(string,length) (string + ' ' * length)[0,length] end
terminate()
click to toggle source
# File lib/release/util/utilities.rb, line 10 def terminate abort 'Program terminated' end
verify_pattern(value, regex) { || ... }
click to toggle source
# File lib/release/util/utilities.rb, line 24 def verify_pattern(value, regex) unless regex.match(value) echo_with_color "#{value} must match #{regex}", 'red' yield end end
verify_pattern_terminate(value, regex)
click to toggle source
# File lib/release/util/utilities.rb, line 18 def verify_pattern_terminate(value, regex) verify_pattern value, regex do terminate end end
wait_or_do(message) { || ... }
click to toggle source
# File lib/release/util/utilities.rb, line 46 def wait_or_do(message) echo_with_color message, 'red' unless (ask 'Continue?', 'y') == 'y' yield end end
write_file(file_name, file_content)
click to toggle source
# File lib/release/util/utilities.rb, line 57 def write_file(file_name, file_content) File.open(file_name, 'w') do |file| file.write(file_content) end end