happyfunjuice 0.0.1.beta.1 → 0.0.1.beta.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,8 @@ class Happyfunjuice::HappyfunjuiceController < ApplicationController
|
|
2
2
|
|
3
3
|
before_filter :verify_key
|
4
4
|
|
5
|
+
before_filter :select_handled_exceptions
|
6
|
+
|
5
7
|
def activities
|
6
8
|
|
7
9
|
begin
|
@@ -16,7 +18,7 @@ class Happyfunjuice::HappyfunjuiceController < ApplicationController
|
|
16
18
|
)
|
17
19
|
}.merge({:status=>'200'})
|
18
20
|
|
19
|
-
rescue
|
21
|
+
rescue *@handled_exceptions => e
|
20
22
|
render :json=>{:status=>'500', :error=>e.message}
|
21
23
|
end
|
22
24
|
|
@@ -32,7 +34,7 @@ class Happyfunjuice::HappyfunjuiceController < ApplicationController
|
|
32
34
|
)
|
33
35
|
}.merge({:status=>'200'})
|
34
36
|
|
35
|
-
rescue
|
37
|
+
rescue *@handled_exceptions => e
|
36
38
|
render :json=>{:status=>'500', :error=>e.message}
|
37
39
|
end
|
38
40
|
|
@@ -40,6 +42,14 @@ class Happyfunjuice::HappyfunjuiceController < ApplicationController
|
|
40
42
|
|
41
43
|
|
42
44
|
private
|
45
|
+
|
46
|
+
def select_handled_exceptions
|
47
|
+
if Happyfunjuice.exceptions_are_fatal
|
48
|
+
@handled_exceptions = []
|
49
|
+
else
|
50
|
+
@handled_exceptions = [StandardError]
|
51
|
+
end
|
52
|
+
end
|
43
53
|
|
44
54
|
def verify_key
|
45
55
|
unless (Happyfunjuice.api_key == params[:api_key] )
|
@@ -3,6 +3,11 @@ Happyfunjuice.setup do |config|
|
|
3
3
|
# Insert the API key from the HappyFunJuice settings page here:
|
4
4
|
config.api_key = "<%=@api_key%>"
|
5
5
|
|
6
|
+
# By default, exceptions encountered while querying activities are passed
|
7
|
+
# back as an error message. Debugging is much easier though if exceptions
|
8
|
+
# cause an application error.
|
9
|
+
# config.exceptions_are_fatal = false
|
10
|
+
|
6
11
|
# Sample usage:
|
7
12
|
#
|
8
13
|
# config.activity :new_user, User do |u|
|
data/lib/happyfunjuice/config.rb
CHANGED
@@ -29,8 +29,8 @@ module Happyfunjuice
|
|
29
29
|
Happyfunjuice.environment = env.to_s
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
33
|
-
Happyfunjuice.
|
32
|
+
def exceptions_are_fatal= bool
|
33
|
+
Happyfunjuice.exceptions_are_fatal = !!(bool)
|
34
34
|
end
|
35
35
|
|
36
36
|
def activity( key, scope, opts={}, &block )
|
data/lib/happyfunjuice.rb
CHANGED
@@ -10,7 +10,7 @@ module Happyfunjuice
|
|
10
10
|
|
11
11
|
# Variables for Juice
|
12
12
|
@@apikey = nil
|
13
|
-
@@
|
13
|
+
@@exceptions_are_fatal = false
|
14
14
|
@@environment = 'production'
|
15
15
|
|
16
16
|
# Variables for landing page:
|
@@ -19,7 +19,7 @@ module Happyfunjuice
|
|
19
19
|
@@mailer_api_key = 'api-key'
|
20
20
|
@@newsletter_list = 'newsletters'
|
21
21
|
|
22
|
-
mattr_accessor :api_key, :
|
22
|
+
mattr_accessor :api_key, :exceptions_are_fatal
|
23
23
|
mattr_accessor :mailer, :mailer_api_user, :mailer_api_key, :newsletter_list
|
24
24
|
mattr_accessor :environment
|
25
25
|
|