justexchangerates 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -0
- data/lib/justexchangerates.rb +39 -0
- metadata +66 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7f7d728f98dccb8bea8d353c87967fa521103335
|
4
|
+
data.tar.gz: ee268fa959a4acaedda9cf08215a0b71f9cf7b28
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 794ea0e6d9865daebcd74f5f608c74154032f76d2b89617279efbdf6160a0878abb05ff75e64ab3d1b946e844d51c08998e2efc4d50f000ae2a78b0af80636a4
|
7
|
+
data.tar.gz: 4cebf1d0e70509cd4a9ff69bfb6796518580727b3d91821b71452eeec427c7074194033bc914cfc1d1ac0b310582a38c3197ad2769f55641dcc1292566325a64
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
5 =�k[�[�7��aߺ�����1\���.�4�����V.E�=����г$�u�|#O D�C7+z��~� �^9�L����I]�7�Q�F�7��3�s,����-��|��Ce��-��}�6��5_�3}N�a��VZ�<dF#;;bU��1�E~s<��l��h㊣*�AG�;�B�)h� �el���֪�㨁���^���s�J�oR#�X�Aiz��Նg[j��'��mΡ��r������]
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: justexchangerates.rb
|
4
|
+
|
5
|
+
require 'json'
|
6
|
+
require 'open-uri'
|
7
|
+
|
8
|
+
|
9
|
+
class JustExchangeRates
|
10
|
+
|
11
|
+
attr_reader *%i(base date rates)
|
12
|
+
|
13
|
+
def initialize(api:'https://api.fixer.io/latest?base=', base: 'USD')
|
14
|
+
|
15
|
+
response = open(api + base.upcase)
|
16
|
+
|
17
|
+
if response.status.last == "OK" then
|
18
|
+
|
19
|
+
h = JSON.parse(response.read)
|
20
|
+
@base, @date, @rates = h['base'], h['date'], h['rates']
|
21
|
+
|
22
|
+
else
|
23
|
+
puts "JustExchangeRates API error %s : %s" % response.status
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def rate(currency)
|
29
|
+
@rates[currency.upcase]
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
if __FILE__ == $0 then
|
35
|
+
|
36
|
+
jer = JustExchangeRates.new(base: 'USB')
|
37
|
+
jer.rate(VARGS.first) # e.g. GBP #=> 0.73792
|
38
|
+
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: justexchangerates
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwMTA2MTMzMTA1WhcN
|
15
|
+
MTkwMTA2MTMzMTA1WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCdzhfJ
|
17
|
+
E26fwYkFtDE48Tn1mtkdXUeUnpmKUZOk4JzsiP+AiMZaUpeODw9rAxjx2WveEWS8
|
18
|
+
R2Ku3+SK/qNMGpYrxQKp8HZHo+8CBZqWDf32PDcVcDKr7YQGDCM3Bq/KESg6HAR5
|
19
|
+
QciHuU0iqC3dzieoqkC3uTc6SSgFcFBdBZ8XShXJi+b+sAvwVpTLonDbJwYvQDns
|
20
|
+
IPcJHg1LUrr0oiiRsjAr5FRoRfAJ4X8rYd5dSCMzg094vPzkQTI9Q0KL8LxRN9YZ
|
21
|
+
Htqr1EGaCJ9lhHsRw1pmm4ic+LpbdBK+fVmtvkQPB/UzLieKd/H5PxqFEex9cHXe
|
22
|
+
TOv/SEs1XPeBoucxAgMBAAGjgYowgYcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
23
|
+
HQYDVR0OBBYEFEunlQ9JkNIQUIlHiBWFwHkCgb3HMCYGA1UdEQQfMB2BG2dlbW1h
|
24
|
+
c3RlckBqYW1lc3JvYmVydHNvbi5ldTAmBgNVHRIEHzAdgRtnZW1tYXN0ZXJAamFt
|
25
|
+
ZXNyb2JlcnRzb24uZXUwDQYJKoZIhvcNAQEFBQADggEBAGZXS7DSplJaL0WvSnjK
|
26
|
+
vUgyriUKHjWE0r4h4P33nvr81R79Emr/6COTULQnaDBMQ9Ndqob/oWWiY1Xr8KLs
|
27
|
+
fmBE3EzgBdvw5egkMzMCF3tGvazEYhtu2HTXTLhp3dMZMZ5uYijpiAb+Cr0m6EBh
|
28
|
+
lGOlm0nGc2IoqACeXMX+RfwlrUTs1Povy/Y4AK4op8NEafshlowk7llYF1DX4/LL
|
29
|
+
R393mTUaF6oQpbxanRjLmrH8MziLbg4whY7D9KgMMgwwnvIUzrb0jva6u0q6Hccp
|
30
|
+
wxj+BoAMVbJfP/AfQ46F5erI2X10cQzKt41kZwYasgu98+v6KOKzR+J/d7nKaVJ/
|
31
|
+
BL0=
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2018-01-06 00:00:00.000000000 Z
|
34
|
+
dependencies: []
|
35
|
+
description:
|
36
|
+
email: james@jamesrobertson.eu
|
37
|
+
executables: []
|
38
|
+
extensions: []
|
39
|
+
extra_rdoc_files: []
|
40
|
+
files:
|
41
|
+
- lib/justexchangerates.rb
|
42
|
+
homepage: https://github.com/jrobertson/justexchangerates
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata: {}
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 2.6.13
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Fetches the latest exchange rates using the API from http://fixer.io/
|
66
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|