Release 1.0.0

This commit is contained in:
Hakan Ensari 2017-12-31 16:25:15 +00:00
parent 74cdb1c2d4
commit cc47cff65f
10 changed files with 92 additions and 39 deletions

View File

@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.4
TargetRubyVersion: 2.5
Metrics/BlockLength:
Exclude:
- 'spec/**/*'

View File

@ -1,7 +1,7 @@
PATH
remote: .
specs:
fixer (0.7.0)
fixer (1.0.0)
GEM
remote: https://rubygems.org/
@ -13,26 +13,25 @@ GEM
safe_yaml (~> 1.0.0)
hashdiff (0.3.7)
minitest (5.10.3)
parallel (1.12.0)
parser (2.4.0.0)
ast (~> 2.2)
parallel (1.12.1)
parser (2.4.0.2)
ast (~> 2.3)
powerpack (0.1.1)
public_suffix (3.0.0)
rainbow (2.2.2)
rake
rake (10.5.0)
rubocop (0.51.0)
public_suffix (3.0.1)
rainbow (3.0.0)
rake (12.3.0)
rubocop (0.52.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
parser (>= 2.4.0.2, < 3.0)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 3.0)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
safe_yaml (1.0.4)
unicode-display_width (1.3.0)
vcr (3.0.3)
webmock (2.3.2)
vcr (4.0.0)
webmock (3.1.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
@ -41,13 +40,13 @@ PLATFORMS
ruby
DEPENDENCIES
bundler (~> 1.0)
bundler
fixer!
minitest (~> 5.0)
rake (~> 10.0)
minitest
rake
rubocop
vcr (~> 3.0)
webmock (~> 2.3)
vcr
webmock
BUNDLED WITH
1.16.0
1.16.1

View File

@ -1,3 +1,9 @@
# Fixer
Fixer wraps the XML feeds of Euro foreign exchange reference provided by the European Central Bank.
Fixer wraps the XML feeds of Euro foreign exchange reference provided by the European Central Bank:
```ruby
Fixer.current
Fixer.ninety_days
Fixer.historical
```

View File

@ -6,7 +6,7 @@ require 'rubocop/rake_task'
Rake::TestTask.new do |t|
t.ruby_opts += ['-W1']
t.pattern = 'spec/*_spec.rb'
t.pattern = 'spec/**/*_spec.rb'
end
RuboCop::RakeTask.new

View File

@ -14,13 +14,13 @@ Gem::Specification.new do |spec|
SUMMARY
spec.homepage = 'https://github.com/hakanensari/fixer'
spec.license = 'MIT'
spec.files = Dir.glob('lib/**/*') + %w[LICENSE README.md]
spec.files = Dir.glob('lib/**/*') + %w[README.md]
spec.require_paths = ['lib']
spec.add_development_dependency 'bundler', '~> 1.0'
spec.add_development_dependency 'minitest', '~> 5.0'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'minitest'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'vcr', '~> 3.0'
spec.add_development_dependency 'webmock', '~> 2.3'
spec.add_development_dependency 'vcr'
spec.add_development_dependency 'webmock'
end

View File

@ -1,3 +1,17 @@
# frozen_string_literal: true
require 'fixer/feed'
# ECB exchange rate datasets
#
# The three available short hands here are `.current`, `.ninety_days`, and
# `.historical`.
module Fixer
class << self
Feed::SCOPES.each_key do |scope|
define_method(scope) do
Feed.new(scope)
end
end
end
end

View File

@ -8,14 +8,14 @@ module Fixer
class Feed
include Enumerable
TYPES = {
SCOPES = {
current: 'daily',
ninety_days: 'hist-90d',
historical: 'hist'
}.freeze
def initialize(type = :current)
@type = TYPES.fetch(type) { raise ArgumentError }
def initialize(scope = :current)
@scope = SCOPES.fetch(scope) { raise ArgumentError }
end
def each
@ -42,7 +42,7 @@ module Fixer
end
def url
URI("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-#{@type}.xml")
URI("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-#{@scope}.xml")
end
end
end

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
module Fixer
VERSION = '0.7.0'
VERSION = '1.0.0'
end

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require_relative 'helper'
require_relative '../helper'
module Fixer
describe Feed do
@ -8,25 +8,25 @@ module Fixer
after { VCR.eject_cassette }
it 'parses the date of a currency' do
feed = Feed.new
feed = Feed.new(:current)
currency = feed.first
currency[:date].must_be_kind_of Date
end
it 'parse the ISO code of a currency' do
feed = Feed.new
feed = Feed.new(:current)
currency = feed.first
currency[:iso_code].must_be_kind_of String
end
it 'parses the rate of a currency' do
feed = Feed.new
feed = Feed.new(:current)
currency = feed.first
currency[:rate].must_be_kind_of Float
end
it 'fetches current rates' do
feed = Feed.new
feed = Feed.new(:current)
feed.count.must_be :<, 40
end
@ -40,7 +40,7 @@ module Fixer
feed.count.must_be :>, 33 * 3000
end
it 'raises error with invalid type' do
it 'raises error when scope is not valid' do
-> { Feed.new(:invalid) }.must_raise ArgumentError
end
end

34
gem/spec/fixer_spec.rb Normal file
View File

@ -0,0 +1,34 @@
# frozen_string_literal: true
require_relative 'helper'
describe Fixer do
before do
@mock = MiniTest::Mock.new
end
after do
@mock.verify
end
it 'returns current rates' do
@mock.expect(:call, nil, [:current])
Fixer::Feed.stub(:new, @mock) do
Fixer.current
end
end
it 'returns ninety-day rates' do
@mock.expect(:call, nil, [:ninety_days])
Fixer::Feed.stub(:new, @mock) do
Fixer.ninety_days
end
end
it 'returns historical rates' do
@mock.expect(:call, nil, [:historical])
Fixer::Feed.stub(:new, @mock) do
Fixer.historical
end
end
end