addressable_record 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ == 1.0.1 2010-01-01
2
+
3
+ * Added a join method for specifying output formats a different way than to_s.
4
+
5
+
6
+ == 1.0.0 2009-12-30
7
+
8
+ * Initial release.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ begin
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "addressable_record"
8
8
  gem.summary = %Q{Encapsulates the composed of pattern for addresses into any easy to use library.}
9
- gem.description = %Q{Encapsulates the composed of pattern for addresses into any easy to use library. Provides conveniencce methods for formatting, parsing, etc.}
9
+ gem.description = %Q{Encapsulates the composed of pattern for addresses into any easy to use library. Provides convenience methods for formatting, parsing, etc.}
10
10
  gem.email = "jason@lookforwardenterprises.com"
11
11
  gem.homepage = "http://github.com/midas/addressable_record"
12
12
  gem.authors = ["C. Jason Harrelson (midas)"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{addressable_record}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["C. Jason Harrelson (midas)"]
12
- s.date = %q{2009-12-31}
13
- s.description = %q{Encapsulates the composed of pattern for addresses into any easy to use library. Provides conveniencce methods for formatting, parsing, etc.}
12
+ s.date = %q{2010-01-01}
13
+ s.description = %q{Encapsulates the composed of pattern for addresses into any easy to use library. Provides convenience methods for formatting, parsing, etc.}
14
14
  s.email = %q{jason@lookforwardenterprises.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.files = [
20
20
  ".document",
21
21
  ".gitignore",
22
+ "History.txt",
22
23
  "LICENSE",
23
24
  "README.rdoc",
24
25
  "Rakefile",
@@ -4,7 +4,7 @@ require 'addressable_record/address'
4
4
  require 'addressable_record/active_record_extesions'
5
5
 
6
6
  module AddressableRecord
7
- VERSION = '1.0.0'
7
+ VERSION = '1.0.1'
8
8
  end
9
9
 
10
10
  ActiveRecord::Base.send( :include, AddressableRecord::ActiveRecordExtensions ) if defined?( ActiveRecord::Base )
@@ -79,6 +79,30 @@ module AddressableRecord
79
79
  @pattern_map.each { |pat, replacement| to_return = to_return.gsub( pat, replacement ) }
80
80
  to_return.strip
81
81
  end
82
+
83
+ # Outputs the parts of teh address delimited by specified delimiter(s).
84
+ #
85
+ # *parameters*
86
+ # opts:: Can be a string that is the delimiter or an an options hash.
87
+ #
88
+ # *options*
89
+ # delimiter:: The string to delimit the address with.
90
+ # street_delimiter:: An additional delimiter to use only on the street fields.
91
+ # country:: Outputs the country when true, otherwise no country is output (defaults to false).
92
+ #
93
+ def join( opts )
94
+ if opts.is_a?( Hash )
95
+ options = opts
96
+ options[:street_delimiter] ||= options[:delimiter]
97
+ elsif opts.is_a?( String )
98
+ options = {}
99
+ options[:street_delimiter] = options[:delimiter] = opts
100
+ options[:country] = false
101
+ end
102
+
103
+ to_return = "#{self.street( options[:street_delimiter] )}#{options[:delimiter]}#{self.city}, #{self.state_or_province} #{self.zip_code}"
104
+ return options[:country] ? to_return + "#{options[:delimiter]}#{self.country}" : to_return
105
+ end
82
106
 
83
107
  protected
84
108
 
@@ -28,4 +28,24 @@ shared_examples_for "The address 123 Jones Street, Suite 540, Atlanta, GA, 33333
28
28
  it "should agree that the country is United States" do
29
29
  @address.country.should eql( 'United States' )
30
30
  end
31
+
32
+ it "should join the address correctly given a string delimiter argument" do
33
+ @address.join( '<br/>' ).should eql( '123 Jones Street<br/>Suite 540<br/>Atlanta, GA 33333-1111' )
34
+ end
35
+
36
+ it "should join the address correctly given a delimiter option" do
37
+ @address.join( :delimiter => '<br/>' ).should eql( '123 Jones Street<br/>Suite 540<br/>Atlanta, GA 33333-1111' )
38
+ end
39
+
40
+ it "should join the address correctly given a delimiter and street_delimiter option" do
41
+ @address.join( :delimiter => '<br/>', :street_delimiter => '###' ).should eql( '123 Jones Street###Suite 540<br/>Atlanta, GA 33333-1111' )
42
+ end
43
+
44
+ it "should join the address correctly given a delimiter and country option" do
45
+ @address.join( :delimiter => '<br/>', :country => true ).should eql( '123 Jones Street<br/>Suite 540<br/>Atlanta, GA 33333-1111<br/>United States' )
46
+ end
47
+
48
+ it "should join the address correctly given a delimiter and street_delimiter option" do
49
+ @address.join( :delimiter => '<br/>', :street_delimiter => '###', :country => true ).should eql( '123 Jones Street###Suite 540<br/>Atlanta, GA 33333-1111<br/>United States' )
50
+ end
31
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: addressable_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - C. Jason Harrelson (midas)
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-31 00:00:00 -06:00
12
+ date: 2010-01-01 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,7 +42,7 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 1.2.9
44
44
  version:
45
- description: Encapsulates the composed of pattern for addresses into any easy to use library. Provides conveniencce methods for formatting, parsing, etc.
45
+ description: Encapsulates the composed of pattern for addresses into any easy to use library. Provides convenience methods for formatting, parsing, etc.
46
46
  email: jason@lookforwardenterprises.com
47
47
  executables: []
48
48
 
@@ -54,6 +54,7 @@ extra_rdoc_files:
54
54
  files:
55
55
  - .document
56
56
  - .gitignore
57
+ - History.txt
57
58
  - LICENSE
58
59
  - README.rdoc
59
60
  - Rakefile