ecb_exchange 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2691157f887f862fb2bcedf326175bb3778d45cbefc7d669d5b6b400e4d77470
4
- data.tar.gz: 651a99a0fde7e578018e7798c71b67d82b47e0bb6b76ee860c732e625f015883
3
+ metadata.gz: '0569c1270113499c32743bce9b846a4928a52389f678757789421b3f656609ba'
4
+ data.tar.gz: 283f20e271bbc1bfa5c39560b30d0f1d39b052775b556e9f7373a850b3307a60
5
5
  SHA512:
6
- metadata.gz: 3ed216084ec2aeddc7d67b2f20c6b45e39afaf74d20aa70e0656f7c939a491a298cbde0c63efad4605d5cb2f106665eeae9bc4b6f0d64ee72fd5f33c522a2612
7
- data.tar.gz: 698103784849f9d3a829352b0f60ac3f59fe757d58769a3eaf3175c039d2c05cc808c097b693bb82f3ae9cb82ef8f2a68dc2582d6cc63a3eab24adf64591e607
6
+ metadata.gz: 6921600dfcd10a823ca657979fa6462d4b33ef0cbbcfdac6211743554c0dc15ac06a21755f1a3e7c57cda86bac4fa90149ca72b32e4fbd9bcbefebc32392de34
7
+ data.tar.gz: 2d18faa58686485957e0a17e2a1bba8e6f124a518707f6f150258ec1f9e52208114bcc871ca090f0d8a8983ac476b0479ba9ef20e0d260b25fb5ef9510dd060d
data/.travis.yml CHANGED
@@ -2,16 +2,11 @@ sudo: false
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - 2.1.10
6
- - 2.2.9
7
- - 2.3.6
8
- - 2.4.3
9
- - 2.5.1
10
- - ruby-head
11
-
12
- before_install:
13
- - gem update --system
14
- - gem install bundler
5
+ - 2.3.8
6
+ - 2.4.6
7
+ - 2.5.5
8
+ - 2.6.3
9
+ - ruby-head
15
10
 
16
11
  matrix:
17
12
  allow_failures:
data/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@ adheres to [Semantic Versioning](Semver).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ - Your contribution here!
11
+
12
+ ## [0.2.0] - 2019-04-22
13
+ ### Changed
14
+ - Require at least Ruby 2.3 - earlier versions no longer supported.
15
+ ### Added
16
+ - `# frozen_string_literal: true` to all Ruby files.
17
+
10
18
  ## [0.1.2] - 2018-05-05
11
19
  ### Changed
12
20
  - Updated gemspec meta data links.
@@ -19,7 +27,8 @@ adheres to [Semantic Versioning](Semver).
19
27
  ### Added
20
28
  - Initial version released.
21
29
 
22
- [Unreleased]: https://github.com/matthutchinson/ecb_exchange/compare/v0.1.2...HEAD
30
+ [Unreleased]: https://github.com/matthutchinson/ecb_exchange/compare/v0.2.0...HEAD
31
+ [0.2.0]: https://github.com/matthutchinson/ecb_exchange/compare/v0.1.2...v0.2.0
23
32
  [0.1.2]: https://github.com/matthutchinson/ecb_exchange/compare/v0.1.1...v0.1.2
24
33
  [0.1.1]: https://github.com/matthutchinson/ecb_exchange/compare/v0.1.0...v0.1.1
25
34
  [0.1.0]: https://github.com/matthutchinson/ecb_exchange/compare/e7366b3...v0.1.0
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,24 +1,41 @@
1
- # Contributor Code of Conduct
1
+ # Contributor Covenant Code of Conduct
2
2
 
3
- As contributors and maintainers of this project, and in the interest of
4
- fostering an open and welcoming community, we pledge to respect all people who
5
- contribute through reporting issues, posting feature requests, updating
6
- documentation, submitting pull requests or patches, and other activities.
3
+ ## Our Pledge
7
4
 
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, ethnicity, age, religion, or nationality.
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ education, socio-economic status, nationality, personal appearance, race,
10
+ religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
12
22
 
13
23
  Examples of unacceptable behavior by participants include:
14
24
 
15
- * The use of sexualized language or imagery
16
- * Personal attacks
17
- * Trolling or insulting/derogatory comments
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
18
28
  * Public or private harassment
19
- * Publishing other's private information, such as physical or electronic
20
- addresses, without explicit permission
21
- * Other unethical or unprofessional conduct
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
22
39
 
23
40
  Project maintainers have the right and responsibility to remove, edit, or
24
41
  reject comments, commits, code, wiki edits, issues, and other contributions
@@ -26,24 +43,31 @@ that are not aligned to this Code of Conduct, or to ban temporarily or
26
43
  permanently any contributor for other behaviors that they deem inappropriate,
27
44
  threatening, offensive, or harmful.
28
45
 
29
- By adopting this Code of Conduct, project maintainers commit themselves to
30
- fairly and consistently applying these principles to every aspect of managing
31
- this project. Project maintainers who do not follow or enforce the Code of
32
- Conduct may be permanently removed from the project team.
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
33
54
 
34
- This code of conduct applies both within project spaces and in public spaces
35
- when an individual is representing the project or its community.
55
+ ## Enforcement
36
56
 
37
57
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at matt@hiddenloop.com. All
58
+ reported by contacting the project team at matt@hiddenloop.com. All
39
59
  complaints will be reviewed and investigated and will result in a response that
40
- is deemed necessary and appropriate to the circumstances. Maintainers are
41
- obligated to maintain confidentiality with regard to the reporter of an
42
- incident.
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
43
69
 
44
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
- version 1.3.0, available at
46
- [http://contributor-covenant.org/version/1/3/0/][version]
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
47
72
 
48
- [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/
73
+ [homepage]: https://www.contributor-covenant.org
data/CONTRIBUTING.md CHANGED
@@ -34,4 +34,3 @@ request gets accepted:
34
34
  * Write a good [commit
35
35
  message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
36
36
  * Write tests.
37
-
@@ -0,0 +1,16 @@
1
+
2
+ Explain what you're changing and why here.
3
+
4
+ ---
5
+ #### :memo: Checklist
6
+
7
+ Please check this list and leave it intact for the reviewer. Thanks! :heart:
8
+
9
+ - [ ] Commit messages provide context (why not just what, some tips [here](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)).
10
+ - [ ] If relevant, mention GitHub issue number above and include in a commit message.
11
+ - [ ] Latest code from master merged.
12
+ - [ ] New behaviour has test coverage.
13
+ - [ ] Avoid duplicating code.
14
+ - [ ] No commented out code.
15
+ - [ ] Avoid comments for your code, write code that explains itself.
16
+ - [ ] Changes are simple, useful, clear and brief.
data/README.md CHANGED
@@ -1,21 +1,21 @@
1
1
  # ECB Exchange
2
2
 
3
- [![Gem Version](https://img.shields.io/gem/v/ecb_exchange.svg?style=flat)](http://rubygems.org/gems/ecb_exchange)
4
- [![Travis Build Status](https://travis-ci.org/matthutchinson/ecb_exchange.svg?branch=master)](https://travis-ci.org/matthutchinson/ecb_exchange)
3
+ [![Gem](https://img.shields.io/gem/v/ecb_exchange.svg?style=flat)](http://rubygems.org/gems/ecb_exchange)
4
+ [![Travis](https://img.shields.io/travis/matthutchinson/ecb_exchange/master.svg?style=flat)](https://travis-ci.org/matthutchinson/ecb_exchange)
5
+ [![Depfu](https://img.shields.io/depfu/matthutchinson/ecb_exchange.svg?style=flat)](https://depfu.com/github/matthutchinson/ecb_exchange)
5
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/c67969dd7b921477bdcc/maintainability)](https://codeclimate.com/github/matthutchinson/ecb_exchange/maintainability)
6
7
  [![Test Coverage](https://api.codeclimate.com/v1/badges/c67969dd7b921477bdcc/test_coverage)](https://codeclimate.com/github/matthutchinson/ecb_exchange/test_coverage)
7
- [![Gem Dependency Status](https://gemnasium.com/badges/github.com/matthutchinson/ecb_exchange.svg)](https://gemnasium.com/github.com/matthutchinson/ecb_exchange)
8
8
 
9
9
  Currency conversion using the European Central Bank's foreign [exchange
10
10
  rates](http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml). Rates
11
11
  for the last 90 days are fetched and cached on demand. All calculations are
12
- performed and returned as `BigDecimal`, usually a [good
12
+ performed and returned as `BigDecimal` (usually a [good
13
13
  idea](https://makandracards.com/makandra/1178-bigdecimal-arithmetic-in-ruby)
14
- when dealing with money.
14
+ when dealing with money).
15
15
 
16
16
  ## Requirements
17
17
 
18
- * Ruby >= 2.1.0
18
+ * [Ruby](http://ruby-lang.org/) >= 2.3
19
19
 
20
20
  ## Installation
21
21
 
@@ -27,54 +27,53 @@ gem 'ecb_exchange'
27
27
 
28
28
  ## Usage
29
29
 
30
- To convert an amount from one currency to another use:
30
+ Convert an amount from one currency to another:
31
31
 
32
32
  ```ruby
33
33
  ECB::Exchange.convert(100, from: 'EUR', to: 'GBP')
34
34
  => 0.88235e2
35
35
  ```
36
36
 
37
- The converted amount (using today's current rate) will be returned (as a
38
- `BigDecimal`). In doing so the gem will have fetched and cached ECB rates for
39
- the last 90 days.
37
+ The converted amount (using today's current rate) will be returned as
38
+ `BigDecimal`. In doing this, the gem will fetch and cache ECB rates for the last
39
+ 90 days.
40
40
 
41
- You can ask the exchange to convert an amount on a specific date:
41
+ Convert an amount on a specific date:
42
42
 
43
43
  ```ruby
44
44
  ECB::Exchange.convert(100, from: 'EUR', to: 'GBP', date: Date.parse('2017-01-11'))
45
45
  => 0.87235e2
46
46
  ```
47
47
 
48
- To return only the exchange rate multiplier between two currencies use:
48
+ To fetch the exchange rate multiplier between two currencies:
49
49
 
50
50
  ```ruby
51
- ECB::Exchange.rate(from: 'EUR', to: 'USD')
51
+ ECB::Exchange.rate(from: 'EUR', to: 'USD') # pass an optional `date` arg here too
52
52
  => 0.11969e1
53
- # you can pass an optional `date` argument to this method too
54
53
  ```
55
54
 
56
- You can ask for an array of supported currency codes with:
55
+ You can ask for an array of all supported currencies with:
57
56
 
58
57
  ```ruby
59
58
  ECB::Exchange.currencies
60
59
  => ["USD", "JPY", "BGN", "CZK", "DKK", "GBP", "HUF" ... ]
61
60
  ```
62
61
 
63
- Finally, you can adjust the rates endpoint by setting the
62
+ Finally, you can adjust the rates endpoint by setting your own
64
63
  `XMLFeed.endpoint` (e.g. in an initializer):
65
64
 
66
65
  ```ruby
67
66
  ECB::Exchange::XMLFeed.endpoint = "http://my-awesome-service.com/feed.xml"
68
67
  ```
69
68
 
70
- The XML feed must conform to the [ECB
69
+ The XML feed at this endpoint must conform to the [ECB
71
70
  rates](http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml)
72
71
  structure.
73
72
 
74
73
  ## Handling Errors
75
74
 
76
75
  Not all dates, rates or currencies may be available, or the remote endpoint
77
- could be unresponsive. You should consider handling the following errors:
76
+ could be unresponsive. For these cases consider handling these errors:
78
77
 
79
78
  * `ECB::Exchange::DateNotFoundError`
80
79
  * `ECB::Exchange::CurrencyNotFoundError`
@@ -85,18 +84,18 @@ Or rescue `ECB::Exchange::Error` to catch any of them.
85
84
 
86
85
  ## Caching
87
86
 
88
- By default rates will be cached to one of the following backend stores (with
89
- this order of preference).
87
+ By default rates will be cached to one of the following backend stores (in this
88
+ order of preference).
90
89
 
91
90
  * Your own backend cache store (see below)
92
- * The `Rails.cache`
91
+ * `Rails.cache`
93
92
  * An `ECB::Exchange::MemoryCache` instance (a simple in memory cache store)
94
93
 
95
- To configure your own backend store:
94
+ To configure your own backend store (e.g. in an initializer):
96
95
 
97
96
  ```ruby
98
97
  ECB::Exchange::Cache.backend = MyAwesomeCache.new
99
- # your cache must implement public `read(key)` and `write(key, value)` methods
98
+ # this cache must implement public `read(key)` and `write(key, value)` methods
100
99
  ```
101
100
 
102
101
  All keys in the cache are name-spaced with a `ecb_exchange_rates_for_date-`
@@ -108,8 +107,8 @@ Check out this repo and run `bin/setup`, this will install gem dependencies and
108
107
  generate docs. Use `bundle exec rake` to run tests and generate a coverage
109
108
  report.
110
109
 
111
- You can also run `bin/console` for an interactive prompt allowing you to
112
- experiment with the code.
110
+ You can also run `bin/console` for an interactive prompt to experiment with the
111
+ code.
113
112
 
114
113
  ## Tests
115
114
 
@@ -146,12 +145,10 @@ Covenant](http://contributor-covenant.org) code of conduct. See
146
145
  [here](https://github.com/matthutchinson/ecb_exchange/blob/master/CODE_OF_CONDUCT.md)
147
146
  for more details.
148
147
 
149
-
150
148
  ## Todo
151
149
 
152
150
  * Better RDoc documentation.
153
- * A small Rails app to demo this gem, with a one-click heroku install.
154
- * Allow `Net::HTTP` to be swapped out for any another HTTP client.
151
+ * A Rails app to demo this gem (e.g. with a one-click Heroku install).
155
152
 
156
153
  ## License
157
154
 
@@ -160,11 +157,11 @@ The code is available as open source under the terms of
160
157
 
161
158
  ## Links
162
159
 
160
+ * [Gem](http://rubygems.org/gems/ecb_exchange)
163
161
  * [Travis CI](https://travis-ci.org/matthutchinson/ecb_exchange)
164
162
  * [Maintainability](https://codeclimate.com/github/matthutchinson/ecb_exchange/maintainability)
165
163
  * [Test Coverage](https://codeclimate.com/github/matthutchinson/ecb_exchange/test_coverage)
166
164
  * [RDoc](http://rdoc.info/projects/matthutchinson/ecb_exchange)
167
165
  * [Issues](http://github.com/matthutchinson/ecb_exchange/issues)
168
166
  * [Report a bug](http://github.com/matthutchinson/ecb_exchange/issues/new)
169
- * [Gem](http://rubygems.org/gems/ecb_exchange)
170
167
  * [GitHub](https://github.com/matthutchinson/ecb_exchange)
data/ecb_exchange.gemspec CHANGED
@@ -21,20 +21,13 @@ Gem::Specification.new do |spec|
21
21
  EOF
22
22
 
23
23
  spec.metadata = {
24
- "homepage_uri" => "https://github.com/matthutchinson/ecb_exchange",
25
- "changelog_uri" => "https://github.com/matthutchinson/ecb_exchange/blob/master/CHANGELOG.md",
26
- "source_code_uri" => "https://github.com/matthutchinson/ecb_exchange",
27
- "bug_tracker_uri" => "https://github.com/matthutchinson/ecb_exchange/issues",
24
+ "homepage_uri" => "https://github.com/matthutchinson/ecb_exchange",
25
+ "changelog_uri" => "https://github.com/matthutchinson/ecb_exchange/blob/master/CHANGELOG.md",
26
+ "source_code_uri" => "https://github.com/matthutchinson/ecb_exchange",
27
+ "bug_tracker_uri" => "https://github.com/matthutchinson/ecb_exchange/issues",
28
+ "allowed_push_host" => "https://rubygems.org"
28
29
  }
29
30
 
30
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the "allowed_push_host"
31
- # to allow pushing to a single host or delete this section to allow pushing to any host.
32
- if spec.respond_to?(:metadata)
33
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
34
- else
35
- raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
36
- end
37
-
38
31
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
39
32
  spec.test_files = `git ls-files -- {test}/*`.split("\n")
40
33
  spec.bindir = "bin"
@@ -46,7 +39,7 @@ Gem::Specification.new do |spec|
46
39
  spec.rdoc_options << "--title" << "ECB Exchange" << "--main" << "README.md" << "-ri"
47
40
 
48
41
  # non-gem dependecies
49
- spec.required_ruby_version = ">= 2.1.0"
42
+ spec.required_ruby_version = ">= 2.3"
50
43
 
51
44
  # dev gems
52
45
  spec.add_development_dependency "bundler"
data/lib/ecb/exchange.rb CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'date'
2
4
  require 'bigdecimal/util'
3
5
 
4
6
  module ECB
5
7
  module Exchange
6
- VERSION = "0.1.2".freeze
8
+ VERSION = "0.2.0".freeze
7
9
 
8
10
  def self.convert(amount, from:, to:, date: Date.today)
9
11
  amount.to_d * rate(from: from, to: to, date: date)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ECB
2
4
  module Exchange
3
5
  class Cache
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ECB
2
4
  module Exchange
3
5
  class Error < StandardError; end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ECB
2
4
  module Exchange
3
5
  class MemoryCache
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rexml/document"
2
4
  require "net/http"
3
5
  require "uri"
data/lib/ecb_exchange.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ecb/exchange'
2
4
  require 'ecb/exchange/xml_feed'
3
5
  require 'ecb/exchange/memory_cache'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecb_exchange
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Hutchinson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-05 00:00:00.000000000 Z
11
+ date: 2019-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,6 +128,7 @@ files:
128
128
  - CONTRIBUTING.md
129
129
  - Gemfile
130
130
  - LICENSE
131
+ - PULL_REQUEST_TEMPLATE.md
131
132
  - README.md
132
133
  - Rakefile
133
134
  - bin/console
@@ -161,15 +162,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
162
  requirements:
162
163
  - - ">="
163
164
  - !ruby/object:Gem::Version
164
- version: 2.1.0
165
+ version: '2.3'
165
166
  required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  requirements:
167
168
  - - ">="
168
169
  - !ruby/object:Gem::Version
169
170
  version: '0'
170
171
  requirements: []
171
- rubyforge_project:
172
- rubygems_version: 2.7.6
172
+ rubygems_version: 3.0.3
173
173
  signing_key:
174
174
  specification_version: 4
175
175
  summary: Currency conversion using the European Central Bank's foreign exchange rates.