gless 1.5.2 → 1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/examples/test_github/lib/config/development.yml.example +3 -0
- data/lib/gless/logger.rb +57 -49
- data/lib/gless/wrap_watir.rb +1 -1
- data/lib/gless.rb +13 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6094105504a01a7ceda507eb2a2de510f20fe84a
|
4
|
+
data.tar.gz: 8abe86a6fd223db704e5d88b3b047fd920531115
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb428c193c09e266decac2e913f443cac3477f0f70d8a3813d49cf8059d0cba16ba6dc1ca2b0620988444aef438725f183e96a46d41296e68ba03636cd4f7315
|
7
|
+
data.tar.gz: 3ce61d0b7ce91054352a0861d349e0ba32236f27758bc6f0589882107ed9b23e640db3383b6be19f9bbd63540e8a0a73a13a705d3061527322101f315d89fcc6
|
data/README.md
CHANGED
@@ -192,12 +192,12 @@ produce some pretty verbose logging of what it's doing.
|
|
192
192
|
|
193
193
|
A less crazy version is ":verbose: true".
|
194
194
|
|
195
|
-
|
196
|
-
viewed in a browser. The
|
197
|
-
~/public_html/watir_replay/test/ ;
|
198
|
-
Gless::Logger determines that location. Most
|
199
|
-
performs will cause the replay log to be updated
|
200
|
-
source as Gless/Watir/Selenium/WebDriver sees it.
|
195
|
+
If replay is true in the config file, it will also create a replay
|
196
|
+
log directory which is intended to be viewed in a browser. The
|
197
|
+
directory location defaults to ~/public_html/watir_replay/test/ ;
|
198
|
+
the initialization of Gless::Logger determines that location. Most
|
199
|
+
actions that Gless performs will cause the replay log to be updated
|
200
|
+
a copy of the HTML source as Gless/Watir/Selenium/WebDriver sees it.
|
201
201
|
|
202
202
|
If you have ":screenshots: true" (along with debugging), screenshots
|
203
203
|
will also be taken showing the visual state of the browser at the
|
@@ -15,6 +15,9 @@
|
|
15
15
|
# :max_duration: 5400 # Sauce specific
|
16
16
|
:verbose: false # Whether to engage in more verbose/info level logging
|
17
17
|
:debug: false # Whether to engage in debug logging
|
18
|
+
:replay: false # Whether to create a replay log, which shows html for each step of operations
|
19
|
+
:replay_path: "%{home}/public_html/watir_replay/%{tag}"
|
20
|
+
# The path to put the replay logs; should probably be web accessible to be of much use; %{home} is replaced as you would expect
|
18
21
|
:screenshots: false # Whether, if debugging is on, to create screenshots as part of the replay log
|
19
22
|
:thumbnails: false # Whether, if screenshots are on, to create small-ish "thumbnail" pictures on the replay page; requires the imagemagick system package and the mini_magick gem
|
20
23
|
:cache: false # Whether, by default, to cache elements, significantly improving performance. For individual elements, caching can be disabled by adding ":cache => false" to the element specifier.
|
data/lib/gless/logger.rb
CHANGED
@@ -40,30 +40,34 @@ module Gless
|
|
40
40
|
|
41
41
|
@ssnum = 0 # For snapshot pictures
|
42
42
|
|
43
|
-
@replay_path=sprintf(replay_path, { :home => ENV['HOME'], :tag => tag, :replay => replay })
|
44
|
-
FileUtils.rm_rf(@replay_path)
|
45
|
-
FileUtils.mkdir(@replay_path)
|
46
|
-
|
47
|
-
replay_log_file = File.open("#{@replay_path}/index.html", "w")
|
48
|
-
@replay_log = ::Logger.new replay_log_file
|
49
|
-
|
50
|
-
#@replay_log.formatter = proc do |severity, datetime, progname, msg|
|
51
|
-
# # I, [2012-08-14T15:30:10.736784 #14647] INFO -- : <p>Launching remote browser</p>
|
52
|
-
# "<p>#{severity[0]}, [#{datetime} #{progname}]: #{severity} -- : #{msg}</p>\n"
|
53
|
-
#end
|
54
|
-
|
55
43
|
original_formatter = ::Logger::Formatter.new
|
56
44
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
45
|
+
if replay
|
46
|
+
@replay_path=sprintf(replay_path, { :home => ENV['HOME'], :tag => tag, :replay => replay })
|
47
|
+
FileUtils.rm_rf(@replay_path)
|
48
|
+
FileUtils.mkdir(@replay_path)
|
49
|
+
|
50
|
+
replay_log_file = File.open("#{@replay_path}/index.html", "w")
|
51
|
+
@replay_log = ::Logger.new replay_log_file
|
52
|
+
|
53
|
+
#@replay_log.formatter = proc do |severity, datetime, progname, msg|
|
54
|
+
# # I, [2012-08-14T15:30:10.736784 #14647] INFO -- : <p>Launching remote browser</p>
|
55
|
+
# "<p>#{severity[0]}, [#{datetime} #{progname}]: #{severity} -- : #{msg}</p>\n"
|
56
|
+
#end
|
57
|
+
|
58
|
+
# Add in the tag and html-ify
|
59
|
+
@replay_log.formatter = proc { |severity, datetime, progname, msg|
|
60
|
+
# Can't flush after from here, so flush prior stuff
|
61
|
+
replay_log_file.flush
|
62
|
+
npn = "#{progname} #{tag} ".sub(/^\s*/,'').sub(/\s*$/,'')
|
63
|
+
stuff=original_formatter.call(severity, datetime, "#{progname} #{tag} ", msg)
|
64
|
+
#"<p>#{ERB::Util.html_escape(stuff.chomp)}</p>\n"
|
65
|
+
"<p>#{stuff.chomp}</p>\n"
|
66
|
+
}
|
67
|
+
@replay_log.level = ::Logger::WARN
|
68
|
+
else
|
69
|
+
@replay_log = nil
|
70
|
+
end
|
67
71
|
|
68
72
|
@normal_log = ::Logger.new(STDOUT)
|
69
73
|
# Add in the tag
|
@@ -77,7 +81,9 @@ module Gless
|
|
77
81
|
# Passes on all the normal Logger methods. By default, logs to
|
78
82
|
# both the normal log and the replay log.
|
79
83
|
def method_missing(m, *args, &block)
|
80
|
-
@replay_log
|
84
|
+
if @replay_log
|
85
|
+
@replay_log.send(m, *args, &block)
|
86
|
+
end
|
81
87
|
@normal_log.send(m, *args, &block)
|
82
88
|
end
|
83
89
|
|
@@ -87,36 +93,38 @@ module Gless
|
|
87
93
|
# @param [Watir::Browser] browser
|
88
94
|
# @param [Gless::Session] session
|
89
95
|
def add_to_replay_log( browser, session )
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
96
|
+
if @replay_log
|
97
|
+
@ssnum = @ssnum + 1
|
98
|
+
|
99
|
+
if session.get_config :global, :screenshots
|
100
|
+
begin
|
101
|
+
browser.driver.save_screenshot "#{@replay_path}/screenshot_#{@ssnum}.png"
|
102
|
+
|
103
|
+
if session.get_config :global, :thumbnails
|
104
|
+
require 'mini_magick'
|
105
|
+
|
106
|
+
image = MiniMagick::Image.open("#{@replay_path}/screenshot_#{@ssnum}.png")
|
107
|
+
image.resize "400"
|
108
|
+
image.write "#{@replay_path}/screenshot_#{@ssnum}_thumb.png"
|
109
|
+
FileUtils.chmod 0755, "#{@replay_path}/screenshot_#{@ssnum}_thumb.png"
|
110
|
+
|
111
|
+
@replay_log.debug "Screenshot: <a href='screenshot_#{@ssnum}.png'><img src='screenshot_#{@ssnum}_thumb.png' /></a>"
|
112
|
+
else
|
113
|
+
@replay_log.debug "Screenshot: <a href='screenshot_#{@ssnum}.png'>Screenshot</a>"
|
114
|
+
end
|
115
|
+
rescue Exception => e
|
116
|
+
@normal_log.warn "Screenshot failed with exception #{e}"
|
107
117
|
end
|
108
|
-
rescue Exception => e
|
109
|
-
@normal_log.warn "Screenshot failed with exception #{e}"
|
110
118
|
end
|
111
|
-
end
|
112
119
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
120
|
+
html=browser.html
|
121
|
+
htmlFile = File.new("#{@replay_path}/html_capture_#{@ssnum}.txt", "w")
|
122
|
+
htmlFile.write(html)
|
123
|
+
htmlFile.close
|
117
124
|
|
118
|
-
|
119
|
-
|
125
|
+
@replay_log.debug "<a href='html_capture_#{@ssnum}.txt'>HTML Source</a>"
|
126
|
+
@replay_log.debug "Force flush"
|
127
|
+
end
|
120
128
|
end
|
121
129
|
end
|
122
130
|
end
|
data/lib/gless/wrap_watir.rb
CHANGED
@@ -380,7 +380,7 @@ module Gless
|
|
380
380
|
if trimmed_selectors.inspect =~ /password/i
|
381
381
|
@session.log.debug "WrapWatir: Doing something with passwords, redacted."
|
382
382
|
else
|
383
|
-
if @session.get_config :global, :
|
383
|
+
if @session.get_config :global, :replay
|
384
384
|
@session.log.add_to_replay_log( @browser, @session )
|
385
385
|
end
|
386
386
|
|
data/lib/gless.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# project.
|
7
7
|
module Gless
|
8
8
|
# The current version number.
|
9
|
-
VERSION = '1.
|
9
|
+
VERSION = '1.6'
|
10
10
|
|
11
11
|
# Sets up the config, logger and browser instances, the ordering
|
12
12
|
# of which is slightly tricky. If a block is given, the config, after being
|
@@ -26,12 +26,16 @@ module Gless
|
|
26
26
|
#
|
27
27
|
# @return [Gless::Logger, Gless::EnvConfig, Gless::Browser] logger, config, browser (in that order)
|
28
28
|
def self.setup( tag, hash = nil )
|
29
|
-
logger = Gless::Logger.new( tag )
|
30
|
-
|
31
29
|
# Create the config reading/storage object
|
32
30
|
config = Gless::EnvConfig.new( hash )
|
33
31
|
config = yield config if block_given?
|
34
32
|
|
33
|
+
logger = Gless::Logger.new(
|
34
|
+
tag,
|
35
|
+
config.get_default( false, :global, :replay ),
|
36
|
+
config.get_default( '%{home}/public_html/watir_replay/%{tag}', :global, :replay_path )
|
37
|
+
)
|
38
|
+
|
35
39
|
# Get the whole backtrace, please.
|
36
40
|
if config.get :global, :debug
|
37
41
|
::Cucumber.use_full_backtrace = true
|
@@ -46,14 +50,18 @@ module Gless
|
|
46
50
|
# Turn on verbose (info) level logging.
|
47
51
|
if config.get :global, :verbose
|
48
52
|
logger.normal_log.level = ::Logger::INFO
|
49
|
-
logger.replay_log
|
53
|
+
if logger.replay_log
|
54
|
+
logger.replay_log.level = ::Logger::INFO
|
55
|
+
end
|
50
56
|
logger.debug "Verbose/info level logging enabled."
|
51
57
|
end
|
52
58
|
|
53
59
|
# Turn on debug level logging.
|
54
60
|
if config.get :global, :debug
|
55
61
|
logger.normal_log.level = ::Logger::DEBUG
|
56
|
-
logger.replay_log
|
62
|
+
if logger.replay_log
|
63
|
+
logger.replay_log.level = ::Logger::DEBUG
|
64
|
+
end
|
57
65
|
logger.debug "Debug level logging enabled."
|
58
66
|
end
|
59
67
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Lee Powell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|