selenium-prep 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/Gemfile +3 -0
- data/Guardfile +4 -0
- data/README.txt +57 -0
- data/Rakefile +1 -0
- data/lib/selenium-prep/config-checker.rb +28 -0
- data/lib/selenium-prep/downloader.rb +49 -0
- data/lib/selenium-prep/overrides.rb +19 -0
- data/lib/selenium-prep/system/extract.rb +41 -0
- data/lib/selenium-prep/system/folder.rb +36 -0
- data/lib/selenium-prep/system/path.rb +40 -0
- data/lib/selenium-prep/urls.rb +19 -0
- data/lib/selenium-prep/version.rb +3 -0
- data/lib/selenium-prep.rb +32 -0
- data/selenium-prep.gemspec +26 -0
- data/spec/config-checker_spec.rb +25 -0
- data/spec/downloader_spec.rb +23 -0
- data/spec/extract_spec.rb +36 -0
- data/spec/folder_spec.rb +71 -0
- data/spec/selenium-prep_spec.rb +17 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/url_spec.rb +27 -0
- metadata +161 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 1b27c6417570b34619186a139d1f2f35f67fe163
         | 
| 4 | 
            +
              data.tar.gz: d44aaaa38d2c9812211a30ca9745308e603b613c
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: a58a8c2bea9630f88771ec85327f2764b9999de6175090bb797b7b53530198aeb41f33997b7c82d086ec77c3773fac9453f00f1905915b7230cdd4cc54147fff
         | 
| 7 | 
            +
              data.tar.gz: 8eb1c83e25b5906d983352e14ee65869d8d777f7b109970fbada173f7d9250ea89026046cde099c72260e0909f87dd56c5032a2c307c93cad221a2321f583b0d
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/Guardfile
    ADDED
    
    
    
        data/README.txt
    ADDED
    
    | @@ -0,0 +1,57 @@ | |
| 1 | 
            +
            = selenium-prep
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            == DESCRIPTION:
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            selenium-prep helps set up your machine for local Selenium execution for multiple browsers. It downloads (in parallel) the latest browser drivers and standalone server to a specified location. It will then check your system PATH to see if the directory is in it. If not, it will provide you with information on how to configure it for your operating system.
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            == INSTALLATION:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Coming soon.
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            == USAGE:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            === Environment Variables
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            SE_OS_TYPE (e.g., 'linux32', 'linux64', 'mac32', 'win32', 'win64')
         | 
| 16 | 
            +
            SE_DOWNLOAD_LOCATION (e.g., full path)
         | 
| 17 | 
            +
            SE_DEBUG (e.g., 'off' to disable all standard output -- on by default)
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            If these values are not set properly, a RuntimeError will be returned along with a helpful message.
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            === Downloading
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            SeleniumPrep.download
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            NOTE: The downloader will check to see if the download directory is empty. If not, it will prompt you to proceed, overwriting files of the same name.
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            === Check System Path
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            Find out if your path is set correctly and if not provide instructions on how to proceed.
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            SeleniumPrep.path_set?
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            NOTE: Will return a boolean result in addition to helpful messaging. This will automatically run after downloading completes.
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            == LICENSE:
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            The MIT License (MIT)
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            Copyright (c) 2014 Dave Haeffner
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         | 
| 42 | 
            +
            of this software and associated documentation files (the "Software"), to deal
         | 
| 43 | 
            +
            in the Software without restriction, including without limitation the rights
         | 
| 44 | 
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         | 
| 45 | 
            +
            copies of the Software, and to permit persons to whom the Software is
         | 
| 46 | 
            +
            furnished to do so, subject to the following conditions:
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            The above copyright notice and this permission notice shall be included in all
         | 
| 49 | 
            +
            copies or substantial portions of the Software.
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         | 
| 52 | 
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         | 
| 53 | 
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         | 
| 54 | 
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         | 
| 55 | 
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         | 
| 56 | 
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         | 
| 57 | 
            +
            SOFTWARE.
         | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            require 'bundler/gem_tasks'
         | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            module SeleniumPrep
         | 
| 2 | 
            +
              class ConfigChecker
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                def initialize
         | 
| 5 | 
            +
                  download_location
         | 
| 6 | 
            +
                  os_type
         | 
| 7 | 
            +
                end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                private
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  ERRORS = { NoDownloadLocationSpecified: 'You need to specify a download location with SE_DOWNLOAD_LOCATION.',
         | 
| 12 | 
            +
                             NoOSTypeSpecified:           'You need to specify an operating system type with SE_OS_TYPE.' }
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def download_location
         | 
| 15 | 
            +
                    if ENV['SE_DOWNLOAD_LOCATION'].nil?
         | 
| 16 | 
            +
                      raise ERRORS[:NoDownloadLocationSpecified]
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def os_type
         | 
| 21 | 
            +
                    if ENV['SE_OS_TYPE'].nil?
         | 
| 22 | 
            +
                      raise ERRORS[:NoOSTypeSpecified]
         | 
| 23 | 
            +
                    end
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
             | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
            end
         | 
| @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            require_relative 'urls'
         | 
| 2 | 
            +
            require_relative 'config-checker'
         | 
| 3 | 
            +
            require 'uri'
         | 
| 4 | 
            +
            require 'typhoeus'
         | 
| 5 | 
            +
            require 'fileutils'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module SeleniumPrep
         | 
| 8 | 
            +
              module Downloader
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                include URLs
         | 
| 11 | 
            +
                extend self
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def download
         | 
| 14 | 
            +
                  ConfigChecker.new
         | 
| 15 | 
            +
                  hydra = Typhoeus::Hydra.new(max_concurrency: 3)
         | 
| 16 | 
            +
                  urls.each do |url|
         | 
| 17 | 
            +
                    file = file_for url
         | 
| 18 | 
            +
                    download = File.open(file, 'wb')
         | 
| 19 | 
            +
                    puts "[ #{Time.now} ]   Downloading #{file}"
         | 
| 20 | 
            +
                    request = Typhoeus::Request.new url
         | 
| 21 | 
            +
                    request.on_body do |payload|
         | 
| 22 | 
            +
                      download.write payload
         | 
| 23 | 
            +
                    end
         | 
| 24 | 
            +
                    request.on_complete do |response|
         | 
| 25 | 
            +
                      download.close
         | 
| 26 | 
            +
                      puts "[ #{Time.now} ]   Finished downloading #{file}"
         | 
| 27 | 
            +
                    end
         | 
| 28 | 
            +
                    hydra.queue request
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  hydra.run
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                private
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  def urls
         | 
| 37 | 
            +
                    tmp = []
         | 
| 38 | 
            +
                    tmp << DRIVERS[ENV['SE_OS_TYPE'].to_sym]
         | 
| 39 | 
            +
                    tmp << [ SERVER ]
         | 
| 40 | 
            +
                    tmp.flatten
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  def file_for(url)
         | 
| 44 | 
            +
                    filename = File.basename(URI.parse(url).path)
         | 
| 45 | 
            +
                    File.join(ENV['SE_DOWNLOAD_LOCATION'], filename)
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
            end
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            module SeleniumPrep
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              def self.debug_off?
         | 
| 4 | 
            +
                ENV['SE_DEBUG'] == 'off'
         | 
| 5 | 
            +
              end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            module Kernel
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              def puts(input)
         | 
| 12 | 
            +
                super input unless SeleniumPrep.debug_off?
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              def print(input)
         | 
| 16 | 
            +
                super input unless SeleniumPrep.debug_off?
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            end
         | 
| @@ -0,0 +1,41 @@ | |
| 1 | 
            +
            require 'zip'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module SeleniumPrep
         | 
| 4 | 
            +
              module System
         | 
| 5 | 
            +
                module Extract
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  extend self
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  def extract_zip_files
         | 
| 10 | 
            +
                    puts "Extracting zip files..."
         | 
| 11 | 
            +
                    zip_files.each do |file|
         | 
| 12 | 
            +
                      Zip::File.open(file, 'wb') do |zip_file|
         | 
| 13 | 
            +
                        zip_file.each do |f|
         | 
| 14 | 
            +
                          f_path = File.join(ENV['SE_DOWNLOAD_LOCATION'], f.name)
         | 
| 15 | 
            +
                          delete_file f_path if File.exist? f_path
         | 
| 16 | 
            +
                          zip_file.extract(f, f_path)
         | 
| 17 | 
            +
                        end
         | 
| 18 | 
            +
                      end
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  def delete_zip_files
         | 
| 23 | 
            +
                    puts 'Deleting zip files...'
         | 
| 24 | 
            +
                    zip_files.each { |zip_file| delete_file zip_file }
         | 
| 25 | 
            +
                    puts 'Done working with zip files.'
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  private
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                    def zip_files
         | 
| 31 | 
            +
                      Dir.glob("#{ENV['SE_DOWNLOAD_LOCATION']}/*").collect do |file|
         | 
| 32 | 
            +
                        file if file.include?('.zip')
         | 
| 33 | 
            +
                      end.compact!
         | 
| 34 | 
            +
                    end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                    def delete_file(file)
         | 
| 37 | 
            +
                      FileUtils.rm file
         | 
| 38 | 
            +
                    end
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
            end
         | 
| @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            module SeleniumPrep
         | 
| 2 | 
            +
              module System
         | 
| 3 | 
            +
                module Folder
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  extend self
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  def directory_exists?
         | 
| 8 | 
            +
                    File.directory?(ENV['SE_DOWNLOAD_LOCATION'])
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  def downloads_exist?
         | 
| 12 | 
            +
                    !Dir.glob("#{ENV['SE_DOWNLOAD_LOCATION']}/*").empty?
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def create_directory
         | 
| 16 | 
            +
                    FileUtils.mkdir_p(ENV['SE_DOWNLOAD_LOCATION'])
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def empty_directory
         | 
| 20 | 
            +
                    FileUtils.rm_rf Dir.glob("#{ENV['SE_DOWNLOAD_LOCATION']}/*")
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  def prompt_user
         | 
| 24 | 
            +
                    puts 'Your downloads directory is not empty. This will overwrite files of the same name.'
         | 
| 25 | 
            +
                    print 'Proceed? [Y/N]:  '
         | 
| 26 | 
            +
                    case $stdin.gets.chomp.downcase
         | 
| 27 | 
            +
                    when "y"
         | 
| 28 | 
            +
                      puts "Proceeding with download."
         | 
| 29 | 
            +
                    when "n"
         | 
| 30 | 
            +
                      raise 'Aborting download.'
         | 
| 31 | 
            +
                    end
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
            end
         | 
| @@ -0,0 +1,40 @@ | |
| 1 | 
            +
            require_relative '../config-checker'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module SeleniumPrep
         | 
| 4 | 
            +
              module System
         | 
| 5 | 
            +
                module Path
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  def self.set
         | 
| 8 | 
            +
                    ConfigChecker.new
         | 
| 9 | 
            +
                    puts "You need to add #{ENV['SE_DOWNLOAD_LOCATION']} to your path.\n\n"
         | 
| 10 | 
            +
                    case ENV['SE_OS_TYPE']
         | 
| 11 | 
            +
                    when 'win32', 'win64'
         | 
| 12 | 
            +
                      puts "For instructions on how to do that read:\n http://www.computerhope.com/issues/ch000549.htm"
         | 
| 13 | 
            +
                    when 'mac32', 'linux32', 'linux64'
         | 
| 14 | 
            +
                      puts "For instructions on how to do that read:\n http://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path"
         | 
| 15 | 
            +
                    end
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  def self.set?
         | 
| 19 | 
            +
                    ConfigChecker.new
         | 
| 20 | 
            +
                    case ENV['SE_OS_TYPE']
         | 
| 21 | 
            +
                    when 'win32', 'win64'
         | 
| 22 | 
            +
                      `echo %PATH%'`.include? ENV['SE_DOWNLOAD_LOCATION']
         | 
| 23 | 
            +
                    when 'mac32', 'linux32', 'linux64'
         | 
| 24 | 
            +
                      `echo $PATH`.include? ENV['SE_DOWNLOAD_LOCATION']
         | 
| 25 | 
            +
                    end
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  def self.path
         | 
| 29 | 
            +
                    ConfigChecker.new
         | 
| 30 | 
            +
                    case ENV['SE_OS_TYPE']
         | 
| 31 | 
            +
                    when 'win32', 'win64'
         | 
| 32 | 
            +
                      `echo %PATH%'`
         | 
| 33 | 
            +
                    when 'mac32', 'linux32', 'linux64'
         | 
| 34 | 
            +
                      `echo $PATH`
         | 
| 35 | 
            +
                    end
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
            end
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            module SeleniumPrep
         | 
| 2 | 
            +
              module URLs
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                BASE_URL  = {   chrome_driver:      'http://chromedriver.storage.googleapis.com/2.11',
         | 
| 5 | 
            +
                                ie_driver:          'http://selenium-release.storage.googleapis.com/2.43',
         | 
| 6 | 
            +
                                standalone_server:  'http://selenium-release.storage.googleapis.com/2.43' }
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                SERVER    =     "#{BASE_URL[:standalone_server]}/selenium-server-standalone-2.43.1.jar"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                DRIVERS   = {   mac32:   [ "#{BASE_URL[:chrome_driver]}/chromedriver_mac32.zip" ],
         | 
| 11 | 
            +
                                win32:   [ "#{BASE_URL[:chrome_driver]}/chromedriver_win32.zip",
         | 
| 12 | 
            +
                                         "#{BASE_URL[:ie_driver]}/IEDriverServer_Win32_2.43.0.zip" ],
         | 
| 13 | 
            +
                                win64:   [ "#{BASE_URL[:chrome_driver]}/chromedriver_win32.zip",
         | 
| 14 | 
            +
                                            "#{BASE_URL[:ie_driver]}/IEDriverServer_x64_2.43.0.zip" ],
         | 
| 15 | 
            +
                                linux32: [ "#{BASE_URL[:chrome_driver]}/chromedriver_linux32.zip" ],
         | 
| 16 | 
            +
                                linux64: [ "#{BASE_URL[:chrome_driver]}/chromedriver_linux64.zip" ] }
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
| @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            require_relative 'selenium-prep/downloader'
         | 
| 2 | 
            +
            require_relative 'selenium-prep/system/path'
         | 
| 3 | 
            +
            require_relative 'selenium-prep/system/folder'
         | 
| 4 | 
            +
            require_relative 'selenium-prep/system/extract'
         | 
| 5 | 
            +
            require_relative 'selenium-prep/overrides'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module SeleniumPrep
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              def self.download
         | 
| 10 | 
            +
                ConfigChecker.new
         | 
| 11 | 
            +
                System::Folder.create_directory
         | 
| 12 | 
            +
                System::Folder.prompt_user if System::Folder.downloads_exist?
         | 
| 13 | 
            +
                Downloader.download
         | 
| 14 | 
            +
                System::Extract.extract_zip_files
         | 
| 15 | 
            +
                System::Extract.delete_zip_files
         | 
| 16 | 
            +
                puts "\n"
         | 
| 17 | 
            +
                path_set?
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              def self.path_set?
         | 
| 21 | 
            +
                ConfigChecker.new
         | 
| 22 | 
            +
                result = System::Path.set?
         | 
| 23 | 
            +
                result ?
         | 
| 24 | 
            +
                  (puts "Selenium is ready to use!") :
         | 
| 25 | 
            +
                  (puts "Your PATH is not configured correctly. \n\nHere is what it's set to now:\n")
         | 
| 26 | 
            +
                puts System::Path.path
         | 
| 27 | 
            +
                puts "\n"
         | 
| 28 | 
            +
                System::Path.set
         | 
| 29 | 
            +
                result
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            end
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'selenium-prep/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = 'selenium-prep'
         | 
| 8 | 
            +
              spec.version       = SeleniumPrep::VERSION
         | 
| 9 | 
            +
              spec.authors       = ['Dave Haeffner']
         | 
| 10 | 
            +
              spec.email         = ['dhaeffner@gmail.com']
         | 
| 11 | 
            +
              spec.summary       = %q{selenium-prep helps set up your machine for local Selenium execution for multiple browsers. It downloads (in parallel) the latest browser drivers and standalone server to a specified location. It will then check your system PATH to see if the directory is in it. If not, it will provide you with information on how to configure it for your operating system.}
         | 
| 12 | 
            +
              spec.description   = %q{See README.txt for more.}
         | 
| 13 | 
            +
              spec.homepage      = 'https://github.com/tourdedave/selenium-prep'
         | 
| 14 | 
            +
              spec.license       = 'MIT'
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              spec.files         = `git ls-files -z`.split("\x0")
         | 
| 17 | 
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 18 | 
            +
              spec.require_paths = ['lib']
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              spec.add_dependency 'typhoeus', '~> 0.6.9'
         | 
| 21 | 
            +
              spec.add_dependency 'rubyzip', '~> 1.1.6'
         | 
| 22 | 
            +
              spec.add_development_dependency 'bundler', '~> 1.7'
         | 
| 23 | 
            +
              spec.add_development_dependency 'rake', '~> 10.0'
         | 
| 24 | 
            +
              spec.add_development_dependency 'rspec', '~> 3.1.0'
         | 
| 25 | 
            +
              spec.add_development_dependency 'guard-rspec', '~> 4.3.1'
         | 
| 26 | 
            +
            end
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            require_relative 'spec_helper'
         | 
| 2 | 
            +
            require_relative '../lib/selenium-prep'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe 'Config Checker -> ' do
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              before(:each) do
         | 
| 7 | 
            +
                ENV['SE_OS_TYPE'] = nil
         | 
| 8 | 
            +
                ENV['SE_DOWNLOAD_LOCATION'] = nil
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              it 'no OS type' do
         | 
| 12 | 
            +
                ENV['SE_DOWNLOAD_LOCATION'] = 'asdf'
         | 
| 13 | 
            +
                expect { SeleniumPrep.download }.to raise_error(
         | 
| 14 | 
            +
                  RuntimeError,
         | 
| 15 | 
            +
                  'You need to specify an operating system type with SE_OS_TYPE.')
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              it 'no Download Location' do
         | 
| 19 | 
            +
                ENV['SE_OS_TYPE'] = 'asdf'
         | 
| 20 | 
            +
                expect { SeleniumPrep.download }.to raise_error(
         | 
| 21 | 
            +
                  RuntimeError,
         | 
| 22 | 
            +
                  'You need to specify a download location with SE_DOWNLOAD_LOCATION.')
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            require_relative 'spec_helper'
         | 
| 2 | 
            +
            require_relative '../lib/selenium-prep/downloader'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe 'Downloader' do
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              before(:all) do
         | 
| 7 | 
            +
                ENV['SE_OS_TYPE'] = 'mac32'
         | 
| 8 | 
            +
                @loc = ENV['SE_DOWNLOAD_LOCATION'] = File.join(Dir.pwd, 'spec/tmp/downloader')
         | 
| 9 | 
            +
                FileUtils.rm_rf @loc
         | 
| 10 | 
            +
                FileUtils.mkdir_p(@loc)
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              after(:all) do
         | 
| 14 | 
            +
                FileUtils.rm_rf @loc
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              it 'downloads' do
         | 
| 18 | 
            +
                expect(Dir.glob("#{@loc}/*")).to be_empty
         | 
| 19 | 
            +
                SeleniumPrep::Downloader.download
         | 
| 20 | 
            +
                expect(Dir.glob("#{@loc}/*")).not_to be_empty
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            require_relative 'spec_helper'
         | 
| 2 | 
            +
            require_relative '../lib/selenium-prep/downloader'
         | 
| 3 | 
            +
            require_relative '../lib/selenium-prep/system/extract'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            describe 'Extract', :acceptance do
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              before(:all) do
         | 
| 8 | 
            +
                ENV['SE_OS_TYPE'] = 'mac32'
         | 
| 9 | 
            +
                @loc = ENV['SE_DOWNLOAD_LOCATION'] = File.join(Dir.pwd, 'spec/tmp/file')
         | 
| 10 | 
            +
                FileUtils.rm_rf @loc
         | 
| 11 | 
            +
                FileUtils.mkdir_p @loc
         | 
| 12 | 
            +
                SeleniumPrep::Downloader.download
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              after(:all) do
         | 
| 16 | 
            +
                FileUtils.rm_rf @loc
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              def files
         | 
| 20 | 
            +
                Dir.glob("#{@loc}/*")
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              it 'extracts' do
         | 
| 24 | 
            +
                file_count = files.count
         | 
| 25 | 
            +
                SeleniumPrep::System::Extract.extract_zip_files
         | 
| 26 | 
            +
                expect(files.count).to eql file_count + 1
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              it 'cleans up' do
         | 
| 30 | 
            +
                file_count = files.count
         | 
| 31 | 
            +
                zip_files = files.collect { |file| file if file.include?('.zip') }.compact!
         | 
| 32 | 
            +
                SeleniumPrep::System::Extract.delete_zip_files
         | 
| 33 | 
            +
                expect(files.count).to eql(file_count - zip_files.count)
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            end
         | 
    
        data/spec/folder_spec.rb
    ADDED
    
    | @@ -0,0 +1,71 @@ | |
| 1 | 
            +
            require_relative 'spec_helper'
         | 
| 2 | 
            +
            require_relative '../lib/selenium-prep/system/folder'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe 'Folder creation -> ' do
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              before(:all) do
         | 
| 7 | 
            +
                @loc = ENV['SE_DOWNLOAD_LOCATION'] = File.join(Dir.pwd, 'spec/tmp/folder')
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              context 'Sanity Checks' do
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                before(:each) do
         | 
| 13 | 
            +
                  FileUtils.mkdir_p(@loc)
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                after(:each) do
         | 
| 17 | 
            +
                  FileUtils.rm_rf @loc
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                it 'directory check' do
         | 
| 21 | 
            +
                  expect(SeleniumPrep::System::Folder.directory_exists?).to be true
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                it 'downloads check' do
         | 
| 25 | 
            +
                  expect(SeleniumPrep::System::Folder.downloads_exist?).to be false
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                it 'directory creation' do
         | 
| 29 | 
            +
                  FileUtils.rm_rf @loc
         | 
| 30 | 
            +
                  SeleniumPrep::System::Folder.create_directory
         | 
| 31 | 
            +
                  expect(SeleniumPrep::System::Folder.directory_exists?).to be true
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                it 'empty directory' do
         | 
| 35 | 
            +
                  SeleniumPrep::System::Folder.empty_directory
         | 
| 36 | 
            +
                  expect(SeleniumPrep::System::Folder.downloads_exist?).to be false
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
              context 'User prompt -> ' do
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                class InputWrapper
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  def initialize(string)
         | 
| 45 | 
            +
                    @string = string
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  def gets
         | 
| 49 | 
            +
                    @string
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  def self.input(string)
         | 
| 53 | 
            +
                    $stdin = new(string)
         | 
| 54 | 
            +
                    yield
         | 
| 55 | 
            +
                  ensure
         | 
| 56 | 
            +
                    $stdin = STDIN
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                it 'aborted' do
         | 
| 62 | 
            +
                  InputWrapper.input 'N' do
         | 
| 63 | 
            +
                    expect { SeleniumPrep::System::Folder.prompt_user }.to raise_error(
         | 
| 64 | 
            +
                             RuntimeError,
         | 
| 65 | 
            +
                             'Aborting download.')
         | 
| 66 | 
            +
                  end
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
              end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            end
         | 
| @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            require_relative 'spec_helper'
         | 
| 2 | 
            +
            require_relative '../lib/selenium-prep'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe 'Selenium Prep', :acceptance do
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              it 'downloads' do
         | 
| 7 | 
            +
                ENV['SE_DEBUG'] = 'off'
         | 
| 8 | 
            +
                ENV['SE_OS_TYPE'] = 'mac32'
         | 
| 9 | 
            +
                loc = ENV['SE_DOWNLOAD_LOCATION'] = File.join(Dir.pwd, 'spec/tmp/selenium-prep')
         | 
| 10 | 
            +
                FileUtils.rm_rf loc
         | 
| 11 | 
            +
                SeleniumPrep::System::Folder.create_directory
         | 
| 12 | 
            +
                SeleniumPrep.download
         | 
| 13 | 
            +
                expect(Dir.glob("#{loc}/*")).not_to be_empty
         | 
| 14 | 
            +
                FileUtils.rm_rf loc
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
    
        data/spec/url_spec.rb
    ADDED
    
    | @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            require_relative 'spec_helper'
         | 
| 2 | 
            +
            require_relative '../lib/selenium-prep/urls'
         | 
| 3 | 
            +
            require 'typhoeus'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            describe 'Selenium URLs are valid -> ', :acceptance do
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              def request(url)
         | 
| 8 | 
            +
                Typhoeus.head url
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              it 'Browser Drivers' do
         | 
| 12 | 
            +
                urls = []
         | 
| 13 | 
            +
                SeleniumPrep::URLs::DRIVERS.each { |os_type, url| urls << url }
         | 
| 14 | 
            +
                urls.flatten.each do |url|
         | 
| 15 | 
            +
                  response = request url
         | 
| 16 | 
            +
                  expect(response.code).to eql 200
         | 
| 17 | 
            +
                  expect(response.headers['Content-Type']).to include('zip')
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              it 'Standalone Server' do
         | 
| 22 | 
            +
                response = request SeleniumPrep::URLs::SERVER
         | 
| 23 | 
            +
                expect(response.code).to eql 200
         | 
| 24 | 
            +
                expect(response.headers['Content-Type']).to eql('application/java-archive')
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,161 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: selenium-prep
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Dave Haeffner
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2014-10-15 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: typhoeus
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: 0.6.9
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: 0.6.9
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rubyzip
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: 1.1.6
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: 1.1.6
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: bundler
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - "~>"
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '1.7'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - "~>"
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '1.7'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: rake
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - "~>"
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '10.0'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - "~>"
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '10.0'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: rspec
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - "~>"
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: 3.1.0
         | 
| 76 | 
            +
              type: :development
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - "~>"
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: 3.1.0
         | 
| 83 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            +
              name: guard-rspec
         | 
| 85 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - "~>"
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: 4.3.1
         | 
| 90 | 
            +
              type: :development
         | 
| 91 | 
            +
              prerelease: false
         | 
| 92 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                requirements:
         | 
| 94 | 
            +
                - - "~>"
         | 
| 95 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                    version: 4.3.1
         | 
| 97 | 
            +
            description: See README.txt for more.
         | 
| 98 | 
            +
            email:
         | 
| 99 | 
            +
            - dhaeffner@gmail.com
         | 
| 100 | 
            +
            executables: []
         | 
| 101 | 
            +
            extensions: []
         | 
| 102 | 
            +
            extra_rdoc_files: []
         | 
| 103 | 
            +
            files:
         | 
| 104 | 
            +
            - ".gitignore"
         | 
| 105 | 
            +
            - Gemfile
         | 
| 106 | 
            +
            - Guardfile
         | 
| 107 | 
            +
            - README.txt
         | 
| 108 | 
            +
            - Rakefile
         | 
| 109 | 
            +
            - lib/selenium-prep.rb
         | 
| 110 | 
            +
            - lib/selenium-prep/config-checker.rb
         | 
| 111 | 
            +
            - lib/selenium-prep/downloader.rb
         | 
| 112 | 
            +
            - lib/selenium-prep/overrides.rb
         | 
| 113 | 
            +
            - lib/selenium-prep/system/extract.rb
         | 
| 114 | 
            +
            - lib/selenium-prep/system/folder.rb
         | 
| 115 | 
            +
            - lib/selenium-prep/system/path.rb
         | 
| 116 | 
            +
            - lib/selenium-prep/urls.rb
         | 
| 117 | 
            +
            - lib/selenium-prep/version.rb
         | 
| 118 | 
            +
            - selenium-prep.gemspec
         | 
| 119 | 
            +
            - spec/config-checker_spec.rb
         | 
| 120 | 
            +
            - spec/downloader_spec.rb
         | 
| 121 | 
            +
            - spec/extract_spec.rb
         | 
| 122 | 
            +
            - spec/folder_spec.rb
         | 
| 123 | 
            +
            - spec/selenium-prep_spec.rb
         | 
| 124 | 
            +
            - spec/spec_helper.rb
         | 
| 125 | 
            +
            - spec/url_spec.rb
         | 
| 126 | 
            +
            homepage: https://github.com/tourdedave/selenium-prep
         | 
| 127 | 
            +
            licenses:
         | 
| 128 | 
            +
            - MIT
         | 
| 129 | 
            +
            metadata: {}
         | 
| 130 | 
            +
            post_install_message: 
         | 
| 131 | 
            +
            rdoc_options: []
         | 
| 132 | 
            +
            require_paths:
         | 
| 133 | 
            +
            - lib
         | 
| 134 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 135 | 
            +
              requirements:
         | 
| 136 | 
            +
              - - ">="
         | 
| 137 | 
            +
                - !ruby/object:Gem::Version
         | 
| 138 | 
            +
                  version: '0'
         | 
| 139 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 140 | 
            +
              requirements:
         | 
| 141 | 
            +
              - - ">="
         | 
| 142 | 
            +
                - !ruby/object:Gem::Version
         | 
| 143 | 
            +
                  version: '0'
         | 
| 144 | 
            +
            requirements: []
         | 
| 145 | 
            +
            rubyforge_project: 
         | 
| 146 | 
            +
            rubygems_version: 2.2.2
         | 
| 147 | 
            +
            signing_key: 
         | 
| 148 | 
            +
            specification_version: 4
         | 
| 149 | 
            +
            summary: selenium-prep helps set up your machine for local Selenium execution for
         | 
| 150 | 
            +
              multiple browsers. It downloads (in parallel) the latest browser drivers and standalone
         | 
| 151 | 
            +
              server to a specified location. It will then check your system PATH to see if the
         | 
| 152 | 
            +
              directory is in it. If not, it will provide you with information on how to configure
         | 
| 153 | 
            +
              it for your operating system.
         | 
| 154 | 
            +
            test_files:
         | 
| 155 | 
            +
            - spec/config-checker_spec.rb
         | 
| 156 | 
            +
            - spec/downloader_spec.rb
         | 
| 157 | 
            +
            - spec/extract_spec.rb
         | 
| 158 | 
            +
            - spec/folder_spec.rb
         | 
| 159 | 
            +
            - spec/selenium-prep_spec.rb
         | 
| 160 | 
            +
            - spec/spec_helper.rb
         | 
| 161 | 
            +
            - spec/url_spec.rb
         |