eropple-biggs 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile +0 -3
- data/README.md +5 -5
- data/biggs.gemspec +7 -5
- data/lib/biggs/formatter.rb +25 -1
- data/lib/biggs/version.rb +1 -1
- metadata +35 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba52b6f49f745b5693ccd402be95ac1a8a32d248
|
4
|
+
data.tar.gz: 0e9d5ecc6f3d80d12e8c6fa41afda797a4e5b31f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 667b32fa70a75bc63ee6a41a4d5886c5f5da103d1f846ad6c1274e472d86d617f7e3433fc6beb0ed34916b21699ead42a384ae88e5743b4d75810108882c0311
|
7
|
+
data.tar.gz: a5cf23dd469b672190fcdcb9d861a7128080304c7de0cd14a461b5a912ad36360a3a44bd5e651677572d194ea047d02371f2b6382cccadd89231cec55d0ad886
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -4,11 +4,11 @@ biggs is a small ruby gem/rails plugin for formatting postal addresses from over
|
|
4
4
|
|
5
5
|
As a ruby gem:
|
6
6
|
|
7
|
-
sudo gem install biggs
|
7
|
+
sudo gem install eropple-biggs
|
8
8
|
|
9
|
-
|
9
|
+
Or in a Gemfile:
|
10
10
|
|
11
|
-
|
11
|
+
gem 'eropple-biggs', '~> 0.4.0'
|
12
12
|
|
13
13
|
### Standalone usage
|
14
14
|
|
@@ -144,6 +144,6 @@ biggs knows how to format addresses of over 60 different countries. If you are m
|
|
144
144
|
* United States
|
145
145
|
* Yemen
|
146
146
|
|
147
|
-
biggs is tested to behave well with Rails 3.0, 3.1, 3.2 and 4.0
|
147
|
+
biggs is tested to behave well with Rails 3.0, 3.1, 3.2 and 4.0.
|
148
148
|
|
149
|
-
Copyright (c) 2009-2013 Yolk Sebastian Munz & Julia Soergel GbR
|
149
|
+
Copyright (c) 2009-2013 Yolk Sebastian Munz & Julia Soergel GbR, 2015 Ed Ropple
|
data/biggs.gemspec
CHANGED
@@ -6,11 +6,11 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = 'eropple-biggs'
|
7
7
|
s.version = Biggs::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ['Sebastian Munz']
|
10
|
-
s.email = ['sebastian@yo.lk']
|
11
|
-
s.homepage = 'https://github.com/
|
9
|
+
s.authors = ['Sebastian Munz', 'Ed Ropple']
|
10
|
+
s.email = ['sebastian@yo.lk', 'ed+biggs@edropple.com']
|
11
|
+
s.homepage = 'https://github.com/eropple/biggs'
|
12
12
|
s.summary = 'biggs is a small ruby gem/rails plugin for formatting postal addresses from over 60 countries.'
|
13
|
-
s.description = 'biggs is a small ruby gem/rails plugin for formatting postal addresses from over 60 countries.'
|
13
|
+
s.description = 'biggs is a small ruby gem/rails plugin for formatting postal addresses from over 60 countries. This version is maintained by Ed Ropple off of the abandoned source.'
|
14
14
|
|
15
15
|
s.rubyforge_project = 'biggs'
|
16
16
|
|
@@ -20,9 +20,11 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ['lib']
|
21
21
|
|
22
22
|
s.add_dependency 'activerecord', '>= 3.0'
|
23
|
-
|
23
|
+
s.add_dependency 'countries', '>= 0.11.0'
|
24
|
+
|
24
25
|
s.add_development_dependency 'rake'
|
25
26
|
s.add_development_dependency 'rspec', '>= 3.0.0'
|
26
27
|
s.add_development_dependency 'rspec-its', '>= 1.1.0'
|
27
28
|
s.add_development_dependency 'sqlite3', '>= 1.3.5'
|
29
|
+
s.add_development_dependency 'pry'
|
28
30
|
end
|
data/lib/biggs/formatter.rb
CHANGED
@@ -1,15 +1,39 @@
|
|
1
1
|
module Biggs
|
2
2
|
class Formatter
|
3
|
-
FIELDS = [:recipient, :street, :city, :region, :postalcode, :country]
|
3
|
+
FIELDS = [:recipient, :street, :city, :region, :region_short, :postalcode, :country]
|
4
4
|
|
5
5
|
def initialize(options = {})
|
6
6
|
@blank_country_on = [options[:blank_country_on]].compact.flatten.map { |s| s.to_s.downcase }
|
7
7
|
end
|
8
8
|
|
9
9
|
def format(iso_code, values = {})
|
10
|
+
# HACK: most of this method, honestly. I needed to get {{region_short}} working and
|
11
|
+
# bring this into compliance with countries v0.11.x.
|
10
12
|
values.symbolize_keys! if values.respond_to?(:symbolize_keys!)
|
11
13
|
|
12
14
|
format = Biggs::Format.find(iso_code)
|
15
|
+
raise "Could not find country with code '#{iso_code}'." unless format && format.country
|
16
|
+
|
17
|
+
format_string = (format.format_string || default_format_string(values[:region])).dup.to_s
|
18
|
+
|
19
|
+
if values[:region_short] && !values[:region] && format_string.include?("{{region}}")
|
20
|
+
region_code = values[:region_short]
|
21
|
+
|
22
|
+
region = format.country.subdivisions[:region_short]
|
23
|
+
raise "Could not find region/subdivision with code '#{region_code}'. " +
|
24
|
+
"To override, specify both :region and :region_short." unless region
|
25
|
+
|
26
|
+
values[:region] = region[:name]
|
27
|
+
elsif values[:region] && !values[:region_short] && format_string.include?("{{region_short}}")
|
28
|
+
# FIXME: this is an iterative search over all names in the countries list. Not great, Bob.
|
29
|
+
subdivision = format.country.subdivisions.find do |sub_kvp|
|
30
|
+
sub_kvp[1]["name"] == values[:region] || sub_kvp[1]["names"].include?(values[:region])
|
31
|
+
end
|
32
|
+
raise "Could not find short_code" unless subdivision
|
33
|
+
|
34
|
+
values[:region_short] = subdivision[0]
|
35
|
+
end
|
36
|
+
|
13
37
|
format_string = (format.format_string || default_format_string(values[:region])).dup.to_s
|
14
38
|
country_name = blank_country_on.include?(format.iso_code) ? '' : format.country_name || format.iso_code
|
15
39
|
|
data/lib/biggs/version.rb
CHANGED
metadata
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eropple-biggs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Munz
|
8
|
+
- Ed Ropple
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
@@ -24,6 +25,20 @@ dependencies:
|
|
24
25
|
- - ">="
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '3.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: countries
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.11.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.11.0
|
27
42
|
- !ruby/object:Gem::Dependency
|
28
43
|
name: rake
|
29
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,10 +95,26 @@ dependencies:
|
|
80
95
|
- - ">="
|
81
96
|
- !ruby/object:Gem::Version
|
82
97
|
version: 1.3.5
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: pry
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
83
112
|
description: biggs is a small ruby gem/rails plugin for formatting postal addresses
|
84
|
-
from over 60 countries.
|
113
|
+
from over 60 countries. This version is maintained by Ed Ropple off of the abandoned
|
114
|
+
source.
|
85
115
|
email:
|
86
116
|
- sebastian@yo.lk
|
117
|
+
- ed+biggs@edropple.com
|
87
118
|
executables: []
|
88
119
|
extensions: []
|
89
120
|
extra_rdoc_files: []
|
@@ -106,7 +137,7 @@ files:
|
|
106
137
|
- spec/unit/activerecord_spec.rb
|
107
138
|
- spec/unit/biggs_spec.rb
|
108
139
|
- spec/unit/format_spec.rb
|
109
|
-
homepage: https://github.com/
|
140
|
+
homepage: https://github.com/eropple/biggs
|
110
141
|
licenses: []
|
111
142
|
metadata: {}
|
112
143
|
post_install_message:
|
@@ -135,3 +166,4 @@ test_files:
|
|
135
166
|
- spec/unit/activerecord_spec.rb
|
136
167
|
- spec/unit/biggs_spec.rb
|
137
168
|
- spec/unit/format_spec.rb
|
169
|
+
has_rdoc:
|