Permalink
Browse files

Unforce text-format from AM

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 5714438 commit 0cc4cd020da024674b5cf20ab23ff7498bc55f4a @spastorino spastorino committed with josevalim Jun 1, 2010
View
@@ -24,6 +24,9 @@ end
# AS
gem "memcache-client", ">= 1.7.5"
+# AM
+gem "text-format", "~> 1.0.0"
+
# AR
if mri || RUBY_ENGINE == "rbx"
gem "sqlite3-ruby", "= 1.3.0.beta.2", :require => 'sqlite3'
@@ -21,5 +21,4 @@ Gem::Specification.new do |s|
s.add_dependency('actionpack', version)
s.add_dependency('mail', '~> 2.2.1')
- s.add_dependency('text-format', '~> 1.0.0')
end
@@ -49,9 +49,3 @@ module ActionMailer
autoload :TestCase
autoload :TestHelper
end
-
-module Text
- extend ActiveSupport::Autoload
-
- autoload :Format, 'text/format'
-end
@@ -3,6 +3,13 @@ module MailHelper
# Uses Text::Format to take the text and format it, indented two spaces for
# each line, and wrapped at 72 columns.
def block_format(text)
+ begin
+ require 'text/format'
+ rescue LoadError => e
+ $stderr.puts "You don't have text-format installed in your application. Please add it to your Gemfile and run bundle install"
+ raise e
+ end unless defined?(Text::Format)
+
formatted = text.split(/\n\r\n/).collect { |paragraph|
Text::Format.new(
:columns => 72, :first_indent => 2, :body_indent => 2, :text => paragraph

2 comments on commit 0cc4cd0

Sorry if I'm missing something, but why is a fatal runtime error a better solution than having gems/bundler resolve dependencies at install time? This change means you could have an app that seems to be running fine in Production - and then have it suddenly throw an exception when an email was sent.

Owner

spastorino replied Jun 4, 2010

If the situation you describe occurs, then it might mean that you haven't tested your app correctly. The idea behind removing this dependencies is to avoid installing gems that you may not use.

Please sign in to comment.