nightwatch 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf08834a8450c61d19d81eae776ed3894d815292
4
- data.tar.gz: 746969a1c82a7564e5ca70216cf4349a64728404
3
+ metadata.gz: 9e111fc1eab036c74d4a5a7bc2c8613f961facdd
4
+ data.tar.gz: aa5224897152449ca14568ed53dada6ff8a7cf2b
5
5
  SHA512:
6
- metadata.gz: 2b43abaaf82b85772e5b1c548c7022a7a367252d81025817b5b87514fc243029e24af854f1564efd4244a526f7727c9db1e118e2abeaef879f8ced363be8cb32
7
- data.tar.gz: 6747d65e6c10b13d756fc186b3f0c34e5a3e1ed549ad00ca7340057658b1b25020490da7e1adb2ff971d9951f2207cabea98930668ba74fb6be44e82c0b85f22
6
+ metadata.gz: 024802867d65a72431dffccfd018fde970efdb1df94748519ea12562cf36ed174ed2b68900c3ee566be9a431532b9157f6bffc704199d601634f60141d40f54b
7
+ data.tar.gz: b90e7801a10e9f1355403ade812b74d93f312279492d48f8bff75cd243e88f7da639b6ba82e428d39fb27bad183f02f014bc40fe3b16239c2912bad0f5bcae1e
@@ -1,5 +1,6 @@
1
1
  require 'singleton'
2
2
  require 'nightwatch/mongo'
3
+ require 'nightwatch/filter'
3
4
 
4
5
  module Nightwatch
5
6
  def self.configure(&block)
@@ -11,8 +12,10 @@ module Nightwatch
11
12
 
12
13
  def initialize
13
14
  @logger = Mongo.new
15
+ @filters = [AcceptFilter.new]
14
16
  end
15
17
 
16
18
  attr_accessor :logger
19
+ attr_accessor :filters
17
20
  end
18
21
  end
@@ -0,0 +1,29 @@
1
+ module Rake
2
+ class Application
3
+ top_level_method = instance_method(:top_level)
4
+
5
+ define_method :top_level do |*args, &block|
6
+ begin
7
+ top_level_method.bind(self).call(*args, &block)
8
+ ensure
9
+ if $!
10
+ Nightwatch::ExceptionManager.instance.add_exception($!)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ module Nightwatch
18
+ class RakeFilter
19
+ def apply(exception)
20
+ if exception.is_a? SystemExit
21
+ nil
22
+ else
23
+ exception
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ Nightwatch::Configuration.instance.filters << Nightwatch::RakeFilter.new
@@ -0,0 +1,17 @@
1
+ class Thread
2
+ initialize_method = instance_method(:initialize)
3
+
4
+ define_method :initialize do |*args, &orig_block|
5
+ block = proc do |*block_args|
6
+ begin
7
+ orig_block.call(*block_args)
8
+ ensure
9
+ if $!
10
+ Nightwatch::ExceptionManager.instance.add_exception($!)
11
+ end
12
+ end
13
+ end
14
+
15
+ initialize_method.bind(self).call(*args, &block)
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ module Nightwatch
2
+ class AcceptFilter
3
+ def apply(exception)
4
+ exception
5
+ end
6
+ end
7
+ end
@@ -2,6 +2,8 @@ require 'mongo'
2
2
 
3
3
  module Nightwatch
4
4
  class Mongo
5
+ # TODO: Allow users to specify client (e.g. Nightwatch::Mongo.new(client: mongo_client))
6
+ # TODO: Raise error if one of :host/:port or :client is not specified
5
7
  def initialize(opts = {})
6
8
  @host = opts[:host] || '127.0.0.1'
7
9
  @port = opts[:port] || 27017
@@ -1,6 +1,8 @@
1
1
  require 'socket'
2
2
  require 'singleton'
3
+ require 'rbconfig'
3
4
  require 'nightwatch/configuration'
5
+ require 'nightwatch/ext/thread'
4
6
 
5
7
  module Nightwatch
6
8
  class ExceptionManager
@@ -19,7 +21,14 @@ module Nightwatch
19
21
  end
20
22
 
21
23
  def add_exception(exception)
22
- @exceptions[exception.object_id] = [exception, stack(exception), Time.now.to_i]
24
+ Configuration.instance.filters.each do |filter|
25
+ exception = filter.apply(exception)
26
+ break if !exception
27
+ end
28
+
29
+ if exception
30
+ @exceptions[exception.object_id] = [exception, stack(exception), Time.now.to_i]
31
+ end
23
32
  end
24
33
 
25
34
  def commit!
@@ -31,13 +40,14 @@ module Nightwatch
31
40
  klass = exception.class.name
32
41
 
33
42
  record = {
34
- pid: $$,
43
+ class: klass,
44
+ message: exception.to_s,
35
45
  script: @@script,
36
46
  argv: @@argv,
47
+ pid: $$,
37
48
  env: env,
49
+ config: RbConfig::CONFIG,
38
50
  host: host,
39
- class: klass,
40
- message: exception.to_s,
41
51
  stack: stack,
42
52
  timestamp: ticks
43
53
  }
@@ -74,24 +84,6 @@ module Nightwatch
74
84
  end
75
85
  end
76
86
 
77
- class Thread
78
- alias_method :orig_initialize, :initialize
79
-
80
- def initialize(*args, &orig_block)
81
- block = proc do
82
- begin
83
- orig_block.call
84
- ensure
85
- if $!
86
- Nightwatch::ExceptionManager.instance.add_exception($!)
87
- end
88
- end
89
- end
90
-
91
- orig_initialize(*args, &block)
92
- end
93
- end
94
-
95
87
  at_exit do
96
88
  if $!
97
89
  Nightwatch::ExceptionManager.instance.add_exception($!)
@@ -1,3 +1,3 @@
1
1
  module Nightwatch
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -81,7 +81,7 @@ html, body {
81
81
  .table th {
82
82
  font-weight: 500;
83
83
  }
84
- .environment.table td.value {
84
+ .environment.table td.value, .configuration.table td.value {
85
85
  word-break: break-all;
86
86
  }
87
87
  .table, .table tr th {
@@ -112,8 +112,8 @@ html, body {
112
112
  .tab-pane#summary .name {
113
113
  font-weight: 500;
114
114
  }
115
- .none {
116
- color: #aaa;
115
+ .empty {
116
+ color: #bbb;
117
117
  }
118
118
  .location {
119
119
  font-family: Consolas, Monaco, monospace;
@@ -7,6 +7,7 @@ module Nightwatch
7
7
  set :run, false
8
8
  set :server, 'thin'
9
9
 
10
+ # TODO: Allow server configuration via command-line or settings file.
10
11
  mongo = Mongo::MongoClient.new
11
12
  exceptions = mongo['nightwatch']['exceptions']
12
13
 
@@ -57,6 +57,7 @@
57
57
  <li class="active"><a href="#summary" data-toggle="tab">Summary</a></li>
58
58
  <li><a href="#stack" data-toggle="tab">Stack</a></li>
59
59
  <li><a href="#environment" data-toggle="tab">Environment</a></li>
60
+ <li><a href="#configuration" data-toggle="tab">Configuration</a></li>
60
61
  </ul>
61
62
  <div class="tab-content">
62
63
  <div class="tab-pane active" id="summary">
@@ -78,7 +79,7 @@
78
79
  </div>
79
80
  <div class="row">
80
81
  <div class="col-md-2"><p class="name">Arguments</p></div>
81
- <div class="col-md-10" ng-if="activeException.argv.length == 0"><p class="none">(none)</p></div>
82
+ <div class="col-md-10" ng-if="activeException.argv.length == 0"><p class="empty">(none)</p></div>
82
83
  <div class="col-md-10" ng-if="activeException.argv.length > 0"><p>{{activeException.argv.join(' ')}}</p></div>
83
84
  </div>
84
85
  <div class="row">
@@ -120,6 +121,21 @@
120
121
  </tr>
121
122
  </table>
122
123
  </div>
124
+ <div class="tab-pane" id="configuration">
125
+ <table class="table configuration">
126
+ <tr>
127
+ <th>Name</th>
128
+ <th>Value</th>
129
+ </tr>
130
+ <tr ng-repeat="(name, value) in activeException.config">
131
+ <td>{{name}}</td>
132
+ <td class="value">
133
+ <span ng-unless="value | isEmpty">{{value}}</span>
134
+ <span ng-if="value | isEmpty" class="empty">(empty)</span>
135
+ </td>
136
+ </tr>
137
+ </table>
138
+ </div>
123
139
  </div>
124
140
  </div>
125
141
  </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nightwatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schmich
@@ -102,6 +102,9 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - lib/nightwatch/configuration.rb
105
+ - lib/nightwatch/ext/rake.rb
106
+ - lib/nightwatch/ext/thread.rb
107
+ - lib/nightwatch/filter.rb
105
108
  - lib/nightwatch/mongo.rb
106
109
  - lib/nightwatch/monitor.rb
107
110
  - lib/nightwatch/version.rb