Top Level Namespace
Defined Under Namespace
Modules: Logging, Wraith
Classes: CaptureOptions, ConfigFileDoesNotExistError, CustomError, InvalidDomainsError, InvalidYamlError, MissingImageError, MissingRequiredPropertyError, PropertyOutOfContextError, SaveMetadata
Instance Method Summary
collapse
Instance Method Details
#absolute_path_of_dir(filepath) ⇒ Object
10
11
12
13
14
|
# File 'lib/wraith/helpers/utilities.rb', line 10
def absolute_path_of_dir(filepath)
path_parts = filepath.split('/')
path_to_dir = path_parts.first path_parts.size - 1
path_to_dir.join('/')
end
|
#convert_to_absolute(filepath) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/wraith/helpers/utilities.rb', line 16
def convert_to_absolute(filepath)
if !filepath
"false"
elsif filepath[0] == "/"
filepath
elsif filepath.match(/^[A-Za-z]:\/(.+)$/)
filepath
else
"#{Dir.pwd}/#{filepath}"
end
end
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/wraith/helpers/utilities.rb', line 31
def list_debug_information
wraith_version = Wraith::VERSION
command_run = ARGV.join ' '
ruby_version = run_command_safely("ruby -v") || "Ruby not installed"
phantomjs_version = run_command_safely("phantomjs --version") || "PhantomJS not installed"
chromedriver_version = run_command_safely("chromedriver --version") || "chromedriver not installed"
casperjs_version = run_command_safely("casperjs --version") || "CasperJS not installed"
imagemagick_version = run_command_safely("convert -version") || "ImageMagick not installed"
logger.debug "#################################################"
logger.debug " Command run: #{command_run}"
logger.debug " Wraith version: #{wraith_version}"
logger.debug " Ruby version: #{ruby_version}"
logger.debug " ImageMagick: #{imagemagick_version}"
logger.debug " PhantomJS version: #{phantomjs_version}"
logger.debug " chromedriver version: #{chromedriver_version}"
logger.debug " CasperJS version: #{casperjs_version}"
logger.debug "#################################################"
end
|
#run_command_safely(command) ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'lib/wraith/helpers/utilities.rb', line 52
def run_command_safely(command)
begin
output = `#{command}`
output.lines.first.chomp
rescue StandardError
return false
end
end
|
#within_acceptable_limits ⇒ Object
3
4
5
6
7
8
|
# File 'lib/wraith/helpers/utilities.rb', line 3
def within_acceptable_limits
yield
rescue CustomError => e
logger.error e.message
end
|