-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Rake tasks for update, remove, and version. #117
Merged
titusfortner
merged 1 commit into
titusfortner:master
from
kapoorlakshya:add_rake_tasks
May 21, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'webdrivers' | ||
|
||
path = File.expand_path(__dir__) | ||
Dir.glob("#{path}/tasks/*.rake").each { |f| import f } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'webdrivers' | ||
require 'rails' | ||
|
||
module Webdrivers | ||
class Railtie < Rails::Railtie | ||
railtie_name :webdrivers | ||
|
||
rake_tasks do | ||
path = File.expand_path(__dir__) | ||
Dir.glob("#{path}/tasks/*.rake").each { |f| load f } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
namespace :webdrivers do | ||
require 'webdrivers/chromedriver' | ||
|
||
namespace :chromedriver do | ||
Webdrivers.logger.level = :info | ||
|
||
desc 'Print current chromedriver version' | ||
task :version do | ||
gem_ver = Webdrivers::Chromedriver.current_version | ||
if gem_ver | ||
Webdrivers.logger.info "chromedriver #{gem_ver.version}" | ||
else | ||
Webdrivers.logger.warn 'No existing chromedriver found.' | ||
end | ||
end | ||
|
||
desc 'Remove and download updated chromedriver if necessary' | ||
task :update, [:version] do |_, args| | ||
args.with_defaults(version: 0) | ||
Webdrivers.cache_time = ENV.fetch('WD_CACHE_TIME', 86_400) | ||
Webdrivers.install_dir = ENV.fetch('WD_INSTALL_DIR', nil) | ||
Webdrivers::Chromedriver.required_version = args.version | ||
Webdrivers::Chromedriver.update | ||
Webdrivers.logger.info "Updated to chromedriver #{Webdrivers::Chromedriver.current_version}" | ||
end | ||
|
||
desc 'Force remove chromedriver' | ||
task :remove do | ||
unless File.exist? Webdrivers::Chromedriver.driver_path | ||
Webdrivers.logger.info 'No existing chromedriver to remove.' | ||
next # Return early | ||
end | ||
|
||
cur_version = Webdrivers::Chromedriver.current_version | ||
Webdrivers::Chromedriver.remove | ||
|
||
if File.exist? Webdrivers::Chromedriver.driver_path # Failed for some reason | ||
Webdrivers.logger.error 'Failed to remove chromedriver. Please try removing manually.' | ||
else | ||
Webdrivers.logger.info "Removed chromedriver #{cur_version}." | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
namespace :webdrivers do | ||
require 'webdrivers/geckodriver' | ||
|
||
namespace :geckodriver do | ||
Webdrivers.logger.level = :info | ||
|
||
desc 'Print current geckodriver version' | ||
task :version do | ||
gem_ver = Webdrivers::Geckodriver.current_version | ||
if gem_ver | ||
Webdrivers.logger.info "geckodriver #{gem_ver.version}" | ||
else | ||
Webdrivers.logger.warn 'No existing geckodriver found.' | ||
end | ||
end | ||
|
||
desc 'Remove and download updated geckodriver if necessary' | ||
task :update, [:version] do |_, args| | ||
args.with_defaults(version: 0) | ||
Webdrivers.cache_time = ENV.fetch('WD_CACHE_TIME', 86_400) | ||
Webdrivers.install_dir = ENV.fetch('WD_INSTALL_DIR', nil) | ||
Webdrivers::Geckodriver.required_version = args.version | ||
Webdrivers::Geckodriver.update | ||
Webdrivers.logger.info "Updated to geckodriver #{Webdrivers::Geckodriver.current_version}" | ||
end | ||
|
||
desc 'Force remove geckodriver' | ||
task :remove do | ||
unless File.exist? Webdrivers::Geckodriver.driver_path | ||
Webdrivers.logger.info 'No existing geckodriver to remove.' | ||
next # Return early | ||
end | ||
|
||
cur_version = Webdrivers::Geckodriver.current_version | ||
Webdrivers::Geckodriver.remove | ||
|
||
if File.exist? Webdrivers::Geckodriver.driver_path # Failed for some reason | ||
Webdrivers.logger.error 'Failed to remove geckodriver. Please try removing manually.' | ||
else | ||
Webdrivers.logger.info "Removed geckodriver #{cur_version}." | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
namespace :webdrivers do | ||
require 'webdrivers/iedriver' | ||
|
||
namespace :iedriver do | ||
Webdrivers.logger.level = :info | ||
|
||
desc 'Print current IEDriverServer version' | ||
task :version do | ||
gem_ver = Webdrivers::IEdriver.current_version | ||
if gem_ver | ||
Webdrivers.logger.info "IEDriverServer #{gem_ver.version}" | ||
else | ||
Webdrivers.logger.warn 'No existing IEDriverServer found.' | ||
end | ||
end | ||
|
||
desc 'Remove and download updated IEDriverServer if necessary' | ||
task :update, [:version] do |_, args| | ||
args.with_defaults(version: 0) | ||
Webdrivers.cache_time = ENV.fetch('WD_CACHE_TIME', 86_400) | ||
Webdrivers.install_dir = ENV.fetch('WD_INSTALL_DIR', nil) | ||
Webdrivers::IEdriver.required_version = args.version | ||
Webdrivers::IEdriver.update | ||
Webdrivers.logger.info "Updated to IEDriverServer #{Webdrivers::IEdriver.current_version}" | ||
end | ||
|
||
desc 'Force remove IEDriverServer' | ||
task :remove do | ||
unless File.exist? Webdrivers::IEdriver.driver_path | ||
Webdrivers.logger.info 'No existing IEDriverServer to remove.' | ||
next # Return early | ||
end | ||
|
||
cur_version = Webdrivers::IEdriver.current_version | ||
Webdrivers::IEdriver.remove | ||
|
||
if File.exist? Webdrivers::IEdriver.driver_path # Failed for some reason | ||
Webdrivers.logger.error 'Failed to remove IEDriverServer. Please try removing manually.' | ||
else | ||
Webdrivers.logger.info "Removed IEDriverServer #{cur_version}." | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this different from just using the
attr_accessor
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The accessor (reader method) was only returning the user define path or
nil
. I attempted to move all the logic inSystem.install_dir
and haveWebdrivers.install_dir
reference it, but then that created a circular reference as the first check in System is forWebdrivers.install_dir
, which itself was referencingSystem.install_dir
to get the default path.