Project

cccode

0.0
No commit activity in last 3 years
No release in over 3 years
Fetches and persists country and currency codes via SOAP
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 4.0.0
~> 1.13
>= 4.0
~> 10.0
~> 3.0

Runtime

>= 0
>= 0
>= 0
>= 0
>= 0
 Project Readme

Cccode

Country and Currency Code provides quick access to country and currency data via SOAP webservice provided by http://www.webservicex.net.

The data of all countries can be accessed directly via SOAP or be persisted and used via local database access.

Installation

Add this line to your application's Gemfile:

gem 'cccode'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cccode

After the gem is installed you need to create the country_codes table via the gem`s generator:

$ rails g cccode:install
$ rake db:migrate

Usage

Enable usage by adding this to your class/ ruby file:

require 'Cccode'

Soap

This section explains how to call the web service via SOAP directly. For quick access via local db see next section 'Database'.

Get all countries as an array:

Cccode.get_countries

Get country code by country:

Cccode.get_country_code(<country name>)

Get currency by country:

Cccode.get_currency(<country name>)

Get currency code by currency:

Cccode.get_currency_code(<currency name>)

Note: all these actions DO NOT persist the data. To achieve that see 'Database' section!

Database

To get all available data at once and fill the database (reset is executed upfront):

Cccode.get_all

Reset (truncate) conutry_codes table:

Cccode.reset

Check if data exists:

Cccode::CountryCode.exists?

Get all data for a country:

data = Cccode::Codes.new(<country name>)

Example: data = Cccode::Codes.new('Germany') returns:

data.country       = 'Germany'
data.country_code  = 'de'
data.currency      = 'Mark'
data.currency_code = 'DEM'

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/cherrystoned/cccode.

License

The gem is available as open source under the terms of the MIT License.