Permalink
Browse files

Bump minor (0.3.0)

  • Loading branch information...
josevalim committed May 20, 2009
1 parent 22a348a commit 800c682db7016427444d6742050cdf17082c67d2
Showing with 62 additions and 37 deletions.
  1. +5 −1 CHANGELOG
  2. +22 −13 README
  3. +31 −20 lib/simple_form/dsl.rb
  4. +3 −2 simple_form.gemspec
  5. +1 −1 test/notifier_test.rb
  6. 0 test/{test-file.txt → test_file.txt}
View
@@ -1,6 +1,10 @@
-# Version 0.2
+# Version 0.3
+* Added support to symbols on :sender, :subject and :recipients
* Added support to symbols on :validate
+
+# Version 0.2
+
* Added support to request objects and append DSL
* Added support to :attachments (thanks to @andrewtimberlake)
View
35 README
@@ -1,6 +1,6 @@
Simple Form
License: MIT
-Version: 0.2.1
+Version: 0.3
You can also read this README in pretty html at the GitHub project Wiki page:
@@ -121,31 +121,40 @@ Examples:
# save is an alias to deliver to allow it to work with InheritedResources
c.save #=> true
-== subject(string=nil, &block)
+== subject(string_or_symbol_or_block)
-Declares the subject of the contact email. It can be a string or a proc.
-As a proc, it receives a simple form instance. When not specified, it defaults
+Declares the subject of the contact email. It can be a string or a proc or a symbol.
+
+When a symbol is given, it will call a method on the form object with the same
+name as the symbol. As a proc, it receives a simple form instance. It defaults
to the class human name.
subject "My Contact Form"
- subject {|c| "Contacted by #{c.name}"}
+ subject { |c| "Contacted by #{c.name}" }
+
+== sender(string_or_symbol_or_block)
-== sender(&block)
+Declares contact email sender. It can be a string or a proc or a symbol.
-Declares contact email sender. It can be a string or a proc.
-As a proc, it receives a simple form instance. By default is:
+When a symbol is given, it will call a method on the form object with the same
+name as the symbol. As a proc, it receives a simple form instance. By default is:
sender{ |c| c.email }
-This requires that your SimpleForm object have at least an email attribute.
+This requires that your SimpleForm object have an email attribute.
-== headers(hash)
+== recipients(string_or_array_or_symbol_or_block)
-Additional headers to your e-mail.
+Who will receive the e-mail. Can be a string or array or a symbol or a proc.
-== recipients(string_or_array_or_proc)
+When a symbol is given, it will call a method on the form object with the same
+name as the symbol. As a proc, it receives a simple form instance.
-Who will receive the e-mail. Can be a string or array, or a proc that returns one of them.
+Both the proc and the symbol must return a string or an array. By default is nil.
+
+== headers(hash)
+
+Additional headers to your e-mail.
I18n
----
View
@@ -60,63 +60,74 @@ def attribute(*accessors)
end
alias :attributes :attribute
- # Declares the subject of the contact email. It can be a string or a proc.
- # As a proc, it receives a simple form instance. When not specified, it
- # defaults to the class human name.
+ # Declares contact email sender. It can be a string or a proc or a symbol.
+ #
+ # When a symbol is given, it will call a method on the form object with
+ # the same name as the symbol. As a proc, it receives a simple form
+ # instance. By default is the class human name.
#
# == Examples
#
# class ContactForm < SimpleForm
# subject "My Contact Form"
# end
#
- def subject(string=nil, &block)
- write_inheritable_attribute(:form_subject, string || block)
+ def subject(duck=nil, &block)
+ write_inheritable_attribute(:form_subject, duck || block)
end
- # Declares contact email sender. It can be a string or a proc.
- # As a proc, it receives a simple form instance. By default is:
+ # Declares contact email sender. It can be a string or a proc or a symbol.
+ #
+ # When a symbol is given, it will call a method on the form object with
+ # the same name as the symbol. As a proc, it receives a simple form
+ # instance. By default is:
#
# sender{ |c| c.email }
#
- # This requires that your SimpleForm object have at least an email attribute.
+ # This requires that your SimpleForm object have an email attribute.
#
# == Examples
#
# class ContactForm < SimpleForm
# # Change sender to include also the name
- # sender{|c| %{"#{c.name}" <#{c.email}>} }
+ # sender { |c| %{"#{c.name}" <#{c.email}>} }
# end
#
- def sender(string=nil, &block)
- write_inheritable_attribute(:form_sender, string || block)
+ def sender(duck=nil, &block)
+ write_inheritable_attribute(:form_sender, duck || block)
end
alias :from :sender
- # Additional headers to your e-mail.
+ # Who will receive the e-mail. Can be a string or array or a symbol or a proc.
+ #
+ # When a symbol is given, it will call a method on the form object with
+ # the same name as the symbol. As a proc, it receives a simple form instance.
+ #
+ # Both the proc and the symbol must return a string or an array. By default
+ # is nil.
#
# == Examples
#
# class ContactForm < SimpleForm
- # headers { :content_type => 'text/html' }
+ # recipients [ "first.manager@domain.com", "second.manager@domain.com" ]
# end
#
- def headers(hash)
- write_inheritable_hash(:form_headers, hash)
+ def recipients(duck=nil, &block)
+ write_inheritable_attribute(:form_recipients, duck || block)
end
+ alias :to :recipients
- # Who will receive the e-mail. Can be a string or array.
+ # Additional headers to your e-mail.
#
# == Examples
#
# class ContactForm < SimpleForm
- # recipients "jose.valim@gmail.com"
+ # headers { :content_type => 'text/html' }
# end
#
- def recipients(string_or_array_or_proc)
- write_inheritable_attribute(:form_recipients, string_or_array_or_proc)
+ def headers(hash)
+ write_inheritable_hash(:form_headers, hash)
end
- alias :to :recipients
# Values from request object to be appended to the contact form.
# Whenever used, you have to send the request object when initializing the object:
View
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = "simple_form"
- s.version = "0.2.1"
- s.date = "2009-04-15"
+ s.version = "0.3.0"
+ s.date = "2009-05-20"
s.summary = "Simple easy contact form for Rails with I18n, validations, attachments and request information."
s.email = "jose.valim@gmail.com"
s.homepage = "http://github.com/josevalim/simple_form"
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
"test/base_test.rb",
"test/errors_test.rb",
"test/notifier_test.rb",
+ "test/test_file.txt",
"test/test_helper.rb"
]
s.rdoc_options = ["--main", "README"]
View
@@ -9,7 +9,7 @@ def setup
@valid_attributes = { :name => 'José', :email => 'my.email@my.domain.com', :message => "Cool\nno?" }
@advanced = AdvancedForm.new(@valid_attributes, @request)
- test_file = ActionController::TestUploadedFile.new(File.join(File.dirname(__FILE__), 'test-file.txt'))
+ test_file = ActionController::TestUploadedFile.new(File.join(File.dirname(__FILE__), 'test_file.txt'))
@with_file = FileForm.new(:name => 'José', :email => 'my.email@my.domain.com', :message => "Cool", :file => test_file)
ActionMailer::Base.deliveries = []
File renamed without changes.

0 comments on commit 800c682

Please sign in to comment.