rudra 1.0.17 → 1.1.0

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 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6b9b8353fbb965300bb0e6c9a96ef162717fc1b7e3afaa46192d414a0828584
4
- data.tar.gz: 5ca513a1614e4c9fbae46dc5caf4636d5b579fd8e1fc74c6f745cc61d7d9ddcf
3
+ metadata.gz: b59cfa6497e4560d80369dc076df45638ec043abe069b5f6665e5749aefdef87
4
+ data.tar.gz: 51e97a957330ffce97411d9f3ad40e01a4be439cc677306d5507ae0136577beb
5
5
  SHA512:
6
- metadata.gz: e775d57a29612f265578c1ecfd665e093f837460b32012763ab88983d47a1b7ae674903e1e5169b30609e65cce59d621800ab20500013d506b4dd8120fa76f55
7
- data.tar.gz: 98b306bd3f397ae54f53224fa88d57aacb5d6b6699a92706440626ddbe8dee4d75e3d7ff751fd71e2d64d0bd88a3e95852d1680720b7731fed6eccb22a7213bc
6
+ metadata.gz: f7984dccb05ea056c716dd533c5d4662e83ea8711c62a2fc3f02f95d0d7a795914d16c2ceacd2ef2cf1eff26374ae9c8ed795a14797186f696356f3c02c687bf
7
+ data.tar.gz: 4bfb07ee8abe3ce212c85ca19ab052fb134b47c42e225e7160ea6463795e425e22a594998d2e89365709a3d2b1495a2c5cbbb0894b64bd1bfc073a190519ef8f
@@ -11,9 +11,10 @@ require 'webdrivers'
11
11
  # @attr_reader [Boolean] headless Headless mode for Google Chrome
12
12
  # @attr_reader [String] window_size Chrome window size when headless
13
13
  # @attr_reader [String] screen_dir The screenshot directory of save_screenshot
14
- # @attr_reader [String] log_prefix Prefix for logging executed methods
14
+ # @attr_reader [String] log_prefix Prefix for logging descriptions and methods
15
15
  # @attr_reader [Integer] timeout The driver timeout
16
- # @attr_reader [Boolean] verbose Verbose mode
16
+ # @attr_reader [Boolean] verbose Turn on/off Verbose mode
17
+ # @attr_reader [Boolean] silent Turn off Turn on/off descriptions
17
18
  class Rudra
18
19
  # Supported Browsers
19
20
  BROWSERS = %i[chrome firefox ie safari].freeze
@@ -28,12 +29,12 @@ class Rudra
28
29
  ATTRIBUTES = %i[
29
30
  browser driver install_dir locale
30
31
  headless window_size screen_dir
31
- log_prefix timeout verbose
32
+ log_prefix timeout verbose silent
32
33
  ].freeze
33
34
 
34
35
  attr_reader :browser, :driver, :install_dir, :locale,
35
36
  :headless, :window_size, :screen_dir,
36
- :log_prefix, :timeout, :verbose
37
+ :log_prefix, :timeout, :verbose, :silent
37
38
 
38
39
  # Initialize an instance of Rudra
39
40
  # @param [Hash] options the options to initialize Rudra
@@ -45,9 +46,10 @@ class Rudra
45
46
  # @option options [Boolean] :headless (false) headless mode
46
47
  # @option options [String] :window_size ('1280,720') window size when headless
47
48
  # @option options [String] :screen_dir ('./screens/') the location of screenshots
48
- # @option options [String] :log_prefix (' - ') prefix for logging executed methods
49
+ # @option options [String] :log_prefix (' - ') prefix for logging descriptions and methods
49
50
  # @option options [Integer] :timeout (30) implicit_wait timeout
50
- # @option options [Boolean] :verbose (true) verbose mode
51
+ # @option options [Boolean] :verbose (false) Turn on/off verbose mode
52
+ # @option options [Boolean] :silent (false) Turn on/off descriptions
51
53
  def initialize(options = {})
52
54
  self.browser = options.fetch(:browser, :chrome)
53
55
  self.install_dir = options.fetch(:install_dir, './webdrivers/')
@@ -56,7 +58,8 @@ class Rudra
56
58
  self.window_size = options.fetch(:window_size, '1280,720')
57
59
  self.screen_dir = options.fetch(:screen_dir, './screens/')
58
60
  self.log_prefix = options.fetch(:log_prefix, ' - ')
59
- self.verbose = options.fetch(:verbose, true)
61
+ self.verbose = options.fetch(:verbose, false)
62
+ self.silent = options.fetch(:silent, false)
60
63
  self.main_label = caller_locations(2, 1).first.label
61
64
 
62
65
  initialize_driver
@@ -265,6 +268,12 @@ class Rudra
265
268
  driver.page_source
266
269
  end
267
270
 
271
+ # Print description in the console
272
+ # @param [String] description description to show
273
+ def puts(description)
274
+ $stdout.puts "#{log_prefix}#{description.chomp}" unless silent
275
+ end
276
+
268
277
  # Refresh the current pagef
269
278
  def refresh
270
279
  driver.navigate.refresh
@@ -1069,7 +1078,7 @@ class Rudra
1069
1078
  end
1070
1079
 
1071
1080
  (instance_methods - superclass.instance_methods).map do |method_name|
1072
- next if private_method_defined?(method_name) || ATTRIBUTES.include?(method_name)
1081
+ next if private_method_defined?(method_name) || ATTRIBUTES.include?(method_name) || method_name == :puts
1073
1082
 
1074
1083
  original_method = instance_method(method_name)
1075
1084
 
@@ -1082,7 +1091,7 @@ class Rudra
1082
1091
  private
1083
1092
 
1084
1093
  attr_accessor :main_label
1085
- attr_writer :window_size
1094
+ attr_writer :silent, :window_size
1086
1095
 
1087
1096
  def browser=(brw)
1088
1097
  unless BROWSERS.include?(brw)
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.17
4
+ version: 1.1.0
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-04 00:00:00.000000000 Z
11
+ date: 2020-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard