rudra 1.0.14 → 1.0.15
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 +4 -4
- data/lib/rudra.rb +18 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18f80bbed760fbf34d622b60e647507bab5ddfea167a6d144430dae84ed35a98
|
4
|
+
data.tar.gz: '04965c6ea61ea288861f22c6fabbb61240f384faf99b9a9402e51273d201caa4'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55a6791c2d89ecb33b3833ac41ef6f1514b482ac13525070aa246166bc5d530c7dc23bf09d353630f4205ab5959dc8202a49cee271e96554e485e19a5ca24f6e
|
7
|
+
data.tar.gz: 1e9d5d7c2fd2cfa29aa3baa80145647e3088096a3af625f5e49d7baf931d2a72082d73abfeb7e12e44995a8d29607d08693e0533bbffdb5a34995e1182b7ee44
|
data/lib/rudra.rb
CHANGED
@@ -32,7 +32,8 @@ class Rudra
|
|
32
32
|
].freeze
|
33
33
|
|
34
34
|
attr_reader :browser, :driver, :install_dir, :locale,
|
35
|
-
:headless, :
|
35
|
+
:headless, :screen_dir, :log_prefix,
|
36
|
+
:timeout, :verbose
|
36
37
|
|
37
38
|
# Initialize an instance of Rudra
|
38
39
|
# @param [Hash] options the options to initialize Rudra
|
@@ -42,14 +43,16 @@ class Rudra
|
|
42
43
|
# directory of WebDrivers
|
43
44
|
# @option options [Symbol] :locale (:en) the browser locale
|
44
45
|
# @option options [Boolean] :headless (false) headless mode
|
46
|
+
# @option options [String] :screen_dir ('.//') the location of screenshots
|
45
47
|
# @option options [String] :log_prefix (' - ') log prefix
|
46
48
|
# @option options [Integer] :timeout (30) implicit_wait timeout
|
47
49
|
# @option options [Boolean] :verbose (true) verbose mode
|
48
50
|
def initialize(options = {})
|
49
51
|
self.browser = options.fetch(:browser, :chrome)
|
50
52
|
self.install_dir = options.fetch(:install_dir, './webdrivers/')
|
51
|
-
self.locale = options.fetch(:locale, :
|
53
|
+
self.locale = options.fetch(:locale, :enscreens)
|
52
54
|
self.headless = options.fetch(:headless, false)
|
55
|
+
self.screen_dir = options.fetch(:screen_dir, './screens/')
|
53
56
|
self.log_prefix = options.fetch(:log_prefix, ' - ')
|
54
57
|
self.verbose = options.fetch(:verbose, true)
|
55
58
|
self.main_label = caller_locations(2, 1).first.label
|
@@ -271,11 +274,15 @@ class Rudra
|
|
271
274
|
driver.manage.window.resize_to(width, height)
|
272
275
|
end
|
273
276
|
|
274
|
-
# Save a PNG screenshot to
|
275
|
-
# @param [String]
|
276
|
-
def save_screenshot(
|
277
|
+
# Save a PNG screenshot to file
|
278
|
+
# @param [String] filename the filename of PNG screenshot
|
279
|
+
def save_screenshot(filename)
|
280
|
+
mkdir(@screen_dir) unless Dir.exist?(@screen_dir)
|
277
281
|
driver.save_screenshot(
|
278
|
-
|
282
|
+
File.join(
|
283
|
+
@screen_dir,
|
284
|
+
filename.end_with?('.png') ? filename : "#{filename}.png"
|
285
|
+
)
|
279
286
|
)
|
280
287
|
end
|
281
288
|
|
@@ -1098,6 +1105,10 @@ class Rudra
|
|
1098
1105
|
@headless = true?(mode)
|
1099
1106
|
end
|
1100
1107
|
|
1108
|
+
def screen_dir=(path)
|
1109
|
+
@screen_dir = File.join(path, @locale.to_s)
|
1110
|
+
end
|
1111
|
+
|
1101
1112
|
def log_prefix=(prefix)
|
1102
1113
|
@log_prefix = prefix.chomp
|
1103
1114
|
end
|
@@ -1179,7 +1190,7 @@ class Rudra
|
|
1179
1190
|
end
|
1180
1191
|
|
1181
1192
|
def log(method_name, *args)
|
1182
|
-
return unless @verbose && caller_locations(2, 1).first.label == main_label
|
1193
|
+
return unless @verbose && caller_locations(2, 1).first.label == @main_label
|
1183
1194
|
|
1184
1195
|
arguments = args.map(&:to_s).join(', ')
|
1185
1196
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rudra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Chen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|