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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e85e26e3b8e91e6ad36b4a977eb0612533919305
4
- data.tar.gz: 531cbd742daa5ba9a44363ddb23c7714e5997be5
3
+ metadata.gz: ba52b6f49f745b5693ccd402be95ac1a8a32d248
4
+ data.tar.gz: 0e9d5ecc6f3d80d12e8c6fa41afda797a4e5b31f
5
5
  SHA512:
6
- metadata.gz: 22ff1be8108399d33269fcf39c29648e0302d7857839fe26a94be1e80c8267244488721da1dad40ea9c241d2be1a3dd9acb1c7fbc559b976759269c7e9b1f20c
7
- data.tar.gz: c03358b221cc0b23d5cc1d56737fb7f0b602fa65314604a09429222acbe0122c00d81fb35f1d42adb0020c039ca45facb8efd237436091f557f8fe66368833fe
6
+ metadata.gz: 667b32fa70a75bc63ee6a41a4d5886c5f5da103d1f846ad6c1274e472d86d617f7e3433fc6beb0ed34916b21699ead42a384ae88e5743b4d75810108882c0311
7
+ data.tar.gz: a5cf23dd469b672190fcdcb9d861a7128080304c7de0cd14a461b5a912ad36360a3a44bd5e651677572d194ea047d02371f2b6382cccadd89231cec55d0ad886
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  biggs-*.*.*.gem
2
2
  Gemfile.lock
3
- .rbenv-*
3
+ .rbenv-*
4
+ pkg
data/Gemfile CHANGED
@@ -1,6 +1,3 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'countries', :git => 'https://github.com/burningpony/countries.git'
4
-
5
- # Specify your gem's dependencies in dar_da_da.gemspec
6
3
  gemspec
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
- If your rather prefer to install it as a plugin for rails, from your application directory simply run:
9
+ Or in a Gemfile:
10
10
 
11
- script/plugin install git://github.com/yolk/biggs.git
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
@@ -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/yolk/biggs'
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
- # s.add_dependency 'countries', '>= 0.9.3'
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
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Biggs
2
- VERSION = '0.3.4'
2
+ VERSION = '0.4.0'
3
3
  end
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.3.4
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/yolk/biggs
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: