whoops 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -11,6 +11,7 @@ group :development do
11
11
  gem 'ruby-debug19', :platforms => :ruby_19
12
12
  gem 'ruby-debug', :platforms => :mri_18
13
13
  gem 'pry'
14
+ gem 'faker'
14
15
  end
15
16
  end
16
17
 
@@ -0,0 +1,34 @@
1
+ class EventsController < ApplicationController
2
+ layout 'whoops'
3
+
4
+ def index
5
+ @event_group = WhoopsFinderProxy.find_event_group(params[:event_group_id])
6
+ @event_group = find_event_group(params[:event_group_id])
7
+
8
+ events_base = @event_group.events
9
+ unless params[:query].blank?
10
+ conditions = Whoops::MongoidSearchParser.new(params[:query]).conditions
11
+ events_base = events_base.where(conditions)
12
+ end
13
+
14
+ @events = events_base.desc(:event_time).page(params[:page]).per(20)
15
+ end
16
+
17
+ def show
18
+ @event = Whoops::Event.find(params[:id])
19
+ respond_to do |format|
20
+ format.js { render :partial => 'details', :object => @event, :as => :event}
21
+ end
22
+ end
23
+
24
+ # TODO break this out into a more metal-y controller
25
+ def create
26
+ Whoops::Event.record(params[:event])
27
+ render :status => 200, :nothing => true
28
+ end
29
+ end
30
+
31
+
32
+ delegate fimnd_evbemt_groupo, ... to: authentiuvao--tor
33
+ def fihd_evenmt_group(id)
34
+ currd-
@@ -0,0 +1,55 @@
1
+ # Receives new event params and processes them
2
+ class Whoops::NewEvent
3
+ def initialize(params)
4
+ @params = params.with_indifferent_access
5
+ end
6
+
7
+ # both records and sends notifications
8
+ def record!
9
+ find_or_build_event_group
10
+ update_event_group_attributes
11
+ send_notifications_for_event_group
12
+
13
+ @event_group.archived = false
14
+ @event_group.save
15
+ @event_group.events.create(event_params)
16
+ @event_group
17
+ end
18
+
19
+ private
20
+
21
+ def find_or_build_event_group
22
+ @event_group = Whoops::EventGroup.first(:conditions => event_group_identifying_fields) || Whoops::EventGroup.new(event_group_params)
23
+ end
24
+
25
+ def update_event_group_attributes
26
+ if @event_group.valid?
27
+ @event_group.attributes = event_group_params
28
+ @event_group.last_recorded_at = Time.now
29
+ @event_group.event_count += 1
30
+ end
31
+ end
32
+
33
+ def should_send_notifications?
34
+ @event_group.valid? && (@event_group.archived || @event_group.new_record) && Rails.application.config.whoops_sender
35
+ end
36
+
37
+ def send_notifications_for_event_group
38
+ return unless should_send_notifications?
39
+ matcher = Whoops::NotificationSubscription::Matcher.new(@event_group)
40
+ Whoops::NotificationMailer.event_notification(@event_group, matcher.matching_emails).deliver unless matcher.matching_emails.empty?
41
+ end
42
+
43
+ # TODO does it make sense to have a separate params object?
44
+ def event_group_params
45
+ @params.slice(*Whoops::EventGroup.field_names)
46
+ end
47
+
48
+ def event_group_identifying_fields
49
+ @params.slice(*Whoops::EventGroup.identifying_fields)
50
+ end
51
+
52
+ def event_params
53
+ @params.slice(*Whoops::Event.field_names)
54
+ end
55
+ end
@@ -13,7 +13,7 @@ class Whoops::Event
13
13
 
14
14
  validates_presence_of :message
15
15
 
16
- before_save :set_keywords, :sanitize_details
16
+ before_save :set_keywords, :sanitize_details, :set_event_time
17
17
 
18
18
  def self.search(query)
19
19
  conditions = Whoops::MongoidSearchParser.new(query).conditions
@@ -77,4 +77,8 @@ class Whoops::Event
77
77
  end.flatten!
78
78
  end
79
79
  end
80
+
81
+ def set_event_time
82
+ self.event_time = Time.now
83
+ end
80
84
  end
metadata CHANGED
@@ -1,174 +1,182 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: whoops
3
- version: !ruby/object:Gem::Version
4
- hash: 11
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 5
9
- - 0
10
- version: 0.5.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Daniel Higginbotham
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-12-03 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-12-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rails
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 5
29
- segments:
30
- - 3
31
- version: "3"
20
+ - !ruby/object:Gem::Version
21
+ version: '3'
32
22
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: sass
36
23
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: sass
32
+ requirement: !ruby/object:Gem::Requirement
38
33
  none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
46
38
  type: :runtime
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: haml
50
39
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: haml
48
+ requirement: !ruby/object:Gem::Requirement
52
49
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 3
57
- segments:
58
- - 0
59
- version: "0"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
60
54
  type: :runtime
61
- version_requirements: *id003
62
- - !ruby/object:Gem::Dependency
63
- name: mongo
64
55
  prerelease: false
65
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
66
57
  none: false
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- hash: 3
71
- segments:
72
- - 0
73
- version: "0"
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: mongo
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
74
70
  type: :runtime
75
- version_requirements: *id004
76
- - !ruby/object:Gem::Dependency
77
- name: mongoid
78
71
  prerelease: false
79
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: mongoid
80
+ requirement: !ruby/object:Gem::Requirement
80
81
  none: false
81
- requirements:
82
+ requirements:
82
83
  - - ~>
83
- - !ruby/object:Gem::Version
84
- hash: 11
85
- segments:
86
- - 2
87
- - 4
88
- version: "2.4"
84
+ - !ruby/object:Gem::Version
85
+ version: '2.4'
89
86
  type: :runtime
90
- version_requirements: *id005
91
- - !ruby/object:Gem::Dependency
92
- name: kaminari
93
87
  prerelease: false
94
- requirement: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
95
89
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
101
- - 0
102
- version: "0"
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '2.4'
94
+ - !ruby/object:Gem::Dependency
95
+ name: kaminari
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
103
102
  type: :runtime
104
- version_requirements: *id006
105
- - !ruby/object:Gem::Dependency
106
- name: rspec-rails
107
103
  prerelease: false
108
- requirement: &id007 !ruby/object:Gem::Requirement
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec-rails
112
+ requirement: !ruby/object:Gem::Requirement
109
113
  none: false
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- hash: 3
114
- segments:
115
- - 0
116
- version: "0"
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
117
118
  type: :development
118
- version_requirements: *id007
119
- - !ruby/object:Gem::Dependency
120
- name: fabrication
121
119
  prerelease: false
122
- requirement: &id008 !ruby/object:Gem::Requirement
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: fabrication
128
+ requirement: !ruby/object:Gem::Requirement
123
129
  none: false
124
- requirements:
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- hash: 3
128
- segments:
129
- - 0
130
- version: "0"
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
131
134
  type: :development
132
- version_requirements: *id008
133
- - !ruby/object:Gem::Dependency
134
- name: faker
135
135
  prerelease: false
136
- requirement: &id009 !ruby/object:Gem::Requirement
136
+ version_requirements: !ruby/object:Gem::Requirement
137
137
  none: false
138
- requirements:
139
- - - ">="
140
- - !ruby/object:Gem::Version
141
- hash: 3
142
- segments:
143
- - 0
144
- version: "0"
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: faker
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
145
150
  type: :development
146
- version_requirements: *id009
147
- - !ruby/object:Gem::Dependency
148
- name: capybara
149
151
  prerelease: false
150
- requirement: &id010 !ruby/object:Gem::Requirement
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: capybara
160
+ requirement: !ruby/object:Gem::Requirement
151
161
  none: false
152
- requirements:
153
- - - ">="
154
- - !ruby/object:Gem::Version
155
- hash: 15
156
- segments:
157
- - 0
158
- - 4
159
- - 0
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
160
165
  version: 0.4.0
161
166
  type: :development
162
- version_requirements: *id010
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: 0.4.0
163
174
  description: A Rails engine which receives logs and provides an interface for them
164
175
  email:
165
176
  executables: []
166
-
167
177
  extensions: []
168
-
169
178
  extra_rdoc_files: []
170
-
171
- files:
179
+ files:
172
180
  - app/assets/javascripts/jquery-1.5.2.min.js
173
181
  - app/assets/javascripts/whoops.js
174
182
  - app/assets/stylesheets/autocomplete.scss
@@ -184,6 +192,7 @@ files:
184
192
  - app/assets/stylesheets/variables.scss
185
193
  - app/assets/stylesheets/whoops-application.css
186
194
  - app/assets/stylesheets/whoops.css.scss
195
+ - app/controllers/#events_controller.rb#
187
196
  - app/controllers/event_groups_controller.rb
188
197
  - app/controllers/events_controller.rb
189
198
  - app/controllers/notification_subscriptions_controller.rb
@@ -194,6 +203,7 @@ files:
194
203
  - app/helpers/notifications_helper.rb
195
204
  - app/lib/field_names.rb
196
205
  - app/mailers/whoops/notification_mailer.rb
206
+ - app/models/whoops/#new_event.rb#
197
207
  - app/models/whoops/authorized_service_lookup.rb
198
208
  - app/models/whoops/event.rb
199
209
  - app/models/whoops/event_group.rb
@@ -223,37 +233,26 @@ files:
223
233
  - README.asciidoc
224
234
  homepage: http://www.whoopsapp.com
225
235
  licenses: []
226
-
227
236
  post_install_message:
228
237
  rdoc_options: []
229
-
230
- require_paths:
238
+ require_paths:
231
239
  - lib
232
- required_ruby_version: !ruby/object:Gem::Requirement
240
+ required_ruby_version: !ruby/object:Gem::Requirement
233
241
  none: false
234
- requirements:
235
- - - ">="
236
- - !ruby/object:Gem::Version
237
- hash: 3
238
- segments:
239
- - 0
240
- version: "0"
241
- required_rubygems_version: !ruby/object:Gem::Requirement
242
+ requirements:
243
+ - - ! '>='
244
+ - !ruby/object:Gem::Version
245
+ version: '0'
246
+ required_rubygems_version: !ruby/object:Gem::Requirement
242
247
  none: false
243
- requirements:
244
- - - ">="
245
- - !ruby/object:Gem::Version
246
- hash: 3
247
- segments:
248
- - 0
249
- version: "0"
248
+ requirements:
249
+ - - ! '>='
250
+ - !ruby/object:Gem::Version
251
+ version: '0'
250
252
  requirements: []
251
-
252
253
  rubyforge_project:
253
254
  rubygems_version: 1.8.24
254
255
  signing_key:
255
256
  specification_version: 3
256
257
  summary: A Rails engine which receives logs and provides an interface for them
257
258
  test_files: []
258
-
259
- has_rdoc: