Giter Site home page Giter Site logo

locode's Introduction

Locode

Build Status

The Locode gem gives you the ability to lookup UN/LOCODE codes. You can read more about the UN/LOCODE specifications here: wiki.

All data used by this gem has been taken from the UN Centre for Trade Facilitation and E-business official website. No guarantees for the accuracy or up-to-dateness are given.

http://www.unece.org/cefact/locode/welcome.html and http://www.unece.org/cefact/codesfortrade/codes_index.html

Installation

Add this line to your application's Gemfile:

gem 'locode'

And then execute:

$ bundle

Or install it yourself as:

$ gem install locode

Usage

Find Locations whose full name or full name without diacritics matches the search string

Locode.find_by_name('Göteborg')
#=> [<Locode::Location: 'SE GOT'>]

Find Locations that partially match the Search String. This means you can search by just the country code or a whole LOCODE.

Locode.find_by_locode('US')
#=> [<Locode::Location: 'US NYC'>,>
     <Locode::Location: 'US LAX'>, ... ]

You can also retrieve Locode's by the different functions, for example:

Locode.seaports()
#=> [<Locode::Location: 'DE HAM'>, ..]

There are a lot of locations so you can also limit the amount of locations returned by passing a amount:

Locode.inland_clearance_depots(1)
#=> [<Locode::Location: 'DE HAM'>]

These are the possible function calls:

  • seaports(limit)
  • rail_terminals(limit)
  • road_terminals(limit)
  • airport(limit)
  • postal_exchange_offices(limit)
  • inland_clearance_depots(limit)
  • fixed_transport_functions(limit)
  • border_crossing_functions(limit)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

locode's People

Contributors

patrickdet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

locode's Issues

Memory Leak

Using Ruby 2.7.5, this gem causes a memory leak in my Rails app.
Before adding locode, I see around 100 MB of memory usage when booting Puma webserver (fresh rails app).
After adding locode, memory consumption increases by 100 MB per second.

This gem seems unattended for nearly 10 years, but maybe this will help future users reduce some headaches.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.