Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated treetop loading off vendor to work with no polyglot, made def…

…ault of :to_s go to :decoded for fields and :encoded for containers
  • Loading branch information...
commit 3a9fbd03b3985ce686d4cca58908b17e8947fbd2 1 parent 4b6335e
@mikel authored
View
4 CHANGELOG.rdoc
@@ -1,3 +1,7 @@
+== Sun Dec 27 07:30:02 UTC 2009 Mikel Lindsaar <raasdnil@gmail.com>
+
+* Changed fields to default to :decoded on :to_s, all container objects retain :encoded as the default for :to_s
+
== Thu Dec 17 06:35:05 UTC 2009 Mikel Lindsaar <raasdnil@gmail.com>
* Fixed parsing error 'Subject: =?ISO-8859-1?Q?Re=3A_ol=E1?=' (has a new line embedded)
View
8 README.rdoc
@@ -110,8 +110,12 @@ I have tried to simplify it some:
return the object's "value" only as a string. This means it will not include
the header fields (like 'To:' or 'Subject:').
-3. By default, calling :to_s on an object will call it's encoded method, that is, make
- it ready to send in an email.
+3. By default, calling :to_s on a container object will call it's encoded method, while
+ :to_s on a field object will call it's decoded method. So calling :to_s on a Mail
+ object will return the mail, all encoded ready to send, while calling :to_s on the
+ From field will return the decoded value of the field. The body and headers of Mail
+ objects are considered containers. If you are in doubt, call :encoded, or :decoded
+ explicitly, this is safer if you are not sure.
4. Structured fields that have parameter values that can be encoded (e.g. Content-Type) will
provide decoded parameter values when you call the parameter names as methods against
View
4 lib/mail/elements/content_disposition_element.rb
@@ -22,10 +22,6 @@ def parameters
@parameters
end
- def to_s(*args)
-
- end
-
def cleaned(string)
string =~ /(.+);\s*$/ ? $1 : string
end
View
4 lib/mail/elements/content_type_element.rb
@@ -27,10 +27,6 @@ def parameters
@parameters
end
- def to_s(*args)
-
- end
-
def cleaned(string)
string =~ /(.+);\s*$/ ? $1 : string
end
View
2  lib/mail/fields/common/common_field.rb
@@ -28,7 +28,7 @@ def value
end
def to_s
- encoded
+ decoded
end
def field_length
View
5 lib/vendor/treetop-1.4.3/lib/treetop.rb
@@ -11,7 +11,6 @@ module Treetop
require File.join(TREETOP_ROOT, "runtime")
require File.join(TREETOP_ROOT, "compiler")
-unless defined?(::TREETOP_DISABLE_POLYGLOT)
- require 'polyglot'
+if defined?(Polyglot)
Polyglot.register(Treetop::VALID_GRAMMAR_EXT, Treetop)
-end
+end
View
1  lib/vendor/treetop.rb
@@ -1,5 +1,4 @@
# Have to vendor treetop to avoid loading polyglot
$:.unshift "#{File.dirname(__FILE__)}/treetop-1.4.3/lib"
-::TREETOP_DISABLE_POLYGLOT = true
require 'treetop'
View
4 spec/mail/fields/structured_field_spec.rb
@@ -37,8 +37,8 @@
@field = Mail::FromField.new("bob@me.com")
end
- it "should provide a to_s function that returns the encoded string" do
- @field.to_s.should == "From: bob@me.com\r\n"
+ it "should provide a to_s function that returns the decoded string" do
+ @field.to_s.should == "bob@me.com"
end
it "should return '' on to_s if there is no value" do
Please sign in to comment.
Something went wrong with that request. Please try again.