oexrwrapper 0.1.0 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05dc3742677d8f04ac81872eb5cd29c3026691086ee2618d23e9f903aee5e3d8
4
- data.tar.gz: 4e52196789c76613421cd313469c958add769d761a5f737f9dd1f443aff36a93
3
+ metadata.gz: a706334a795ad7d94d7fbe59423811794cdf966a92630dd3f11fae69db2b8eb8
4
+ data.tar.gz: 5ffb6ea6bedfb17ded3dc517c4f9ac4238d9a19d23cc1d4b035542210230358f
5
5
  SHA512:
6
- metadata.gz: 7f3a0d9a033cf528bb82d0ee344dbac3caff46a0388b533a32f46694261dfa5f25e5a1e0d24661e4f721425271c344bff479c73adc710cee308b1740f08acf7e
7
- data.tar.gz: 9073282c2852c27ff7981e26494b281efb5d1f80fd402358f1a7b72a3bfb73bfce0b9dec6214316501a442c3fb8693dec2bb3f45ceb29d3aaa8928818c55caa3
6
+ metadata.gz: ff20781ab6ada74c7e4baaffb1f6c91e87cd9cd6fa100a69a020cd20a038891f0dcbd59cceeedfa980d5acc65b44def461867f0f13684406397a3625d41a60ae
7
+ data.tar.gz: 15adf92eee3fb001809f3d45cda3f19df16f0b6f28817f767c3e0e194c315e74179dd3e33446d322e297273c1e4da7845429b40967ad6263fb06d838bb485c51
data/CHANGELOG.md CHANGED
@@ -1,4 +1,5 @@
1
- ## [Unreleased]
1
+ ## [0.1.1] - 2022-03-25
2
+ - Add currencies list
2
3
 
3
4
  ## [0.1.0] - 2022-03-21
4
5
 
data/Gemfile CHANGED
@@ -10,3 +10,5 @@ gem "rake", "~> 13.0"
10
10
  gem "rspec", "~> 3.0"
11
11
 
12
12
  gem "rubocop", "~> 1.21"
13
+
14
+ gem 'webmock'
data/Gemfile.lock CHANGED
@@ -1,21 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oexrwrapper (0.1.0)
4
+ oexrwrapper (0.1.3)
5
5
  faraday (~> 2.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ addressable (2.8.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
10
12
  ast (2.4.2)
13
+ crack (0.4.5)
14
+ rexml
11
15
  diff-lcs (1.5.0)
12
16
  faraday (2.2.0)
13
17
  faraday-net_http (~> 2.0)
14
18
  ruby2_keywords (>= 0.0.4)
15
19
  faraday-net_http (2.0.1)
20
+ hashdiff (1.0.1)
16
21
  parallel (1.21.0)
17
22
  parser (3.1.1.0)
18
23
  ast (~> 2.4.1)
24
+ public_suffix (4.0.6)
19
25
  rainbow (3.1.1)
20
26
  rake (13.0.6)
21
27
  regexp_parser (2.2.1)
@@ -47,15 +53,21 @@ GEM
47
53
  ruby-progressbar (1.11.0)
48
54
  ruby2_keywords (0.0.5)
49
55
  unicode-display_width (2.1.0)
56
+ webmock (3.14.0)
57
+ addressable (>= 2.8.0)
58
+ crack (>= 0.3.2)
59
+ hashdiff (>= 0.4.0, < 2.0.0)
50
60
 
51
61
  PLATFORMS
52
62
  arm64-darwin-21
63
+ x86_64-linux
53
64
 
54
65
  DEPENDENCIES
55
66
  oexrwrapper!
56
67
  rake (~> 13.0)
57
68
  rspec (~> 3.0)
58
69
  rubocop (~> 1.21)
70
+ webmock
59
71
 
60
72
  BUNDLED WITH
61
73
  2.3.6
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # OEXRWrapper
2
-
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/a71a2a3a3e3ce266b7c0/maintainability)](https://codeclimate.com/github/sdglhm/OEXRWrapper/maintainability)
3
+ ![example workflow](https://github.com/sdglhm/OEXRWrapper/actions/workflows/build.yml/badge.svg)
4
+ [![Gem Version](https://badge.fury.io/rb/oexrwrapper.svg)](https://badge.fury.io/rb/oexrwrapper)
3
5
  Simple gem written for learning purposes. Fetches latest exchange rate from OpenExchangeRates.org and returns value.
4
6
 
5
7
  ## ToDo
6
8
  - [X] Get latest currency exchange rate
7
- - [ ] Implement currencies list
9
+ - [X] Implement currencies list
8
10
  - [ ] Write tests (Probably)
9
11
 
10
12
  ## Installation
@@ -34,6 +36,13 @@ client.latest.retrieve
34
36
  # Get a single currency exchange rate from code
35
37
  client.latest.usd
36
38
  client.latest.jpy
39
+
40
+ # Get list of supported currencies
41
+ client.currencies.retrieve
42
+
43
+ # Convert a three letter currency code to currency name
44
+ client.currencies.code_to_string('usd')
45
+ client.currencies.code_to_s('usd')
37
46
  ```
38
47
  ## Development
39
48
 
@@ -43,7 +52,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
43
52
 
44
53
  ## Contributing
45
54
 
46
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/oexrwrapper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/oexrwrapper/blob/master/CODE_OF_CONDUCT.md).
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sdglhm/OEXRWrapper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/sdglhm/OEXRWrapper/blob/master/CODE_OF_CONDUCT.md).
47
56
 
48
57
  ## Code of Conduct
49
58
 
@@ -13,7 +13,11 @@ module OEXRWrapper
13
13
  end
14
14
 
15
15
  def latest
16
- LatestResource.new(self)
16
+ LatestResource.new self
17
+ end
18
+
19
+ def currencies
20
+ CurrenciesResources.new self
17
21
  end
18
22
 
19
23
  def connection
@@ -0,0 +1,4 @@
1
+ module OEXRWrapper
2
+ class Currencies < SimpleDelegator
3
+ end
4
+ end
@@ -0,0 +1,10 @@
1
+ module OEXRWrapper
2
+ class Currency
3
+ attr_accessor :name, :code
4
+
5
+ def initialize(code, name)
6
+ @code = code
7
+ @name = name
8
+ end
9
+ end
10
+ end
@@ -13,7 +13,7 @@ module OEXRWrapper
13
13
  private
14
14
 
15
15
  def raise_response(response)
16
- case response
16
+ case response.status
17
17
  when 404
18
18
  raise Error, "Not found error."
19
19
  when 401
@@ -0,0 +1,18 @@
1
+ module OEXRWrapper
2
+ class CurrenciesResources < Resource
3
+ def retrieve
4
+ currency_array = Array.new
5
+ get_request('currencies').body.each do |currency|
6
+ currency_array.push(Currency.new(currency[0], currency[1]))
7
+ end
8
+
9
+ Currencies.new currency_array
10
+ end
11
+
12
+ def code_to_string(code)
13
+ get_request('currencies').body[String(code).upcase]
14
+ end
15
+
16
+ alias code_to_s code_to_string
17
+ end
18
+ end
@@ -1,14 +1,14 @@
1
1
  module OEXRWrapper
2
2
  class LatestResource < Resource
3
3
  def retrieve
4
- Latest.new get_request('latest').body.dig('rates')
4
+ Latest.new get_request('latest').body['rates']
5
5
  end
6
6
 
7
7
  def method_missing(symbol, *args)
8
8
  if symbol !~ /^[a-zA-Z]{3}$/
9
9
  super
10
10
  else
11
- get_request('latest').body.dig('rates')[symbol.to_s.upcase]
11
+ get_request('latest').body['rates'][symbol.to_s.upcase]
12
12
  end
13
13
  end
14
14
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OEXRWrapper
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/oexrwrapper.rb CHANGED
@@ -11,7 +11,10 @@ module OEXRWrapper
11
11
 
12
12
  # Resources
13
13
  autoload :LatestResource, "oexrwrapper/resources/latest"
14
+ autoload :CurrenciesResources, "oexrwrapper/resources/currencies"
14
15
 
15
16
  # Classes
16
17
  autoload :Latest, "oexrwrapper/objects/latest"
18
+ autoload :Currencies, "oexrwrapper/objects/currencies"
19
+ autoload :Currency, "oexrwrapper/objects/currency"
17
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oexrwrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lahiru Himesh Madusanka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-21 00:00:00.000000000 Z
11
+ date: 2022-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -44,8 +44,11 @@ files:
44
44
  - lib/oexrwrapper/client.rb
45
45
  - lib/oexrwrapper/error.rb
46
46
  - lib/oexrwrapper/object.rb
47
+ - lib/oexrwrapper/objects/currencies.rb
48
+ - lib/oexrwrapper/objects/currency.rb
47
49
  - lib/oexrwrapper/objects/latest.rb
48
50
  - lib/oexrwrapper/resource.rb
51
+ - lib/oexrwrapper/resources/currencies.rb
49
52
  - lib/oexrwrapper/resources/latest.rb
50
53
  - lib/oexrwrapper/version.rb
51
54
  - sig/oexrwrapper.rbs