exchangerate 0.1.0

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.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Giridhar Bandi
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest ADDED
@@ -0,0 +1,6 @@
1
+ MIT-LICENSE
2
+ Manifest
3
+ README.rdoc
4
+ Rakefile
5
+ exchangerate.gemspec
6
+ lib/exchangerate.rb
data/README.rdoc ADDED
@@ -0,0 +1,21 @@
1
+ = EchangeRate
2
+
3
+ == Description
4
+ This is a Ruby interface into the exchangerate-api service.
5
+
6
+ == Installation
7
+
8
+ gem install exhangerate
9
+
10
+ == Usage
11
+
12
+ Before you use this library please get the api key from http://www.exchangerate-api.com/api-key
13
+
14
+ require 'rubygems'
15
+ require 'exchangerate'
16
+
17
+ er=ExchangeRate.new("my-api-key")
18
+ er.convert("USD","INR","300.00")
19
+
20
+
21
+
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('exchangerate', '0.1.0') do |p|
6
+ p.description = "A gem to convert currencies with ease!"
7
+ p.url = "http://github.com/giridhar/exhangerate"
8
+ p.author = "Giridhar Bandi"
9
+ p.email = "giridhar dot bandi at gmail.com"
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = []
12
+ end
13
+
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{exchangerate}
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Giridhar Bandi"]
9
+ s.date = %q{2010-05-20}
10
+ s.description = %q{A gem to convert currencies with ease!}
11
+ s.email = %q{giridhar dot bandi at gmail.com}
12
+ s.extra_rdoc_files = ["README.rdoc", "lib/exchangerate.rb"]
13
+ s.files = ["MIT-LICENSE", "Manifest", "README.rdoc", "Rakefile", "exchangerate.gemspec", "lib/exchangerate.rb"]
14
+ s.homepage = %q{http://github.com/giridhar/exhangerate}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Exchangerate", "--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{exchangerate}
18
+ s.rubygems_version = %q{1.3.7}
19
+ s.summary = %q{A gem to convert currencies with ease!}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ else
27
+ end
28
+ else
29
+ end
30
+ end
@@ -0,0 +1,26 @@
1
+ require 'net/http'
2
+
3
+ class UnsupportedCurrencyException < RuntimeError
4
+ end
5
+
6
+ class ExchangeRate
7
+ HOST = "www.exchangerate-api.com"
8
+ SUPPORTED_CODES=['EUR','USD','JPY','GBP','BGN','CZK','DKK','EEK','HUF','LTL','LVL','PLN','RON','SEK','CHF','NOK','HRK','RUB','TRY','AUD','BRL','CAD','CNY','HKD','IDR','INR','KRW','MXN','MYR','NZD','PHP','SGD','THB','ZAR']
9
+
10
+ def initialize(api_key)
11
+ @api_key = api_key
12
+ end
13
+
14
+ def convert(from_curr,to_curr,amount)
15
+ begin
16
+ raise UnsupportedCurrencyException, "The currency is not supported " if !SUPPORTED_CODES.include?(from_curr) || !SUPPORTED_CODES.include?(to_curr)
17
+ http = Net::HTTP.new(HOST, 80)
18
+ url = "/"+from_curr+"/"+to_curr+"/"+amount.to_s+"?k=#{@api_key}"
19
+ response = http.get(url)
20
+ return response.body
21
+ rescue => e
22
+ puts "Error: #{e}"
23
+ end
24
+ end
25
+ end
26
+
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exchangerate
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Giridhar Bandi
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-20 00:00:00 +05:30
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: A gem to convert currencies with ease!
22
+ email: giridhar dot bandi at gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README.rdoc
29
+ - lib/exchangerate.rb
30
+ files:
31
+ - MIT-LICENSE
32
+ - Manifest
33
+ - README.rdoc
34
+ - Rakefile
35
+ - exchangerate.gemspec
36
+ - lib/exchangerate.rb
37
+ has_rdoc: true
38
+ homepage: http://github.com/giridhar/exhangerate
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options:
43
+ - --line-numbers
44
+ - --inline-source
45
+ - --title
46
+ - Exchangerate
47
+ - --main
48
+ - README.rdoc
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ segments:
65
+ - 1
66
+ - 2
67
+ version: "1.2"
68
+ requirements: []
69
+
70
+ rubyforge_project: exchangerate
71
+ rubygems_version: 1.3.7
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: A gem to convert currencies with ease!
75
+ test_files: []
76
+