From aa17c5a59741a4bb55c9989070894e3ea4e1de59 Mon Sep 17 00:00:00 2001 From: Joost Hietbrink Date: Fri, 26 Apr 2013 15:29:04 +0200 Subject: [PATCH] Version 0.2.1 --- README.md | 21 ++++++++++++--------- lib/phony_rails.rb | 2 +- lib/phony_rails/version.rb | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 177b16d..155dee7 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,11 @@ In your model add: class SomeModel < ActiveRecord::Base - # Normalizes the attribute itself before validation + # Normalizes the attribute itself before validation phony_normalize :phone_number, :default_country_code => 'US' # Normalizes attribute before validation and saves into other attribute - phony_normalize :phone_number, :as => :phone_number_normalized_version, :default_country_code => 'US' + phony_normalize :phone_number, :as => :phone_number_normalized_version, :default_country_code => 'US' # Creates method normalized_fax_number that returns the normalized version of fax_number phony_normalized_method :fax_number @@ -78,11 +78,11 @@ In your views use: <%= "311012341234".phony_formatted(:format => :international, :spaces => '-') %> <%= "+31-10-12341234".phony_formatted(:format => :international, :spaces => '-') %> - <%= "+31(0)1012341234".phony_formatted(:format => :international, :spaces => '-') %> + <%= "+31(0)1012341234".phony_formatted(:format => :international, :spaces => '-') %> To first normalize the String to a certain country use: - <%= "010-12341234".phony_formatted(normalize => :NL, :format => :international, :spaces => '-') %> + <%= "010-12341234".phony_formatted(normalize => :NL, :format => :international, :spaces => '-') %> You can also use the bang method (phony_formatted!): @@ -98,28 +98,31 @@ Say you want to find a record by a phone number. Best is to normalize user input ## Changelog +0.2.1 +* Better error handling by @k4nar + 0.1.12 * Further loosened gemspec dependencies. 0.1.11 -* Better gemspec dependency versions by rjhaveri. +* Better gemspec dependency versions by @rjhaveri. 0.1.10 * Changes from henning-koch. * Some pending fixes. 0.1.8 -* Improved validation methods by ddidier. +* Improved validation methods by @ddidier. 0.1.6 * Added :as option to phony_normalize. 0.1.5 -* some tests and a helper method by ddidier. +* some tests and a helper method by @ddidier. 0.1.2 -* Using countries gem as suggested by brutuscat. -* Fixes bugs mentioned by ddidier. +* Using countries gem as suggested by @brutuscat. +* Fixes bugs mentioned by @ddidier. 0.1.0 * Added specs. diff --git a/lib/phony_rails.rb b/lib/phony_rails.rb index 1341ea1..9c376eb 100644 --- a/lib/phony_rails.rb +++ b/lib/phony_rails.rb @@ -49,7 +49,7 @@ def set_phony_normalized_numbers(attributes, options = {}) options[:country_code] ||= self.country_code if self.respond_to?(:country_code) attributes.each do |attribute| attribute_name = options[:as] || attribute - raise RuntimeError, "No attribute #{attribute_name} found on #{self.class.name} (PhonyRails)" if not self.respond_to?(attribute_name) + raise RuntimeError, "No attribute #{attribute_name} found on #{self.class.name} (PhonyRails)" if not self.attribute_method?(attribute_name) write_attribute(attribute_name, PhonyRails.normalize_number(read_attribute(attribute), options)) end end diff --git a/lib/phony_rails/version.rb b/lib/phony_rails/version.rb index 0abb6a6..945bc0c 100644 --- a/lib/phony_rails/version.rb +++ b/lib/phony_rails/version.rb @@ -1,3 +1,3 @@ module PhonyRails - VERSION = "0.2.0" + VERSION = "0.2.1" end