kiss 1.7.1 → 1.7.2
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 +1 -1
- data/data/scaffold.tgz +0 -0
- data/lib/kiss.rb +10 -2
- data/lib/kiss/ext/core.rb +11 -0
- data/lib/kiss/mailer.rb +33 -1
- data/lib/kiss/request.rb +7 -7
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.7.
|
1
|
+
1.7.2
|
data/data/scaffold.tgz
CHANGED
Binary file
|
data/lib/kiss.rb
CHANGED
@@ -72,7 +72,7 @@ class Kiss
|
|
72
72
|
:evolution_dir, :asset_host, :asset_uri, :asset_dir, :public_dir, :environment,
|
73
73
|
:rack_file, :default_action, :exception_log_file, :session_class, :cookie_name,
|
74
74
|
:authenticate_all, :authenticate_exclude, :exception_handlers, :project_dir,
|
75
|
-
:config, :mailer_config, :mailer_override
|
75
|
+
:config, :mailer_config, :mailer_override, :exception_mailer_config
|
76
76
|
|
77
77
|
_attr_accessor :session_setup
|
78
78
|
|
@@ -131,9 +131,10 @@ class Kiss
|
|
131
131
|
@_gem_dirs = ['gems']
|
132
132
|
@_require = []
|
133
133
|
@_authenticate_exclude = ['/login', '/logout']
|
134
|
-
@_exception_handlers = {}
|
135
134
|
@_mailer_config = {}
|
136
135
|
@_mailer_override = {}
|
136
|
+
@_exception_handlers = {}
|
137
|
+
@_exception_mailer_config = {}
|
137
138
|
|
138
139
|
# store for cached files and directories
|
139
140
|
@_file_cache = {}
|
@@ -288,6 +289,13 @@ class Kiss
|
|
288
289
|
@_mailer_override.merge!(mailer_override)
|
289
290
|
end
|
290
291
|
|
292
|
+
if email_errors = new_config.delete(:email_errors)
|
293
|
+
@_exception_mailer_config.merge!(email_errors)
|
294
|
+
end
|
295
|
+
if exception_mailer = new_config.delete(:exception_mailer)
|
296
|
+
@_exception_mailer_config.merge!(exception_mailer)
|
297
|
+
end
|
298
|
+
|
291
299
|
@_config.merge!( new_config )
|
292
300
|
end
|
293
301
|
end
|
data/lib/kiss/ext/core.rb
CHANGED
@@ -594,6 +594,12 @@ class String
|
|
594
594
|
original_sequel_underscore.gsub(/\W+/, '_').sub(/_\Z/, '')
|
595
595
|
end
|
596
596
|
|
597
|
+
def capitalize
|
598
|
+
result = self.downcase
|
599
|
+
result[0,1] = result[0,1].upcase
|
600
|
+
result
|
601
|
+
end
|
602
|
+
|
597
603
|
# adapt titlecase method to downcase short prepositions in middle
|
598
604
|
alias_method :original_sequel_titlecase, :titlecase
|
599
605
|
def titlecase
|
@@ -601,6 +607,11 @@ class String
|
|
601
607
|
end
|
602
608
|
alias_method :titleize, :titlecase
|
603
609
|
|
610
|
+
def headercase
|
611
|
+
original_sequel_underscore.capitalize.gsub('_', '-')
|
612
|
+
end
|
613
|
+
alias_method :headerize, :titlecase
|
614
|
+
|
604
615
|
def adjective
|
605
616
|
gsub(/\s/, '-')
|
606
617
|
end
|
data/lib/kiss/mailer.rb
CHANGED
@@ -14,6 +14,8 @@ class Kiss
|
|
14
14
|
|
15
15
|
class << self
|
16
16
|
def send(options)
|
17
|
+
options = options.clone
|
18
|
+
|
17
19
|
if options[:sendmail] || (options[:engine] == :sendmail) || !options[:server]
|
18
20
|
send_via_sendmail(options)
|
19
21
|
else
|
@@ -72,7 +74,7 @@ class Kiss
|
|
72
74
|
end
|
73
75
|
|
74
76
|
# Renders email template to string, unless message option is
|
75
|
-
# already set to a string value.
|
77
|
+
# already set to a string value. Also adds missing headers.
|
76
78
|
def prepare_email_message(new_options = {})
|
77
79
|
merge_options(new_options)
|
78
80
|
|
@@ -85,6 +87,36 @@ class Kiss
|
|
85
87
|
raise 'no email message or template found to prepare'
|
86
88
|
end
|
87
89
|
end
|
90
|
+
|
91
|
+
headers, body = options[:message].split(/\n\n/, 2)
|
92
|
+
header_lines = headers.split(/\n/)
|
93
|
+
headers_by_name = {}
|
94
|
+
headers.each do |header|
|
95
|
+
name, value = header.split(/:\s*/, 2)
|
96
|
+
headers_by_name[name] = value
|
97
|
+
end
|
98
|
+
|
99
|
+
new_headers_by_name = {}
|
100
|
+
[:from, :to].each do |name|
|
101
|
+
headercase_name = name.to_s.headercase
|
102
|
+
unless headers_by_name[headercase_name]
|
103
|
+
value = options[name]
|
104
|
+
value = value.join(', ') if value.is_a?(Array)
|
105
|
+
new_headers_by_name[headercase_name] = value
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
(options[:headers] || {}).each_pair do |name, value|
|
110
|
+
new_headers_by_name[name.to_s.headercase_name] = value
|
111
|
+
end
|
112
|
+
|
113
|
+
new_headers_by_name.each_pair do |name, value|
|
114
|
+
header_line = "#{name}: #{value}"
|
115
|
+
header_lines.unshift header_line
|
116
|
+
end
|
117
|
+
|
118
|
+
headers = header_lines.join("\n")
|
119
|
+
options[:message] = "#{headers}\n\n#{body}"
|
88
120
|
|
89
121
|
return @_options[:message]
|
90
122
|
end
|
data/lib/kiss/request.rb
CHANGED
@@ -133,14 +133,14 @@ class Kiss
|
|
133
133
|
"X-Kiss-Error-Message" => exception_message
|
134
134
|
}, body]
|
135
135
|
|
136
|
-
|
136
|
+
should_send_exception_email = true
|
137
137
|
|
138
138
|
unless @_loading_exception_handler
|
139
139
|
@_loading_exception_handler = true
|
140
140
|
begin
|
141
141
|
exception_handler = lookup_exception_handler(e)
|
142
142
|
if exception_handler
|
143
|
-
|
143
|
+
should_send_exception_email = exception_handler[:send_email]
|
144
144
|
new_result = load_exception_handler(exception_handler)
|
145
145
|
if exception_handler[:action]
|
146
146
|
result = handle_request(exception_handler[:action])
|
@@ -152,16 +152,16 @@ class Kiss
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
if
|
155
|
+
if should_send_exception_email && !@_controller.exception_mailer_config.empty?
|
156
|
+
app_name = @_controller.exception_mailer_config.app_name ||
|
157
|
+
@_controller.exception_mailer_config.app || 'Kiss'
|
156
158
|
email_message = <<-EOT
|
159
|
+
Subject: #{app_name} - #{e.class.name}#{exception_message.blank? ? '' : ": #{exception_message}"}
|
157
160
|
Content-type: text/html
|
158
|
-
From: #{@_config.email_errors.from}
|
159
|
-
To: #{@_config.email_errors.to.is_a?(String) ? @_config.email_errors.to : @_config.email_errors.to.join(', ')}
|
160
|
-
Subject: #{@_config.email_errors.app} - #{e.class.name}#{ exception_message ? ": #{exception_message}" : ''}
|
161
161
|
|
162
162
|
#{report}
|
163
163
|
EOT
|
164
|
-
|
164
|
+
send_email(@_controller.exception_mailer_config.merge(:message => email_message))
|
165
165
|
@_exception_email_sent = true
|
166
166
|
end
|
167
167
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 1.7.
|
8
|
+
- 2
|
9
|
+
version: 1.7.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Shawn Van Ittersum
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-02-
|
17
|
+
date: 2012-02-02 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|