simple_forex 0.1.0 → 0.1.1

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: 15bbf36ebf4a841feed8f60243b2b0d06abff9b144d60a372ab4df8a23195330
4
- data.tar.gz: 2b9837d7cb44e58381d023950a19e627f53a2a845d448e906c56363dc3c87a61
3
+ metadata.gz: f474511989432ae427e6107ca3470d42cc43b1d6876d72a66b8a0a18fd0e678f
4
+ data.tar.gz: fa0b99e28d57e2ee24b1a250164b3ff13550d9ef2524cc56b619acbbe941b9ac
5
5
  SHA512:
6
- metadata.gz: 9beb9be479dce8b19b36feb829f51838ce93bbf32478afb23284f9f7f905c369ba528730dd7a48c6560c0b488fa304cf88c5a87880f190b38029f92e4719b2a8
7
- data.tar.gz: 8e6e97c5374f5c493b7e951c6da47a123efa2e4fa070981261984e0f6d9c909ceff94804e9c87fd569cac435572d0020a6bdd77c58863960458b1d2f4851e6ec
6
+ metadata.gz: 556b50a43b7b13ae4a16a5dc92bf6c917aa61158729698bb3093917ab1163c497b3892571b394a9301cfecfd9ed7e6c391eb4d033c6ab9b42d8f5bd36be10098
7
+ data.tar.gz: e8038a1f63c9f0098aa47afbbf1d99b592b5c15bbbc134bc75a40fded711835104e0d6e45b9a8ef0303525e0ad960d4245fa4c25d8b2fe7a7fe04f67b303f71a
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- ## [Unreleased]
1
+
2
+
3
+ ## [0.1.1] - 2023-03-06
4
+
5
+ - Support for rails 6 credentials.yml.enc
2
6
 
3
7
  ## [0.1.0] - 2023-03-05
4
8
 
data/README.md CHANGED
@@ -44,8 +44,9 @@ rake db:migrate
44
44
  Get a [free API key](https://openexchangerates.org/signup/free), open credentials.yml (`EDITOR="vim" rails credentials:edit`) and add the API key to credentials.yml like so:
45
45
 
46
46
  ```
47
+ # config/credentials.yml.enc
47
48
  simple_forex:
48
- openexchangerates_key: 1234AB
49
+ openexchangerates_key: 1234abcd
49
50
  ```
50
51
 
51
52
  Then, run this to retrieve currencies in the currencies table:
@@ -54,10 +55,10 @@ Then, run this to retrieve currencies in the currencies table:
54
55
  rake simple_forex:fetch_rates
55
56
  ```
56
57
 
57
- Confirm it worked in the rails console with something like `Currency.last`.
58
+ View the exchange rate data in the rails console with `Currency.last`.
58
59
 
59
60
 
60
- ### Schedule it
61
+ ### Schedule task to update currencies
61
62
 
62
63
  **Optional**
63
64
 
@@ -70,21 +71,20 @@ Tip: open exchange rates's free API gives 1000 calls monthly, and there are ~700
70
71
 
71
72
  Convert currencies by calling
72
73
 
73
-
74
74
  ```ruby
75
75
  require 'simple_forex'
76
76
  convert(amount, from_currency, to_currency)
77
77
  ```
78
78
 
79
-
80
- ### Example
79
+ For example
81
80
 
82
81
  ```ruby
83
82
  require 'simple_forex'
84
83
  convert(100, 'USD', 'EUR')
85
- # => 89.0
84
+ # => 0.939717e2
86
85
  ```
87
86
 
87
+ Note the decimal value returned uses scientific notation, evidenced by the `e` in the decimal's representation.
88
88
 
89
89
 
90
90
  ## Development
@@ -40,10 +40,25 @@ namespace :simple_forex do
40
40
  # from = "AUDz"
41
41
  # error_message % {currency_code: from}
42
42
 
43
-
43
+
44
+
45
+ def get_key
46
+ # Get key
47
+ if Rails.version[0].to_i <= 6
48
+ # Works in rails 6
49
+ Rails.application.credentials.simple_forex[:openexchangerates_key]
50
+ elsif Rails.version[0].to_i >= 7
51
+ # Works for rails 7
52
+ Rails.application.credentials.simple_forex.openexchangerates_key
53
+ end
54
+ end
55
+
56
+
57
+
58
+
44
59
 
45
60
  begin
46
- openexchangerates_key = Rails.application.credentials.simple_forex.openexchangerates_key
61
+ get_key
47
62
  rescue => exception
48
63
  $stderr.puts "Error: #{exception} - \n\n" + error_message + "\n\n"
49
64
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleForex
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_forex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Condylios