selenium-prep 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9ad9e9fc87056fa9da1413bf86498adc5339d75
4
- data.tar.gz: 327175318ebcb6c7ec24564811cab3f2ed800b4a
3
+ metadata.gz: fa3a1f4b9de0019d2a5ccf4665f381334314e1a5
4
+ data.tar.gz: ccd0dc7e1a75cab075fe973e524278df0c1a0cd6
5
5
  SHA512:
6
- metadata.gz: 6b3b38a7cdd6882eb1c3384953f66c1775765332bd3e2b154c83cbb821ea57aec61e7c58f5a5fed8e2caa22c51fb3ff9bb5fb89c37730c5df21448b83f3e41b4
7
- data.tar.gz: e490be978bca3cc4c432ee724bf066e82a10843025b91e9f8c4a2488b55c05d4d5e65b05c121872c2c47f43fda44128b54bddd140bff6588580c0bb671a75a13
6
+ metadata.gz: 6dbf642956127fe2c9ffe88015fe926a3b2812c12cb7c73311c7cb629c7e3ca268c59c873c59aebfbc11275c46a70d263973914866f3831ea07bd9a8e246bbfa
7
+ data.tar.gz: 7b9010f011b40f090e25bb16938a81e372cf044c8f27b474f0be3be37cd7d68ff0ac876007df95aa468d4bd96c6576666e27eef9ec52c4430485c9d643877993
data/README.txt CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == DESCRIPTION:
4
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 download directory is in it. If not, it will provide you with information on how to configure it for your operating system.
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 download directory is in it. If not, it will add it for you.
6
6
 
7
7
  == INSTALLATION:
8
8
 
@@ -12,11 +12,17 @@ gem install selenium-prep
12
12
 
13
13
  === Environment Variables
14
14
 
15
- SE_OS_TYPE (e.g., 'linux32', 'linux64', 'mac32', 'win32', 'win64')
15
+ SE_OS_TYPE (e.g., 'linux32', 'linux64', 'mac32', 'win32', 'win64' -- automatically detected)
16
+ SE_OS_TYPE_BIT (e.g., '32', '64' -- defaults to '32')
16
17
  SE_DOWNLOAD_LOCATION (e.g., full path)
17
- SE_DEBUG (e.g., 'off' to disable all standard output -- on by default)
18
18
 
19
- If these values are not set properly, a RuntimeError will be returned along with a helpful message.
19
+ NOTE: SE_DOWNLOAD_LOCATION is the only variable you need to set. If is not set properly, a RuntimeError will be returned along with a helpful message.
20
+
21
+ === Prep
22
+
23
+ SeleniumPrep.prep
24
+
25
+ NOTE: This will download the files for your OS, attempt to set the path on your system, and check that the path is set correctly. If not, it will provide some debugging output.
20
26
 
21
27
  === Downloading
22
28
 
@@ -26,11 +32,11 @@ NOTE: The downloader will check to see if the download directory is empty. If no
26
32
 
27
33
  === Check System Path
28
34
 
29
- Find out if your path is set correctly and if not provide instructions on how to proceed.
35
+ Find out if your path is set correctly and if not provide some debugging output.
30
36
 
31
37
  SeleniumPrep.path_set?
32
38
 
33
- NOTE: Will return a boolean result in addition to helpful messaging. This will automatically run after downloading completes.
39
+ NOTE: Will return a boolean result in addition to debugging output.
34
40
 
35
41
  == LICENSE:
36
42
 
data/lib/selenium-prep.rb CHANGED
@@ -2,31 +2,39 @@ require_relative 'selenium-prep/downloader'
2
2
  require_relative 'selenium-prep/system/path'
3
3
  require_relative 'selenium-prep/system/folder'
4
4
  require_relative 'selenium-prep/system/extract'
5
- require_relative 'selenium-prep/overrides'
5
+ require_relative 'selenium-prep/system/os'
6
6
 
7
7
  module SeleniumPrep
8
8
 
9
+ def self.prep
10
+ System::OS.set_type
11
+ download
12
+ System::Path.set
13
+ path_set?
14
+ end
15
+
9
16
  def self.download
17
+ System::OS.set_type
10
18
  ConfigChecker.new
11
19
  System::Folder.create_directory
12
20
  System::Folder.prompt_user if System::Folder.downloads_exist?
13
21
  Downloader.download
14
22
  System::Extract.extract_zip_files
15
23
  System::Extract.delete_zip_files
16
- puts "\n"
17
- path_set?
18
24
  end
19
25
 
20
26
  def self.path_set?
27
+ System::OS.set_type
21
28
  ConfigChecker.new
22
29
  result = System::Path.set?
23
30
  result ?
24
31
  (puts "Selenium is ready to use!") :
25
32
  (puts "Your PATH is not configured correctly. \n\nHere is what it's set to now:\n")
26
33
  puts System::Path.path
27
- puts "\n"
28
- System::Path.set
29
34
  result
30
35
  end
31
36
 
37
+ private
38
+
39
+
32
40
  end
@@ -0,0 +1,32 @@
1
+ module SeleniumPrep
2
+ module System
3
+ module OS
4
+
5
+ extend self
6
+
7
+ def windows?
8
+ (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
9
+ end
10
+
11
+ def mac?
12
+ (/darwin/ =~ RUBY_PLATFORM) != nil
13
+ end
14
+
15
+ def unix?
16
+ !windows?
17
+ end
18
+
19
+ def linux?
20
+ unix? and not mac?
21
+ end
22
+
23
+ def set_type
24
+ ENV['SE_OS_TYPE'] = 'win' if System::OS.windows?
25
+ ENV['SE_OS_TYPE'] = 'mac' if System::OS.mac?
26
+ ENV['SE_OS_TYPE'] = 'linux' if System::OS.linux?
27
+ ENV['SE_OS_TYPE'] = ENV['SE_OS_TYPE'] + (ENV['SE_OS_TYPE_BIT'] ||= '32')
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -6,35 +6,42 @@ module SeleniumPrep
6
6
 
7
7
  def self.set
8
8
  ConfigChecker.new
9
- puts "You need to add #{ENV['SE_DOWNLOAD_LOCATION']} to your path.\n\n"
10
9
  case ENV['SE_OS_TYPE']
11
10
  when 'win32', 'win64'
12
- puts "For instructions on how to do that read:\n http://www.computerhope.com/issues/ch000549.htm"
11
+ system("set path=%path%;#{ENV['SE_DOWNLOAD_LOCATION']}")
12
+ system('reg.exe ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /d %path% /f')
13
+ ENV['PATH'] = "#{ENV['PATH']};#{ENV['SE_DOWNLOAD_LOCATION']}"
13
14
  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
+ unless set?
16
+ unless bash_updated?
17
+ system("echo 'export PATH=$PATH:#{ENV['SE_DOWNLOAD_LOCATION']}' | sudo tee -a ~/.bash_profile")
18
+ end
19
+ system('source ~/.bash_profile')
20
+ ENV['PATH'] = "#{ENV['PATH']}:/#{ENV['SE_DOWNLOAD_LOCATION']}"
21
+ end
15
22
  end
16
23
  end
17
24
 
18
25
  def self.set?
19
- ConfigChecker.new
20
26
  case ENV['SE_OS_TYPE']
21
27
  when 'win32', 'win64'
22
- `echo %PATH%'`.include? ENV['SE_DOWNLOAD_LOCATION']
28
+ path.include?(ENV['SE_DOWNLOAD_LOCATION'])
23
29
  when 'mac32', 'linux32', 'linux64'
24
- `echo $PATH`.include? ENV['SE_DOWNLOAD_LOCATION']
30
+ path.include?(ENV['SE_DOWNLOAD_LOCATION']) && bash_updated?
25
31
  end
26
32
  end
27
33
 
28
34
  def self.path
29
35
  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
+ ENV['PATH']
36
37
  end
37
38
 
39
+ private
40
+
41
+ def self.bash_updated?
42
+ !`cat ~/.bash_profile | grep #{ENV['SE_DOWNLOAD_LOCATION']}`.empty?
43
+ end
44
+
38
45
  end
39
46
  end
40
47
  end
@@ -1,3 +1,3 @@
1
1
  module SeleniumPrep
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -1,22 +1,9 @@
1
- require_relative 'spec_helper'
2
1
  require_relative '../lib/selenium-prep'
3
2
 
4
3
  describe 'Config Checker -> ' do
5
4
 
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
5
  it 'no Download Location' do
19
- ENV['SE_OS_TYPE'] = 'asdf'
6
+ ENV['SE_DOWNLOAD_LOCATION'] = nil
20
7
  expect { SeleniumPrep.download }.to raise_error(
21
8
  RuntimeError,
22
9
  'You need to specify a download location with SE_DOWNLOAD_LOCATION.')
@@ -1,10 +1,10 @@
1
- require_relative 'spec_helper'
1
+ require_relative '../lib/selenium-prep/system/os'
2
2
  require_relative '../lib/selenium-prep/downloader'
3
3
 
4
4
  describe 'Downloader' do
5
5
 
6
6
  before(:all) do
7
- ENV['SE_OS_TYPE'] = 'mac32'
7
+ SeleniumPrep::System::OS.set_type
8
8
  @loc = ENV['SE_DOWNLOAD_LOCATION'] = File.join(Dir.pwd, 'spec/tmp/downloader')
9
9
  FileUtils.rm_rf @loc
10
10
  FileUtils.mkdir_p(@loc)
data/spec/extract_spec.rb CHANGED
@@ -1,11 +1,11 @@
1
- require_relative 'spec_helper'
1
+ require_relative '../lib/selenium-prep/system/os'
2
2
  require_relative '../lib/selenium-prep/downloader'
3
3
  require_relative '../lib/selenium-prep/system/extract'
4
4
 
5
5
  describe 'Extract', :acceptance do
6
6
 
7
7
  before(:all) do
8
- ENV['SE_OS_TYPE'] = 'mac32'
8
+ SeleniumPrep::System::OS.set_type
9
9
  @loc = ENV['SE_DOWNLOAD_LOCATION'] = File.join(Dir.pwd, 'spec/tmp/file')
10
10
  FileUtils.rm_rf @loc
11
11
  FileUtils.mkdir_p @loc
@@ -23,7 +23,7 @@ describe 'Extract', :acceptance do
23
23
  it 'extracts' do
24
24
  file_count = files.count
25
25
  SeleniumPrep::System::Extract.extract_zip_files
26
- expect(files.count).to eql file_count + 1
26
+ expect(files.count).to be > file_count
27
27
  end
28
28
 
29
29
  it 'cleans up' do
data/spec/folder_spec.rb CHANGED
@@ -1,4 +1,3 @@
1
- require_relative 'spec_helper'
2
1
  require_relative '../lib/selenium-prep/system/folder'
3
2
 
4
3
  describe 'Folder creation -> ' do
data/spec/path_spec.rb ADDED
@@ -0,0 +1,13 @@
1
+ require_relative '../lib/selenium-prep/system/os'
2
+ require_relative '../lib/selenium-prep/system/path'
3
+
4
+ describe 'Path' do
5
+
6
+ it 'sets' do
7
+ SeleniumPrep::System::OS.set_type
8
+ ENV['SE_DOWNLOAD_LOCATION'] = File.join(Dir.pwd, 'spec/tmp/selenium-prep')
9
+ SeleniumPrep::System::Path.set
10
+ expect(SeleniumPrep::System::Path.set?).to be true
11
+ end
12
+
13
+ end
@@ -1,11 +1,10 @@
1
- require_relative 'spec_helper'
1
+ require_relative '../lib/selenium-prep/system/os'
2
2
  require_relative '../lib/selenium-prep'
3
3
 
4
4
  describe 'Selenium Prep', :acceptance do
5
5
 
6
6
  it 'downloads' do
7
- ENV['SE_DEBUG'] = 'off'
8
- ENV['SE_OS_TYPE'] = 'mac32'
7
+ SeleniumPrep::System::OS.set_type
9
8
  loc = ENV['SE_DOWNLOAD_LOCATION'] = File.join(Dir.pwd, 'spec/tmp/selenium-prep')
10
9
  FileUtils.rm_rf loc
11
10
  SeleniumPrep::System::Folder.create_directory
data/spec/url_spec.rb CHANGED
@@ -1,4 +1,3 @@
1
- require_relative 'spec_helper'
2
1
  require_relative '../lib/selenium-prep/urls'
3
2
  require 'typhoeus'
4
3
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium-prep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Haeffner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-27 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -113,9 +113,9 @@ files:
113
113
  - lib/selenium-prep.rb
114
114
  - lib/selenium-prep/config-checker.rb
115
115
  - lib/selenium-prep/downloader.rb
116
- - lib/selenium-prep/overrides.rb
117
116
  - lib/selenium-prep/system/extract.rb
118
117
  - lib/selenium-prep/system/folder.rb
118
+ - lib/selenium-prep/system/os.rb
119
119
  - lib/selenium-prep/system/path.rb
120
120
  - lib/selenium-prep/urls.rb
121
121
  - lib/selenium-prep/version.rb
@@ -124,8 +124,8 @@ files:
124
124
  - spec/downloader_spec.rb
125
125
  - spec/extract_spec.rb
126
126
  - spec/folder_spec.rb
127
+ - spec/path_spec.rb
127
128
  - spec/selenium-prep_spec.rb
128
- - spec/spec_helper.rb
129
129
  - spec/url_spec.rb
130
130
  homepage: https://github.com/tourdedave/selenium-prep
131
131
  licenses:
@@ -156,6 +156,6 @@ test_files:
156
156
  - spec/downloader_spec.rb
157
157
  - spec/extract_spec.rb
158
158
  - spec/folder_spec.rb
159
+ - spec/path_spec.rb
159
160
  - spec/selenium-prep_spec.rb
160
- - spec/spec_helper.rb
161
161
  - spec/url_spec.rb
@@ -1,19 +0,0 @@
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
data/spec/spec_helper.rb DELETED
@@ -1,2 +0,0 @@
1
- require_relative '../lib/selenium-prep/overrides'
2
- ENV['SE_DEBUG'] = 'off'