cainlevy / snail Goto Github PK
View Code? Open in Web Editor NEWA Ruby gem to assist with collecting and formatting international addresses
License: MIT License
A Ruby gem to assist with collecting and formatting international addresses
License: MIT License
For those of us still using Ruby 1.9, snail-1.2.2/lib/snail/helpers.rb could use # encoding: utf-8
at the top of the file.
Hi there,
First off: great gem! Unfortunately the notation for the Netherlands is incorrect. We (as I live in the Netherlands) don't use our regions (provinces) for postal. So you can just leave them out.
when 'Netherlands'
"#{postal_code} #{region} #{city}"
should become (not the two spaces between postal_code and city)
when 'Netherlands'
"#{postal_code} #{city}"
Thanks for this gem!
I'm just wondering how to format addresses containing a company name and a person name.
In Germany, we'd typically put the company name on the first line, followed by the person's name on the next line.
What's the international way of dealing with this? Can Snail handle it in any way?
This does work...
Snail.new(
:name => "Jon Doe c/o Doe Inc.",
:line_1 => "12345 Somewhere Ln",
:line_2 => nil,
:city => "Bentley",
:region => "WA",
:postal_code => "6102",
:country => "AU"
).to_s
...but isn't there a better way?
Hey @cainlevy,
Currently the home_country
is used to determine whether we should display the country line. I believe it is too restrictive and before opening a PR, I would like to discuss with you about it.
In some cases, printing the country line is required. Think about an invoice for instance, the company address printed (home_country
) might be different from the billing/delivery address country (destination).
For an international invoice, the company country should be printed but it is not the case since the home_country
property is specified. Also, the home_country
property always fallback to US
(https://github.com/cainlevy/snail/blob/master/lib/snail.rb#L61).
To avoid breaking changes, I was thinking about adding another property, something like skip_country_line
which will be true
by default. You will be able to override it like home_country
: Snail.skip_country_line = false
Let me know your thoughts.
Cheers.
Hey,
Isn't it proper practice to seperate a region, country with a comma?
so,
New York, NY, USA
rather than:
New York NY USA
Snail's "to_html" method should not wrap the resulting address in an HTML <address>
tag. According to the spec:
The address element provides contact information for a document or part of a document. Information provided by address may include the names of the document’s maintainers, links to the maintainers’ Web pages, e-mail addresses for feedback, postal addresses, phone numbers, and so on. The address element is not appropriate for all postal and e-mail addresses; it should be reserved for providing such information about the contact people for the document.
I think it would be best to allow the caller to determine what block-level element in which to wrap the resulting HTML-formatted addresss.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.