<commit_before>#
#  Installer for Watir
#

def getNewLocation( forWhat, default)
    puts "New location for #{forWhat}: [ #{default} ] "
    n = gets.chomp!
    n = default if n == ""
    return n
end

def getBooleanOption(label, default)
    n = nil
    while n != 'true' and n != 'false'
        puts "New value for #{label}: [#{default}] "
        n = gets.chomp!.downcase
        n = default.to_s if n == ""
    end
    return false if n == "false"
    return true if n == "true"
    return nil # should never execute
end

def copyFile( from , to )
    c = File.cp(from , to, true)
    if !c
        puts "Problem copying #{from}"
        exit
    end
end

def showBanner( bonusLocation , desktopIcon , startMenuIcon )

    puts "\n"
    puts "*******************************************************************************"
    puts "*                                                                             *"
    puts "* Installer for WATIR                                                         *"
    puts "*                                                                             *"
    puts "*  These settings will be used, press c and then enter to                     *"
    puts "*  change them or just press enter to use these defaults.                     *"
    puts "*                                                                             *"
    puts "*  Bonus files include examples, documentation and unit tests.                *"
    puts "*  " + ("Bonus files:     " + bonusLocation.gsub("/" , "\\")).ljust(75) + "*"
    puts "*                                                                             *"
    puts "*  Create a desktop shortcut:    " +  desktopIcon.to_s.ljust(45)  + "*"
    puts "*  Create a start menu shortcut: " +  desktopIcon.to_s.ljust(45)  + "*"
    puts "*                                                                             *"
    puts "*******************************************************************************"

    n = gets.chomp!
    return n
end

def makeStartMenuShortCut( name , targetURL )

    #http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsobjwshshortcut.asp
    wshShell = WIN32OLE.new("WScript.Shell")
    strStartMenu = wshShell.SpecialFolders("AllUsersStartMenu")
    d = File.makedirs(strStartMenu + '/Programs/watir/' )
    oShellLink = wshShell.CreateShortcut(strStartMenu +  '\\Programs\\' + "watir\\#{name}.lnk")
    oShellLink.TargetPath =  targetURL 
    oShellLink.WindowStyle = 1
    oShellLink.Hotkey = "CTRL+SHIFT+F"
    oShellLink.Description = name
    oShellLink.WorkingDirectory = strStartMenu 
    oShellLink.Save
    wshShell = nil
end

def makeDeskTopShortCut( name , targetURL )

    wshShell = WIN32OLE.new("WScript.Shell")
    strDesktop = wshShell.SpecialFolders("Desktop")
    oShellLink = wshShell.CreateShortcut(strDesktop +  '\\' + name +  '.lnk')
    oShellLink.TargetPath =  targetURL 
    oShellLink.WindowStyle = 1
    oShellLink.Hotkey = "CTRL+SHIFT+F"
    oShellLink.Description = name
    oShellLink.WorkingDirectory = strDesktop
    oShellLink.Save
    wshShell = nil
end


require 'win32ole'
require 'ftools'
require 'FileUtils'
include FileUtils::Verbose

require 'rbconfig'
siteLib = Config::CONFIG['sitelibdir']
display_lib = siteLib.gsub("/" , "\\")

# defaults
homeDrive = ENV["HOMEDRIVE"]
bonusLocation = homeDrive + "/watir_bonus/"
deskTop  = true
startMenu = true

n = showBanner(bonusLocation , deskTop , startMenu  )
while n.downcase == "c"
    puts "New directories selected!"
    bonusLocation  = getNewLocation("Bonus Files"    , bonusLocation.gsub("/" , "\\"))
    deskTop = getBooleanOption("Create a desktop shortcut", deskTop)
    startMenu = getBooleanOption("Create a start menu shortcut" , startMenu)
    n = showBanner(bonusLocation , deskTop , startMenu)
end

# TODO: check to see if stuff already exists

# copy the watir libs to siteLib 
puts "Copying Files"
d = File.makedirs(siteLib + '/watir/' )
copyFile( 'watir.rb' , siteLib )
copyFile( 'watir/winClicker.rb' , siteLib + '/watir/' )
copyFile( 'watir/clickJSDialog.rb' , siteLib + '/watir/' )
copyFile( 'watir/testUnitAddons.rb' , siteLib + '/watir/' )<commit_msg>fixed installer bug -- exceptions.rb not found<commit_after>#
#  Installer for Watir
#

def getNewLocation( forWhat, default)
    puts "New location for #{forWhat}: [ #{default} ] "
    n = gets.chomp!
    n = default if n == ""
    return n
end

def getBooleanOption(label, default)
    n = nil
    while n != 'true' and n != 'false'
        puts "New value for #{label}: [#{default}] "
        n = gets.chomp!.downcase
        n = default.to_s if n == ""
    end
    return false if n == "false"
    return true if n == "true"
    return nil # should never execute
end

def copyFile( from , to )
    c = File.cp(from , to, true)
    if !c
        puts "Problem copying #{from}"
        exit
    end
end

def showBanner( bonusLocation , desktopIcon , startMenuIcon )

    puts "\n"
    puts "*******************************************************************************"
    puts "*                                                                             *"
    puts "* Installer for WATIR                                                         *"
    puts "*                                                                             *"
    puts "*  These settings will be used, press c and then enter to                     *"
    puts "*  change them or just press enter to use these defaults.                     *"
    puts "*                                                                             *"
    puts "*  Bonus files include examples, documentation and unit tests.                *"
    puts "*  " + ("Bonus files:     " + bonusLocation.gsub("/" , "\\")).ljust(75) + "*"
    puts "*                                                                             *"
    puts "*  Create a desktop shortcut:    " +  desktopIcon.to_s.ljust(45)  + "*"
    puts "*  Create a start menu shortcut: " +  desktopIcon.to_s.ljust(45)  + "*"
    puts "*                                                                             *"
    puts "*******************************************************************************"

    n = gets.chomp!
    return n
end

def makeStartMenuShortCut( name , targetURL )

    #http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsobjwshshortcut.asp
    wshShell = WIN32OLE.new("WScript.Shell")
    strStartMenu = wshShell.SpecialFolders("AllUsersStartMenu")
    d = File.makedirs(strStartMenu + '/Programs/watir/' )
    oShellLink = wshShell.CreateShortcut(strStartMenu +  '\\Programs\\' + "watir\\#{name}.lnk")
    oShellLink.TargetPath =  targetURL 
    oShellLink.WindowStyle = 1
    oShellLink.Hotkey = "CTRL+SHIFT+F"
    oShellLink.Description = name
    oShellLink.WorkingDirectory = strStartMenu 
    oShellLink.Save
    wshShell = nil
end

def makeDeskTopShortCut( name , targetURL )

    wshShell = WIN32OLE.new("WScript.Shell")
    strDesktop = wshShell.SpecialFolders("Desktop")
    oShellLink = wshShell.CreateShortcut(strDesktop +  '\\' + name +  '.lnk')
    oShellLink.TargetPath =  targetURL 
    oShellLink.WindowStyle = 1
    oShellLink.Hotkey = "CTRL+SHIFT+F"
    oShellLink.Description = name
    oShellLink.WorkingDirectory = strDesktop
    oShellLink.Save
    wshShell = nil
end


require 'win32ole'
require 'ftools'
require 'FileUtils'
include FileUtils::Verbose

require 'rbconfig'
siteLib = Config::CONFIG['sitelibdir']
display_lib = siteLib.gsub("/" , "\\")

# defaults
homeDrive = ENV["HOMEDRIVE"]
bonusLocation = homeDrive + "/watir_bonus/"
deskTop  = true
startMenu = true

n = showBanner(bonusLocation , deskTop , startMenu  )
while n.downcase == "c"
    puts "New directories selected!"
    bonusLocation  = getNewLocation("Bonus Files"    , bonusLocation.gsub("/" , "\\"))
    deskTop = getBooleanOption("Create a desktop shortcut", deskTop)
    startMenu = getBooleanOption("Create a start menu shortcut" , startMenu)
    n = showBanner(bonusLocation , deskTop , startMenu)
end

# TODO: check to see if stuff already exists

# copy the watir libs to siteLib 
puts "Copying Files"
d = File.makedirs(siteLib + '/watir/' )
copyFile( 'watir.rb' , siteLib )
FileUtils.cp_r('watir', siteLib, {:verbose=> true} )
{'fraction_non_alphanumeric': 0.14725327563409063, 'fraction_numerical': 0.0038466161798293066, 'mean_word_length': 2.124295906871949, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2176121', 'n_tokens_mistral': 2455, 'n_tokens_neox': 2391, 'n_words': 599}