Permalink
Browse files

finishing the beginning

  • Loading branch information...
1 parent bfd2cfb commit 07f676c67941206f14cf43d9d80adfba1b20c902 @aquaman committed Jun 24, 2011
Showing with 90 additions and 9 deletions.
  1. +90 −9 install_win.rb
View
@@ -9,19 +9,21 @@
# b) files to rewrite include EVERYTHING, except: .PDF, .GIF, .RTF, .XLS
# 5. Update SBTM.YML
#
-# Last Updated:: 22 June 2011
+# Last Updated:: 24 June 2011
#
## 1) Check to make sure this is a Windows operating system:
-# puts ENV['OS'] << returns OS in windows, but blank/nil in Linux. what about OS X? Test this!
-
if RUBY_PLATFORM !~ /mswin|windows|cygwin|mingw32/i
puts 'This script is meant for users of the MS Windows operating system only.'
puts 'Nothing to do.'
exit
end
+puts
+puts 'Cleaning up the files for Windows use...'
+puts
+
## 2) Collect the file and folder names:
@@ -40,10 +42,9 @@
end
-## 4) rewrite all files that have had the line endings set to LF:
+## 4) rewrite all text files to change the line endings from LF to CR:
filez.delete_if {|filename| filename !~ /\.rb|\.txt|\.bat|\.ini|\.yml|\.tpl|\.htm|\.ses|\.drd/i }
-filez.delete( File.basename($0) ) # (let's not overwrite the script that is running!)
def rewrite( filename )
timez = []
@@ -63,8 +64,88 @@ def rewrite( filename )
## 5) Update SBTM.YML:
-# Ask for name
-# Ask for initials
-# write info to SBTM.YML
+puts '*' * 40
+puts "\n Update the SBTM.YML configuration file\n\n"
+puts '*' * 40
+puts
+
+# Find the 'config' folder & file..
+config_file = ''
+filez.each { |file| config_file = file if ( file =~ /sbtm\.yml/ and file !~ /doc/ ) }
+
+if config_file.empty? or ! File.exist?( config_file )
+
+ puts 'Could not find the "config/sbtm.yml" file to update.'
+ puts 'Please be sure to update this file before you begin.'
+
+else
+
+ puts 'Updating : ' + config_file
+
+ # Ask for name & initials
+ full_name = ''
+ initials = ''
+ name_valid = false
+ initials_valid = false
+
+ while ! name_valid
+ print "\n1) Enter your full name : "
+ full_name = $stdin.gets.strip
+ puts
+
+ if full_name.empty? or full_name.length > 100
+ puts '> Please enter the name you will use in your session sheets.'
+ puts '> Please enter a name less than 100 characters.' if full_name.length > 100
+ else
+ name_valid = true
+ full_name =~ /^(\S+)\s*/
+ puts "Thanks, #{$1}!\n\n"
+ end
+
+ puts
+ end
+
+ while ! initials_valid
+ print "2) Enter your initials : "
+ initials = $stdin.gets.strip
+ inits = initials.length
+ puts
+
+ if initials.empty? or inits < 2 or inits > 3
+ puts '> Your initials are used to create the session sheet file names.'
+ puts '> Please enter 2 or 3 initials to uniquely identify your work.'
+ else
+ initials_valid = true
+ puts 'Terrific!'
+ end
+ puts
+ end
+
+ # write info to SBTM.YML
+ puts 'Adding your information to the configuration file ...'
+
+ config_info = IO.readlines( config_file )
+ f = File.new( config_file, 'w' )
+
+ config_info.each do|line|
+ if line =~ /full name:/
+ line =~ /(\s+full name:\s+)(.*)/
+ f.puts $1.chomp + full_name
+
+ elsif line =~ /initials:/
+ line =~ /(\s+initials:\s+)(.*)/
+ f.puts $1.chomp + initials
+
+ else
+ f.puts line
+ end
+ end
+
+ f.close
+
+end
+
+puts
+puts 'Please check the "scan_options" to make sure they match your needs.'
-puts 'Done!'
+puts "\n>> Setup complete."

0 comments on commit 07f676c

Please sign in to comment.