currency_converter_cis 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ module GeoRequest
2
+ def self.location(ip)
3
+ loc = Geocoder.search(ip).first
4
+ return loc.country_code
5
+ end
6
+ end
@@ -0,0 +1,37 @@
1
+ require "spec_helper"
2
+
3
+ describe CountryData::Country do
4
+
5
+ describe '.country_by_id' do
6
+
7
+ it "should return details of the country" do
8
+ data = CountryData::Country.country_by_id("RD")
9
+ data.should_not be_nil
10
+ end
11
+
12
+ it "should return nil if invalid country id passed" do
13
+ data = CountryData::Country.country_by_id("xyz")
14
+ data.should be_nil
15
+ end
16
+
17
+ end
18
+
19
+ describe '.country_by_ip' do
20
+
21
+ it "should return details of the country" do
22
+ data = CountryData::Country.country_by_ip("127.0.0.1")
23
+ data.should_not be_nil
24
+ end
25
+
26
+ end
27
+
28
+ describe '.all_currency' do
29
+
30
+ it "should return all currency details" do
31
+ data = CountryData::Country.all_currency
32
+ data.count.should eq(150)
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,45 @@
1
+ require "spec_helper"
2
+
3
+ describe Currency do
4
+
5
+ describe '.exchange' do
6
+
7
+ it 'should return the amount in dollar' do
8
+ Currency.exchange(500, "inr", "aud").should_not be_nil
9
+ end
10
+
11
+ end
12
+
13
+ describe '.exchange_rate' do
14
+
15
+ it "should return exchange rate of amount" do
16
+ Currency.exchange_rate.should_not be_nil
17
+ end
18
+
19
+ end
20
+
21
+ describe '.calculate' do
22
+
23
+ it "should return a calculated amount" do
24
+ Currency.calculate(500).should_not be_nil
25
+ end
26
+
27
+ end
28
+
29
+ describe 'Raise Errors' do
30
+
31
+ it "raises error with unknown currency" do
32
+ expect { Currency.exchange(500, "xxx", "aud") }.to raise_error(StandardError, /xxx/)
33
+ end
34
+
35
+ it "raises error with unknown currency if any" do
36
+ expect { Currency.exchange(500, "inr", "yyy") }.to raise_error(StandardError, /yyy/)
37
+ end
38
+
39
+ it "raises error if valid amout is not present" do
40
+ expect { Currency.calculate('xyz') }.to raise_error(StandardError, 'Could not find out the result')
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,13 @@
1
+ require "spec_helper"
2
+
3
+ describe GeoRequest do
4
+
5
+ describe '.location' do
6
+
7
+ it "should return location details as per the ip" do
8
+ GeoRequest.location("127.0.0.1").should_not be_nil
9
+ end
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,6 @@
1
+ ENV['RAILS_ENV'] = 'test'
2
+
3
+ require 'rails'
4
+ require 'currency'
5
+ require 'currencies_code'
6
+ require 'currency_converter_cis'
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: currency_converter_cis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Akeel Qureshi, CISROR Team
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-10-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nokogiri
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: geocoder
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec-rails
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: With the use to this gem , The two major issues will be solved the first
63
+ one is to find out the various contry related details using either the contry code
64
+ or the ip-address and the second one is to convert an amount from one currency to
65
+ another, There are various scenarios where user has to show user locale related
66
+ information based up on his/her ip-address So in those cases this gem will be really
67
+ useful.
68
+ email:
69
+ executables: []
70
+ extensions: []
71
+ extra_rdoc_files: []
72
+ files:
73
+ - lib/geo_request.rb
74
+ - lib/country_data.rb
75
+ - lib/data/countries.yaml
76
+ - lib/currencies_code.rb
77
+ - lib/currency.rb
78
+ - lib/currency_converter_cis.rb
79
+ - spec/geo_request_spec.rb
80
+ - spec/currency_spec.rb
81
+ - spec/spec_helper.rb
82
+ - spec/country_data_spec.rb
83
+ - README.md
84
+ - currency_converter_cis.gemspec
85
+ homepage: http://rubygems.org/gems/currency_converter_cis
86
+ licenses: []
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 1.8.24
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: This gem caters the requirement to fetch the country related details based
109
+ up on the ip-address or the country code. You can also convert an amount from one
110
+ currency to another
111
+ test_files: []