Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Countries gem as data source. #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
source "http://rubygems.org"
source 'http://rubygems.org'

gem 'countries', :git => 'https://github.com/burningpony/countries.git'

# Specify your gem's dependencies in dar_da_da.gemspec
gemspec
gemspec
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ If your rather prefer to install it as a plugin for rails, from your application
:recipient => "Yolk Sebastian Munz & Julia Soergel GbR",
:street => "Adalbertstr. 11", # <= street + house number
:city => "Berlin",
:zip => 10999,
:state => "Berlin" # <= state/province/region
:postalcode => 10999,
:region => "Berlin" # <= region/province/region
)

returns
Expand Down Expand Up @@ -47,13 +47,13 @@ With the data from the above example this would return:
biggs :postal_address
end

This adds the method postal_address to your Address-model, and assumes the presence of the methods/columns recipient, street, city, zip, state, and country to get the address data. Country should return the ISO-code (e.g. 'us', 'fr', 'de').
This adds the method postal_address to your Address-model, and assumes the presence of the methods/columns recipient, street, city, postalcode, region, and country to get the address data. Country should return the ISO-code (e.g. 'us', 'fr', 'de').

You can customize the method-names biggs will use by passing in a hash of options:

Address < ActiveRecord::Base
biggs :postal_address,
:zip => :postal_code,
:postalcode => :postal_code,
:country => :country_code,
:street => Proc.new {|address| "#{address.street} #{address.house_number}" }
end
Expand All @@ -73,7 +73,7 @@ To access the formatted address string, simply call the provided method on an ad

Address.find(1).postal_address

If you pass in a ISO alpha 2 code as :country that is not supported by biggs, it will choose the US-format for addresses with an state specified, and the french/german format for addresses without an state.
If you pass in a ISO alpha 2 code as :country that is not supported by biggs, it will choose the US-format for addresses with an region specified, and the french/german format for addresses without an region.

### Supported countries

Expand All @@ -90,7 +90,7 @@ biggs knows how to format addresses of over 60 different countries. If you are m
* Canada
* China
* Croatia
* Czech
* Czech Republic
* Denmark
* Egypt
* Finland
Expand All @@ -108,11 +108,12 @@ biggs knows how to format addresses of over 60 different countries. If you are m
* Italy
* Japan
* Jordan
* Korea, Republic of
* Kuwait
* Lebanon
* Lichtenstein
* Liechtenstein
* Luxembourg
* Macedonia
* Macedonia, the Former Yugoslav Republic Of
* Mexico
* Netherlands
* New Caledonia
Expand All @@ -126,23 +127,21 @@ biggs knows how to format addresses of over 60 different countries. If you are m
* Romania
* Russian Federation
* Saudi Arabia
* Serbia and Montenegro
* Singapore
* Slovakia
* Slovenia
* South Africa
* South Korea
* Spain
* Sweden
* Switzerland
* Syrian Arab Republic
* Taiwan
* Taiwan, Republic Of China
* Thailand
* Turkey
* Ukraine
* United Arab Emirates
* United Kingdom
* United States of America
* United States
* Yemen

biggs is tested to behave well with Rails 3.0, 3.1, 3.2 and 4.0
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

task :default => :spec
task default: :spec
27 changes: 14 additions & 13 deletions biggs.gemspec
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "biggs/version"
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'biggs/version'

Gem::Specification.new do |s|
s.name = "biggs"
s.name = 'biggs'
s.version = Biggs::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Sebastian Munz"]
s.email = ["[email protected]"]
s.homepage = "https://github.com/yolk/biggs"
s.summary = %q{biggs is a small ruby gem/rails plugin for formatting postal addresses from over 60 countries.}
s.description = %q{biggs is a small ruby gem/rails plugin for formatting postal addresses from over 60 countries.}
s.authors = ['Sebastian Munz']
s.email = ['[email protected]']
s.homepage = 'https://github.com/yolk/biggs'
s.summary = 'biggs is a small ruby gem/rails plugin for formatting postal addresses from over 60 countries.'
s.description = 'biggs is a small ruby gem/rails plugin for formatting postal addresses from over 60 countries.'

s.rubyforge_project = "biggs"
s.rubyforge_project = 'biggs'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
s.require_paths = ['lib']

s.add_dependency 'activerecord', '>= 3.0'
# s.add_dependency 'countries', '>= 0.9.3'
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec', '>= 2.4.0'
s.add_development_dependency 'rspec', '>= 3.0.0'
s.add_development_dependency 'rspec-its', '>= 1.1.0'
s.add_development_dependency 'sqlite3', '>= 1.3.5'
end

246 changes: 0 additions & 246 deletions country_names.yml

This file was deleted.

Loading