google_currency_exchange 0.0.5

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 406d1e3b51740964054418eb5ace14cccdc7ab5e
4
+ data.tar.gz: 5ecae785ab45847e2b0f0e96e3647a66f3e742ec
5
+ SHA512:
6
+ metadata.gz: df9552a16c090ed48f2b2620a134b248462704cb027140c76cbe5b1ce15fc8f29b4dbc5f9e6f7c1f5d8c75657ea148c49a488588561aaa208ec1d4291858fdf9
7
+ data.tar.gz: d53976e9a3c6c23d9c142e8e2057edc86c601e442140f8555b887b3db1f12505f3b217fd0e8b97f0df48be1f0cd115610a81de8ce558a62e21354b7c8644f1a6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in google_currency_exchange.gemspec
4
+ gemspec
@@ -0,0 +1,15 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ google_currency_exchange (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ bundler
15
+ google_currency_exchange!
@@ -0,0 +1,20 @@
1
+ Copyright 2015 four-corner. https://github.com/four-corner
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.
@@ -0,0 +1,39 @@
1
+ # currency_exchange
2
+
3
+ ### Download and Install
4
+ ```
5
+ gem install google_currency_exchange
6
+ ```
7
+
8
+ or on your Gemfile:
9
+ ```
10
+ gem "google_currency_exchange"
11
+ ```
12
+
13
+ and run
14
+ ```
15
+ bundle install
16
+ ```
17
+
18
+
19
+
20
+ ### Usage
21
+
22
+ ```ruby
23
+
24
+ require 'google_currency_exchange'
25
+
26
+ #Exchange from US dollars(USD) to Indian rupees(INR)
27
+
28
+ currency = GoogleCurrencyExchange.new(1, 'USD','INR')
29
+ currency.process #=> 63.4564
30
+
31
+ ```
32
+
33
+
34
+ ### Contributing to google_currency_exchange
35
+
36
+ Feel free to fork the project and contribute.
37
+
38
+ Copyright (c) 2015 Alok Anand. Read MIT-LICENSE for full details5
39
+
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "google_currency_exchange/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "google_currency_exchange"
7
+ s.version = GemVersion::VERSION
8
+ s.authors = ["four-corner"]
9
+ s.email = ["a2.solutions.44@gmail.com"]
10
+ s.homepage = "https://github.com/four-corner/google_currency_exchange"
11
+ s.summary = %q{Exchange currency of one country to tht of another country's real time valuation using latest Google Finance API}
12
+ s.description = %q{Exchange currency of one country to tht of another country's real time valuation latest Google Finance API}
13
+
14
+ s.rubyforge_project = "google_currency_exchange"
15
+ s.required_ruby_version = '>= 2.0.0'
16
+
17
+ s.extra_rdoc_files = ["MIT-LICENSE", "README.md"]
18
+ s.files = ["Gemfile", "Gemfile.lock","MIT-LICENSE", "README.md", "Rakefile", "lib/google_currency_exchange/version.rb", "lib/base.rb", "lib/google_currency_exchange.rb", "google_currency_exchange.gemspec"]
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+ s.add_development_dependency 'bundler'
23
+ end
@@ -0,0 +1,19 @@
1
+ module Base
2
+ def call_google_finance(amount, from, to)
3
+ uri = URI('https://www.google.com/finance/converter')
4
+ params = { :a => amount,:from => from, :to => to }
5
+ uri.query = URI.encode_www_form(params)
6
+ # Google api will return an html object in response
7
+ res = Net::HTTP.get_response(uri)
8
+ extract_exchanged_amount(res.body)
9
+ end
10
+
11
+ def extract_exchanged_amount(data)
12
+ amount = data[/[bld]>(.*)</,1]
13
+ if amount.nil?
14
+ return "Check & correct currency codes"
15
+ else
16
+ return amount
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require "google_currency_exchange/version"
2
+ require 'net/http'
3
+ require 'base'
4
+
5
+ class GoogleCurrencyExchange
6
+ # Your code goes here...
7
+ include Base
8
+ attr_accessor :amount, :from, :to
9
+
10
+ def initialize(amount, from, to)
11
+ @amount = amount
12
+ @from = from
13
+ @to = to
14
+ end
15
+
16
+ def process
17
+ call_google_finance(@amount, @from, @to)
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module GemVersion
2
+ VERSION = "0.0.5"
3
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: google_currency_exchange
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - four-corner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Exchange currency of one country to tht of another country's real time
28
+ valuation latest Google Finance API
29
+ email:
30
+ - a2.solutions.44@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files:
34
+ - MIT-LICENSE
35
+ - README.md
36
+ files:
37
+ - Gemfile
38
+ - Gemfile.lock
39
+ - MIT-LICENSE
40
+ - README.md
41
+ - Rakefile
42
+ - google_currency_exchange.gemspec
43
+ - lib/base.rb
44
+ - lib/google_currency_exchange.rb
45
+ - lib/google_currency_exchange/version.rb
46
+ homepage: https://github.com/four-corner/google_currency_exchange
47
+ licenses: []
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 2.0.0
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project: google_currency_exchange
65
+ rubygems_version: 2.4.7
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Exchange currency of one country to tht of another country's real time valuation
69
+ using latest Google Finance API
70
+ test_files: []