exrt 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -13
- data/exrt.gemspec +1 -1
- data/lib/exrt.rb +11 -5
- data/lib/exrt/http.rb +9 -6
- data/lib/exrt/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 007bee7c3c946e8d6d80e97c4caaf7fb7a5c22198b409ea1f073c6484b8efa08
|
4
|
+
data.tar.gz: fba712eb6c422cbe1c8b250c107e3cf34cdae752a67f321c4fc38b773bab8ce4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a93425d499945ca878b61a88a2dc958f4edee779097f9f801334064644906a8ecc14c0ddb748a8fc824721c19e65ccdf83605b700b43056e6b6b7bc573cc013
|
7
|
+
data.tar.gz: de192a0e8fe93e6c810719ab734445e2a7fc9fe7a365ad03b61f71f19a0976df1aa0d4d340b1058a74bd4965ed49d1ba4d8b731427c8c923d8d780239a95d26d
|
data/README.md
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# Exrt
|
2
2
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/exrt`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
3
|
## Installation
|
8
4
|
|
9
5
|
Add this line to your application's Gemfile:
|
@@ -16,20 +12,14 @@ And then execute:
|
|
16
12
|
|
17
13
|
$ bundle
|
18
14
|
|
19
|
-
Or
|
15
|
+
Or just:
|
20
16
|
|
21
17
|
$ gem install exrt
|
22
18
|
|
23
19
|
## Usage
|
24
20
|
|
25
|
-
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
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.
|
30
|
-
|
31
|
-
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).
|
21
|
+
check [exrt-cli](https://github.com/al002/exrt-cli/) for usage example.
|
32
22
|
|
33
23
|
## Contributing
|
34
24
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
25
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/al002/exrt.
|
data/exrt.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
end
|
20
20
|
spec.bindir = "exe"
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = ["lib"
|
22
|
+
spec.require_paths = ["lib"]
|
23
23
|
|
24
24
|
spec.add_dependency "faraday", "~> 0.15"
|
25
25
|
|
data/lib/exrt.rb
CHANGED
@@ -1,25 +1,31 @@
|
|
1
|
+
require 'json'
|
1
2
|
require "exrt/version"
|
2
|
-
require
|
3
|
+
require 'exrt/http'
|
3
4
|
|
4
5
|
module Exrt
|
5
6
|
class Rate
|
6
7
|
def self.latest(base: "USD", symbols: [])
|
7
|
-
response = Http.get("/latest", { base: base, symbols: symbols_str(symbols) })
|
8
|
-
response.body
|
8
|
+
response = Exrt::Http.get("/latest", { base: base, symbols: symbols_str(symbols) })
|
9
|
+
to_json(response.body)
|
9
10
|
end
|
10
11
|
|
11
12
|
def self.history(base: "USD", symbols: [], start_at:, end_at:)
|
12
|
-
response = Http.get("/history", {
|
13
|
+
response = Exrt::Http.get("/history", {
|
13
14
|
base: base,
|
14
15
|
symbols: symbols_str(symbols),
|
15
16
|
start_at: start_at,
|
16
17
|
end_at: end_at,
|
17
18
|
})
|
18
|
-
response.body
|
19
|
+
to_json(response.body)
|
19
20
|
end
|
20
21
|
|
22
|
+
private
|
21
23
|
def self.symbols_str(symbols)
|
22
24
|
symbols.join(",")
|
23
25
|
end
|
26
|
+
|
27
|
+
def self.to_json(resp)
|
28
|
+
JSON.parse(resp)
|
29
|
+
end
|
24
30
|
end
|
25
31
|
end
|
data/lib/exrt/http.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
require "faraday"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Exrt
|
4
|
+
class Http
|
5
|
+
@@api_base = "https://api.exchangeratesapi.io"
|
6
|
+
@@conn = Faraday.new(:url => @@api_base)
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
public
|
9
|
+
def self.get(url, params ={})
|
10
|
+
@@conn.get(url, params)
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
14
|
+
|
data/lib/exrt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exrt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- al002
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -94,7 +94,6 @@ post_install_message:
|
|
94
94
|
rdoc_options: []
|
95
95
|
require_paths:
|
96
96
|
- lib
|
97
|
-
- "~/workspace/exrt/lib"
|
98
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
99
98
|
requirements:
|
100
99
|
- - ">="
|
@@ -106,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
105
|
- !ruby/object:Gem::Version
|
107
106
|
version: '0'
|
108
107
|
requirements: []
|
109
|
-
rubygems_version: 3.0.
|
108
|
+
rubygems_version: 3.0.2
|
110
109
|
signing_key:
|
111
110
|
specification_version: 4
|
112
111
|
summary: exchange rate library
|