money-oxr 0.3.0 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.travis.yml +9 -3
- data/CHANGELOG.md +13 -1
- data/README.md +4 -2
- data/lib/money_oxr/rates_store.rb +12 -5
- data/money-oxr.gemspec +6 -6
- metadata +28 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8c3d339d52f62d327085b6505068bcfdc7a32af3f971bab5d65fbbc82535acbf
|
4
|
+
data.tar.gz: b95fcb453cc33b302daa061a929133197c89ccb1ff5539d5842a7867e54fb6f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77730e56a3c28b6c75d0fbc3f0a7dffcca953b15a72627e79817cd742ad537029896c4477b9b3832b7afdb7162cc5b9db098c970a64f7fc4d49f62013b4f2a6c
|
7
|
+
data.tar.gz: a455c71676ffa47bc74196b312f82cab46683ebaf2a1fb92b0c485ef8e8f3209b4c13833c1ac4e290819de2cfed331d069a1a1afcf94376bed8e400c6b00c3f7
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,19 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
|
5
5
|
[How to use a CHANGELOG](http://keepachangelog.com/)
|
6
6
|
|
7
|
-
## [
|
7
|
+
## [0.4.3]
|
8
|
+
- Replace `open` with `URI.open` for compatibility with ruby 3.
|
9
|
+
|
10
|
+
## [0.4.2]
|
11
|
+
- Update to Money 6.13.5
|
12
|
+
- Fix bugs related to webmock in specs.
|
13
|
+
|
14
|
+
## [0.4.1]
|
15
|
+
- Fix ruby 2.7 warnings.
|
16
|
+
|
17
|
+
## [0.4.0] - 2018-11-29
|
18
|
+
- Use `base` instead of `source` for base currency.
|
19
|
+
- Use Time.now as last_updated_at timestamp when fetching data over the API
|
8
20
|
|
9
21
|
## [0.3.0] - 2018-03-21
|
10
22
|
### Changed
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# money-oxr [![Build Status](https://travis-ci.org/edlebert/money-oxr.svg?branch=master)](https://travis-ci.org/edlebert/money-oxr)
|
2
2
|
|
3
3
|
A [Money](https://github.com/RubyMoney/money)-compatible rate store that uses exchange rates from openexchangerates.org.
|
4
4
|
|
@@ -68,7 +68,9 @@ Money.default_bank = MoneyOXR::Bank.new(
|
|
68
68
|
|
69
69
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
70
70
|
|
71
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
71
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
72
|
+
|
73
|
+
To release a new version, update the version number in `money-oxr.gemspec`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
72
74
|
|
73
75
|
## Contributing
|
74
76
|
|
@@ -35,7 +35,9 @@ module MoneyOXR
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def loaded?
|
38
|
-
|
38
|
+
transaction do
|
39
|
+
rates.any?
|
40
|
+
end
|
39
41
|
end
|
40
42
|
|
41
43
|
def load
|
@@ -55,6 +57,10 @@ module MoneyOXR
|
|
55
57
|
end
|
56
58
|
|
57
59
|
def load_from_api
|
60
|
+
# When loading from the API, set the last_updated_at to now.
|
61
|
+
# "timestamp" value in response may be days old (it may not update over
|
62
|
+
# the weekend)
|
63
|
+
now = Time.now
|
58
64
|
json = get_json_from_api
|
59
65
|
# Protect against saving or loading nil/bad data from API.
|
60
66
|
return unless json && json =~ /rates/
|
@@ -64,10 +70,11 @@ module MoneyOXR
|
|
64
70
|
else
|
65
71
|
load_json(json)
|
66
72
|
end
|
73
|
+
@last_updated_at = now
|
67
74
|
end
|
68
75
|
|
69
76
|
def get_json_from_api
|
70
|
-
open(api_uri).read
|
77
|
+
URI.open(api_uri).read
|
71
78
|
rescue OpenURI::HTTPError, SocketError
|
72
79
|
raise unless on_api_failure == :warn
|
73
80
|
warn "#{$!.class}: #{$!.message}"
|
@@ -75,7 +82,7 @@ module MoneyOXR
|
|
75
82
|
end
|
76
83
|
|
77
84
|
def api_uri
|
78
|
-
"https://openexchangerates.org/api/latest.json?
|
85
|
+
"https://openexchangerates.org/api/latest.json?base=#{source}&app_id=#{app_id}"
|
79
86
|
end
|
80
87
|
|
81
88
|
def load_from_cache_path
|
@@ -90,7 +97,7 @@ module MoneyOXR
|
|
90
97
|
data = parse_json(text)
|
91
98
|
transaction do
|
92
99
|
@last_updated_at = Time.at(data['timestamp'])
|
93
|
-
|
100
|
+
rates.clear
|
94
101
|
data['rates'].each do |iso_to, rate|
|
95
102
|
add_rate(source, iso_to, rate)
|
96
103
|
end
|
@@ -102,7 +109,7 @@ module MoneyOXR
|
|
102
109
|
text = text.gsub(/("[A-Z]{3}": ?)(\d+\.\d+)/, '\\1"\\2"')
|
103
110
|
data = JSON.parse(text)
|
104
111
|
data['rates'] = data['rates'].each_with_object({}) do |(key, value), rates|
|
105
|
-
rates[key] = BigDecimal
|
112
|
+
rates[key] = BigDecimal(value)
|
106
113
|
end
|
107
114
|
data
|
108
115
|
end
|
data/money-oxr.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "money-oxr"
|
5
|
-
spec.version = "0.3
|
5
|
+
spec.version = "0.4.3"
|
6
6
|
spec.authors = ["Ed Lebert"]
|
7
7
|
|
8
8
|
spec.summary = %q{A Money-compatible rate store that uses exchange rates from openexchangerates.org.}
|
@@ -14,10 +14,10 @@ Gem::Specification.new do |spec|
|
|
14
14
|
end
|
15
15
|
spec.require_paths = ["lib"]
|
16
16
|
|
17
|
-
spec.add_dependency "money", "
|
17
|
+
spec.add_dependency "money", ">= 6.13.5"
|
18
18
|
|
19
|
-
spec.add_development_dependency "bundler"
|
20
|
-
spec.add_development_dependency "rake"
|
21
|
-
spec.add_development_dependency "rspec"
|
22
|
-
spec.add_development_dependency "webmock"
|
19
|
+
spec.add_development_dependency "bundler"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
spec.add_development_dependency "rspec"
|
22
|
+
spec.add_development_dependency "webmock"
|
23
23
|
end
|
metadata
CHANGED
@@ -1,87 +1,87 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: money-oxr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ed Lebert
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: money
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 6.13.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 6.13.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
83
|
-
description:
|
84
|
-
email:
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
85
|
executables: []
|
86
86
|
extensions: []
|
87
87
|
extra_rdoc_files: []
|
@@ -103,7 +103,7 @@ homepage: https://github.com/edlebert/money-oxr
|
|
103
103
|
licenses:
|
104
104
|
- MIT
|
105
105
|
metadata: {}
|
106
|
-
post_install_message:
|
106
|
+
post_install_message:
|
107
107
|
rdoc_options: []
|
108
108
|
require_paths:
|
109
109
|
- lib
|
@@ -118,9 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
|
-
|
122
|
-
|
123
|
-
signing_key:
|
121
|
+
rubygems_version: 3.2.25
|
122
|
+
signing_key:
|
124
123
|
specification_version: 4
|
125
124
|
summary: A Money-compatible rate store that uses exchange rates from openexchangerates.org.
|
126
125
|
test_files: []
|