fixerio_client 0.1.3 → 0.1.4

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: 231d1216c9743fa2f35f40ef5fde662f1bbe5e59f4a00862dabd9247c43a9da4
4
- data.tar.gz: 9a14a225256e9f1d8a7ac7cac80aef7066b4dd3ea1321638ba2991c4d491ff62
3
+ metadata.gz: 99132c5efadcd16ae53bace1bdeef5cbaaa407ce13206e372b2558a3e604e0dc
4
+ data.tar.gz: 96bbcf9fea170f5918001052a37cc89c3f02c380a77df418d3a36493d7179d76
5
5
  SHA512:
6
- metadata.gz: 352fd8ead73f25aaca464550f0af14061210d8c5844c8d20b2854b79528c1050a6aed8912d713a204b8ffb711699700ae34e8aa3bbbbdc27e2766d8472bf4cd1
7
- data.tar.gz: d81d4a4c88149c3bc8a8f70067a4b3fe31c265ff230efe7df2389582856f8be2d3cb4331ed09df0588fc104791926aed958fa3affb54740af2dfb677d6ef4f4c
6
+ metadata.gz: 800d990c38e5e1caa3c2edf030172fcc11c4d3cc4912011ac9aca26c194098a7a746078dfb08ed2972294b94f2ec109dd7d15b5a6f5f0d43bb8205287a057def
7
+ data.tar.gz: 63c47632bba92b5e7d0aae2524e849b265104ee8bd02ac123a14eaf296122fbf8de01a9b5e3be2e66cc8d3577b0b81e7ff46739478024f101fdff01c4656cdda
data/.rspec_status CHANGED
@@ -0,0 +1,9 @@
1
+ example_id | status | run_time |
2
+ ---------------------------------------------------------- | ------ | --------------- |
3
+ ./spec/fixer/client/errors/invalid_response_spec.rb[1:1:1] | passed | 0.00038 seconds |
4
+ ./spec/fixer/client/http_client_spec.rb[1:1:1] | passed | 0.00009 seconds |
5
+ ./spec/fixer/client/http_client_spec.rb[1:1:2] | passed | 0.00007 seconds |
6
+ ./spec/fixer/client/http_client_spec.rb[1:2:1] | passed | 0.00008 seconds |
7
+ ./spec/fixer/client_spec.rb[1:1:1] | passed | 0.00642 seconds |
8
+ ./spec/fixer/client_spec.rb[1:1:2] | passed | 0.00091 seconds |
9
+ ./spec/fixer/client_spec.rb[1:2:1] | passed | 0.00015 seconds |
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=a1e3ce44025ce3a08c05fe12ac9adece58af49ca93790aa2d7f62e4daa453795
4
+ language: ruby
5
+ cache: bundler
6
+ rvm:
7
+ - 2.2.3
8
+ - 2.5.1
9
+ before_script:
10
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
11
+ - chmod +x ./cc-test-reporter
12
+ - ./cc-test-reporter before-build
13
+ scripts:
14
+ - bundle exec rspec spec
15
+ after_script:
16
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Gemfile.lock CHANGED
@@ -1,17 +1,34 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fixerio_client (0.1.3)
4
+ fixerio_client (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ addressable (2.5.2)
10
+ public_suffix (>= 2.0.2, < 4.0)
11
+ ansi (1.5.0)
12
+ ast (2.4.0)
9
13
  coderay (1.1.2)
14
+ crack (0.4.3)
15
+ safe_yaml (~> 1.0.0)
10
16
  diff-lcs (1.3)
17
+ docile (1.3.1)
18
+ hashdiff (0.3.7)
19
+ hirb (0.7.3)
20
+ jaro_winkler (1.5.1)
21
+ json (2.1.0)
11
22
  method_source (0.9.0)
23
+ parallel (1.12.1)
24
+ parser (2.5.1.2)
25
+ ast (~> 2.4.0)
26
+ powerpack (0.1.2)
12
27
  pry (0.11.3)
13
28
  coderay (~> 1.1.0)
14
29
  method_source (~> 0.9.0)
30
+ public_suffix (3.0.3)
31
+ rainbow (3.0.0)
15
32
  rake (10.5.0)
16
33
  rspec (3.8.0)
17
34
  rspec-core (~> 3.8.0)
@@ -26,6 +43,33 @@ GEM
26
43
  diff-lcs (>= 1.2.0, < 2.0)
27
44
  rspec-support (~> 3.8.0)
28
45
  rspec-support (3.8.0)
46
+ rubocop (0.59.2)
47
+ jaro_winkler (~> 1.5.1)
48
+ parallel (~> 1.10)
49
+ parser (>= 2.5, != 2.5.1.1)
50
+ powerpack (~> 0.1)
51
+ rainbow (>= 2.2.2, < 4.0)
52
+ ruby-progressbar (~> 1.7)
53
+ unicode-display_width (~> 1.0, >= 1.0.1)
54
+ ruby-progressbar (1.10.0)
55
+ safe_yaml (1.0.4)
56
+ simplecov (0.16.1)
57
+ docile (~> 1.1)
58
+ json (>= 1.8, < 3)
59
+ simplecov-html (~> 0.10.0)
60
+ simplecov-cobertura (1.3.0)
61
+ simplecov (~> 0.8)
62
+ simplecov-console (0.4.2)
63
+ ansi
64
+ hirb
65
+ simplecov
66
+ simplecov-html (0.10.2)
67
+ unicode-display_width (1.4.0)
68
+ vcr (4.0.0)
69
+ webmock (3.4.2)
70
+ addressable (>= 2.3.6)
71
+ crack (>= 0.3.2)
72
+ hashdiff
29
73
 
30
74
  PLATFORMS
31
75
  ruby
@@ -36,6 +80,11 @@ DEPENDENCIES
36
80
  pry (~> 0.11.0)
37
81
  rake (~> 10.0)
38
82
  rspec (~> 3.0)
83
+ rubocop (~> 0.59.0)
84
+ simplecov-cobertura (~> 1.3.0)
85
+ simplecov-console (~> 0.4.0)
86
+ vcr (~> 4.0.0)
87
+ webmock (~> 3.4.2)
39
88
 
40
89
  BUNDLED WITH
41
90
  1.16.2
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Fixer::Client
2
2
 
3
+ [![Build Status](https://travis-ci.org/grzegorzblaszczyk/fixerio-client.svg?branch=master)](https://travis-ci.org/grzegorzblaszczyk/fixerio-client)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/beca7c860bad3aaed7ef/maintainability)](https://codeclimate.com/github/grzegorzblaszczyk/fixerio-client/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/beca7c860bad3aaed7ef/test_coverage)](https://codeclimate.com/github/grzegorzblaszczyk/fixerio-client/test_coverage)
6
+
3
7
  Get latest or historic currency rates for base EUR from api.fixer.io
4
8
 
5
9
  To experiment with our code, run `bin/console` for an interactive prompt.
@@ -39,6 +43,16 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
39
43
 
40
44
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, 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).
41
45
 
46
+ ## Testing
47
+
48
+ By default all requests to api.fixer.io are stubbed and VCR gem is used to replay HTTP responses.
49
+ If you want to send real requests, please copy `config/fixerio_client.yml.sample` to `config/fixerio_client.yml` and put your real API key there.
50
+ Then run:
51
+
52
+ ```
53
+ VCR_OFF=1 rspec spec
54
+ ```
55
+
42
56
  ## Contributing
43
57
 
44
58
  Bug reports and pull requests are welcome on GitHub at https://github.com/grzegorzblaszczyk/fixerio-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -3,4 +3,4 @@
3
3
  # Usage of Fixer.io API requires a key
4
4
  api_key: 'some_api_key'
5
5
 
6
- enabled_environments: ['production', 'deelopment', 'test']
6
+ enabled_environments: ['production', 'development', 'test']
@@ -27,4 +27,9 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "pry", "~> 0.11.0"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency "rubocop", "~> 0.59.0"
31
+ spec.add_development_dependency "simplecov-console", "~> 0.4.0"
32
+ spec.add_development_dependency "simplecov-cobertura", "~> 1.3.0"
33
+ spec.add_development_dependency "vcr", "~> 4.0.0"
34
+ spec.add_development_dependency "webmock", "~> 3.4.2"
30
35
  end
@@ -1,31 +1,26 @@
1
1
  require "net/http"
2
2
  require "json"
3
3
  require "pry"
4
- require "fixer/client/errors/invalid_response.rb"
4
+ require "fixer/client/errors/invalid_response"
5
5
  require "yaml"
6
6
 
7
7
  module Fixer
8
8
  module Client
9
9
  class HttpClient
10
10
 
11
- BASE_URI = "http://data.fixer.io/api"
11
+ BASE_URI = "http://data.fixer.io/api".freeze
12
12
  SCOPES = [
13
13
  :latest,
14
14
  :historical
15
15
  ].freeze
16
+
17
+ CONFIG_FILE = "config/fixerio_client.yml".freeze
16
18
 
17
19
  def initialize(scope = :latest)
18
20
  raise ::ArgumentError.new unless SCOPES.include?(scope)
19
- @scope = scope
20
-
21
- @config = YAML.load_file("config/fixerio_client.yml")
22
-
23
- @api_key = nil
24
- if Kernel.const_defined?("Rails") && !Rails.env.nil? && @config["enabled_environments"].include?(Rails.env)
25
- @api_key = @config["api_key"]
26
- else
27
- @api_key = @config["api_key"]
28
- end
21
+ @scope = scope
22
+ @config = read_config
23
+ @api_key = get_api_key
29
24
  end
30
25
 
31
26
  def fetch(symbols = [], date = nil)
@@ -54,6 +49,23 @@ module Fixer
54
49
  raise ::ArgumentError.new("Not implemented yet!")
55
50
  end
56
51
  end
52
+
53
+ def read_config
54
+ File.exist?(CONFIG_FILE) ? YAML.load_file(CONFIG_FILE) : default_config
55
+ end
56
+
57
+ def default_config
58
+ hash = {}
59
+ hash["api_key"] = 'invalid_key'
60
+ hash["enabled_environments"] = ['production', 'development', 'test']
61
+ hash
62
+ end
63
+
64
+ def get_api_key
65
+ return nil if Kernel.const_defined?("Rails") && !Rails.env.nil? && !@config["enabled_environments"].include?(Rails.env)
66
+ return nil if @config.nil?
67
+ @config["api_key"]
68
+ end
57
69
  end
58
70
  end
59
71
  end
@@ -1,5 +1,5 @@
1
1
  module Fixer
2
2
  module Client
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
@@ -0,0 +1 @@
1
+ require "fixer/client"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixerio_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grzegorz Błaszczyk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-30 00:00:00.000000000 Z
11
+ date: 2018-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,76 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.59.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.59.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov-console
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.4.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.4.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov-cobertura
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.3.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.3.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: vcr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 4.0.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 4.0.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 3.4.2
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 3.4.2
69
139
  description: Get latest or historic currency rates for base EUR from api.fixer.io
70
140
  email:
71
141
  - grzegorz.blaszczyk@gmail.com
@@ -77,6 +147,7 @@ files:
77
147
  - ".rspec_status"
78
148
  - ".ruby-gemset"
79
149
  - ".ruby-version"
150
+ - ".travis.yml"
80
151
  - CODE_OF_CONDUCT.md
81
152
  - Gemfile
82
153
  - Gemfile.lock
@@ -91,6 +162,7 @@ files:
91
162
  - lib/fixer/client/errors/invalid_response.rb
92
163
  - lib/fixer/client/http_client.rb
93
164
  - lib/fixer/client/version.rb
165
+ - lib/fixerio_client.rb
94
166
  homepage: https://github.com/grzegorzblaszczyk/fixerio-client
95
167
  licenses:
96
168
  - MIT