un_locode 0.0.1
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 +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +10 -0
- data/data/csv/2013-1 UNLOCODE CodeListPart1.csv +43647 -0
- data/data/csv/2013-1 UNLOCODE CodeListPart2.csv +23444 -0
- data/data/csv/2013-1 UNLOCODE CodeListPart3.csv +28630 -0
- data/data/db.rb +32 -0
- data/data/db.sqlite +0 -0
- data/data/locode_data_update.rb +106 -0
- data/data/schema.rb +36 -0
- data/debug.log +4 -0
- data/lib/.DS_Store +0 -0
- data/lib/un_locode/.DS_Store +0 -0
- data/lib/un_locode/base_record.rb +6 -0
- data/lib/un_locode/country.rb +9 -0
- data/lib/un_locode/locode.rb +31 -0
- data/lib/un_locode/version.rb +3 -0
- data/lib/un_locode.rb +11 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/un_locode_spec.rb +76 -0
- data/un_locode.gemspec +28 -0
- metadata +175 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 3793656f2e8a019e5f31026caac9967ec35946e5
|
|
4
|
+
data.tar.gz: 62959bd158236bde648d9a68a690adaf3d53ba20
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c21c0b8702f0d0e70846d08cdc91c55340510c4d70ecb4780b74a8671d2640e6fe73c8a472a08f39bc89e4246bdb571544ec8f75404eb76be1192426366323e1
|
|
7
|
+
data.tar.gz: f6437cc441506e37f35987c02d7a4344b31adc4f9853b79a19d31bfedd5982341abe65771e8c6caa2b1d61058187333d2a06dfd49bf86635b73cded7f010b9c4
|
data/.DS_Store
ADDED
|
Binary file
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-2.0.0-p247
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 Michel de Graaf
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Locode
|
|
2
|
+
|
|
3
|
+
The Locode gem gives you the ability to lookup UN/LOCODE codes. You can read more about the UN/LOCODE specifications here: [wiki](http://en.wikipedia.org/wiki/UN/LOCODE).
|
|
4
|
+
|
|
5
|
+
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.**
|
|
6
|
+
|
|
7
|
+
`http://www.unece.org/cefact/locode/welcome.html` and `http://www.unece.org/cefact/codesfortrade/codes_index.html`
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
gem 'un_locode'
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install un_locode
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Find locations whose name is like the supplied search string. The search is case insensitive and also tries to match
|
|
26
|
+
location name without diacritics (and also alternative names when available). By default the amount of locations
|
|
27
|
+
returned are 10 but you can override this value by passing a number as second argument.
|
|
28
|
+
|
|
29
|
+
UnLocode::Locode.find_by_fuzzy_name('Göte', 5)
|
|
30
|
+
#=> [#<UnLocode::Locode city_code: "GOT", name: "Göteborg", ...
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
Same search mechanisms as above but filter by function. You can find a list of possible functions @ UnLocode::FUNCTIONS.
|
|
34
|
+
Like above you can limit the query result.
|
|
35
|
+
|
|
36
|
+
UnLocode::Locode.find_by_name_and_function('US', :port)
|
|
37
|
+
#=> [<UnLocode::Locode: city_code: "GOT", name: ">,>
|
|
38
|
+
<UnLocode::Locode: 'US LAX'>, ... ]
|
|
39
|
+
|
|
40
|
+
## Contributing
|
|
41
|
+
|
|
42
|
+
1. Fork it
|
|
43
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
44
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
45
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
46
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
2
|
+
require './data/locode_data_update'
|
|
3
|
+
require 'benchmark'
|
|
4
|
+
|
|
5
|
+
desc 'Update the datasource of the gem from csv files'
|
|
6
|
+
task :dataupdate do
|
|
7
|
+
puts 'updating data'
|
|
8
|
+
puts Benchmark.measure { LocodeDataUpdate.parse }
|
|
9
|
+
puts 'end of data update'
|
|
10
|
+
end
|