whoops_notifier 0.0.0 → 0.0.1
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.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
data/lib/whoops_notifier.rb
CHANGED
@@ -21,8 +21,12 @@ module WhoopsNotifier
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def self.config
|
25
|
+
@config ||= Configuration.new
|
26
|
+
end
|
27
|
+
|
28
|
+
|
24
29
|
self.strategies = {}
|
25
|
-
self.config = Configuration.new
|
26
30
|
end
|
27
31
|
|
28
32
|
Dir[File.join(File.dirname(__FILE__),"whoops_notifier/strategies/*.rb")].each do |strategy_file|
|
@@ -1,8 +1,7 @@
|
|
1
1
|
# Copyright (c) 2007, Tammer Saleh, Thoughtbot, Inc.
|
2
|
-
module WhoopsNotifier
|
2
|
+
module WhoopsNotifier
|
3
3
|
# Used to set up and modify settings for the notifier.
|
4
4
|
class Configuration
|
5
|
-
|
6
5
|
OPTIONS = [:host, :http_open_timeout, :http_read_timeout,
|
7
6
|
:port, :protocol, :proxy_host,
|
8
7
|
:proxy_pass, :proxy_port, :proxy_user, :secure].freeze
|
@@ -81,6 +80,42 @@ module WhoopsNotifier
|
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
83
|
+
def set(config)
|
84
|
+
case config
|
85
|
+
when Hash: set_with_hash(config)
|
86
|
+
when IO: set_with_io(config)
|
87
|
+
when String: set_with_string(config)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def set_with_hash(config)
|
92
|
+
OPTIONS.each do |option|
|
93
|
+
if config.has_key?(option)
|
94
|
+
self.send("#{option}=", config[option])
|
95
|
+
elsif config.has_key?(option.to_s)
|
96
|
+
self.send("#{option}=", config[option.to_s])
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# String should be either a filename or YAML
|
102
|
+
def set_with_string(config)
|
103
|
+
if File.exists?(config)
|
104
|
+
set_with_yaml(File.read(config))
|
105
|
+
else
|
106
|
+
set_with_yaml(config)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def set_with_io(config)
|
111
|
+
set_with_hash(YAML.load(config))
|
112
|
+
config.close
|
113
|
+
end
|
114
|
+
|
115
|
+
def set_with_yaml(config)
|
116
|
+
set_with_hash(YAML.load(config))
|
117
|
+
end
|
118
|
+
|
84
119
|
private
|
85
120
|
|
86
121
|
def default_port
|
@@ -90,7 +125,5 @@ module WhoopsNotifier
|
|
90
125
|
80
|
91
126
|
end
|
92
127
|
end
|
93
|
-
|
94
128
|
end
|
95
|
-
|
96
129
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
strategy = WhoopsNotifier::Strategy.new("default::basic")
|
2
2
|
|
3
3
|
strategy.add_report_modifier(:use_basic_hash) do |report, evidence|
|
4
|
-
report.event_type
|
5
|
-
report.service
|
6
|
-
report.environment
|
7
|
-
report.message
|
8
|
-
report.
|
9
|
-
report.event_time
|
10
|
-
report.details
|
4
|
+
report.event_type = evidence[:event_type]
|
5
|
+
report.service = evidence[:service]
|
6
|
+
report.environment = evidence[:environment]
|
7
|
+
report.message = evidence[:message]
|
8
|
+
report.event_group_identifier = evidence[:event_group_identifier]
|
9
|
+
report.event_time = evidence[:event_time] if evidence[:event_time]
|
10
|
+
report.details = evidence[:details]
|
11
11
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
describe "WhoopsNotifier::Configuration" do
|
2
|
+
describe "#set" do
|
3
|
+
after(:each) { WhoopsNotifier.config.host = nil }
|
4
|
+
let(:config_path) { File.join(File.dirname(__FILE__), "fixtures/whoops_notifier.yml") }
|
5
|
+
it "should set the config from a yaml filename" do
|
6
|
+
WhoopsNotifier.config.set(config_path)
|
7
|
+
WhoopsNotifier.config.host.should == "whoops.com"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should set the config from a file" do
|
11
|
+
WhoopsNotifier.config.set(File.open(config_path))
|
12
|
+
WhoopsNotifier.config.host.should == "whoops.com"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should set the config from a hash" do
|
16
|
+
WhoopsNotifier.config.set({
|
17
|
+
:host => "whoops.com",
|
18
|
+
})
|
19
|
+
WhoopsNotifier.config.host.should == "whoops.com"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should allow string keys" do
|
23
|
+
WhoopsNotifier.config.set({
|
24
|
+
"host" => "whoops.com",
|
25
|
+
})
|
26
|
+
WhoopsNotifier.config.host.should == "whoops.com"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
:host: whoops.com
|
data/whoops_notifier.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{whoops_notifier}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Daniel Higginbotham"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-06-03}
|
13
13
|
s.description = %q{Handles basic notification responsibilities and allows creation of report creation strategies}
|
14
14
|
s.email = %q{daniel@flyingmachinestudios.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -32,6 +32,8 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/whoops_notifier/sender.rb",
|
33
33
|
"lib/whoops_notifier/strategies/basic.rb",
|
34
34
|
"lib/whoops_notifier/strategy.rb",
|
35
|
+
"spec/configuration_spec.rb",
|
36
|
+
"spec/fixtures/whoops_notifier.yml",
|
35
37
|
"spec/investigator_spec.rb",
|
36
38
|
"spec/spec_helper.rb",
|
37
39
|
"spec/strategy_spec.rb",
|
@@ -44,6 +46,7 @@ Gem::Specification.new do |s|
|
|
44
46
|
s.rubygems_version = %q{1.3.7}
|
45
47
|
s.summary = %q{Handles basic notification responsibilities and allows creation of report creation strategies}
|
46
48
|
s.test_files = [
|
49
|
+
"spec/configuration_spec.rb",
|
47
50
|
"spec/investigator_spec.rb",
|
48
51
|
"spec/spec_helper.rb",
|
49
52
|
"spec/strategy_spec.rb",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whoops_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Higginbotham
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-06-03 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -133,6 +133,8 @@ files:
|
|
133
133
|
- lib/whoops_notifier/sender.rb
|
134
134
|
- lib/whoops_notifier/strategies/basic.rb
|
135
135
|
- lib/whoops_notifier/strategy.rb
|
136
|
+
- spec/configuration_spec.rb
|
137
|
+
- spec/fixtures/whoops_notifier.yml
|
136
138
|
- spec/investigator_spec.rb
|
137
139
|
- spec/spec_helper.rb
|
138
140
|
- spec/strategy_spec.rb
|
@@ -173,6 +175,7 @@ signing_key:
|
|
173
175
|
specification_version: 3
|
174
176
|
summary: Handles basic notification responsibilities and allows creation of report creation strategies
|
175
177
|
test_files:
|
178
|
+
- spec/configuration_spec.rb
|
176
179
|
- spec/investigator_spec.rb
|
177
180
|
- spec/spec_helper.rb
|
178
181
|
- spec/strategy_spec.rb
|