rudra 1.0.14 → 1.0.15

This diff has not been reviewed by any users.
Log in in order to be able to vote.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rudra.rb +18 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f065383cc3c1a776dccc5708a77f627383aaa63f4198b087adad977271f713d6
4
- data.tar.gz: 9fc4e3d993f3d3a1b4fb53d57b146df87fe8fa5e561308b726a3c8c46dd5ac1d
3
+ metadata.gz: 18f80bbed760fbf34d622b60e647507bab5ddfea167a6d144430dae84ed35a98
4
+ data.tar.gz: '04965c6ea61ea288861f22c6fabbb61240f384faf99b9a9402e51273d201caa4'
5
5
  SHA512:
6
- metadata.gz: 9f80dd1cc85e183b9ac7ac2be6831a2e1ac56be27ab884133fcbfc4b0f87e03a23d4d9443bd933cfef69292c881d968b2033d3af8cd5a72c909ba8474afcce03
7
- data.tar.gz: ad1f215b1ea9c9f6d16e387f95f1a5f9c087845c2db3239d0f64ea719e94241805578fe1a3589b69dafc0207fcc10b6589677259ecb87939752ab0fd0d5c9a52
6
+ metadata.gz: 55a6791c2d89ecb33b3833ac41ef6f1514b482ac13525070aa246166bc5d530c7dc23bf09d353630f4205ab5959dc8202a49cee271e96554e485e19a5ca24f6e
7
+ data.tar.gz: 1e9d5d7c2fd2cfa29aa3baa80145647e3088096a3af625f5e49d7baf931d2a72082d73abfeb7e12e44995a8d29607d08693e0533bbffdb5a34995e1182b7ee44
@@ -32,7 +32,8 @@ class Rudra
32
32
  ].freeze
33
33
 
34
34
  attr_reader :browser, :driver, :install_dir, :locale,
35
- :headless, :log_prefix, :timeout, :verbose
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, :en)
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 the given path
275
- # @param [String] png_path the path of PNG screenshot
276
- def save_screenshot(png_path)
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
- png_path.end_with?('.png') ? png_path : "#{png_path}.png"
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.14
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-01 00:00:00.000000000 Z
11
+ date: 2020-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard