currency_quote 0.1.3 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +5 -1
- data/lib/currency_quote.rb +0 -3
- data/lib/currency_quote/currency.rb +9 -5
- data/lib/currency_quote/dolar.rb +6 -5
- data/lib/currency_quote/version.rb +1 -1
- metadata +2 -5
- data/lib/support/hash.rb +0 -12
- data/lib/support/string.rb +0 -8
- data/lib/support/symbol.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a40c658e70dd631e2ebfe07cb250b1aee1917b65d152b76704f508877eee6413
|
4
|
+
data.tar.gz: eccea7c2458ad7f76686fb6b8e5c471c1cceb6fd57dbcbe537ee82f3c7da1408
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f799969d09d60bd074429f6d5a91f7a8fda187d9f5c645e3e14f5950897651934ca0dc7ba50596c47a6c8b4f26a755d9b3088e71f471593e910f6345eb525502
|
7
|
+
data.tar.gz: c00160541e39ec418cea55f75024bc186591cced6f91fe77132ee825885a44b355319f25cf94d08e6a07645463c63b7438277cc0ec44aaef8a2a99b954d8f6ea
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
currency_quote (0.1.
|
4
|
+
currency_quote (0.1.7)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
addressable (2.7.0)
|
10
|
+
public_suffix (>= 2.0.2, < 5.0)
|
9
11
|
diff-lcs (1.4.4)
|
10
12
|
mini_portile2 (2.4.0)
|
11
13
|
nokogiri (1.10.10)
|
12
14
|
mini_portile2 (~> 2.4.0)
|
15
|
+
public_suffix (4.0.6)
|
13
16
|
rake (12.3.3)
|
14
17
|
rspec (3.10.0)
|
15
18
|
rspec-core (~> 3.10.0)
|
@@ -29,6 +32,7 @@ PLATFORMS
|
|
29
32
|
ruby
|
30
33
|
|
31
34
|
DEPENDENCIES
|
35
|
+
addressable (~> 2.7)
|
32
36
|
currency_quote!
|
33
37
|
nokogiri (~> 1.10)
|
34
38
|
rake (~> 12.0)
|
data/lib/currency_quote.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
require_relative "currency_quote/version"
|
2
2
|
require_relative "currency_quote/dolar"
|
3
3
|
require_relative "currency_quote/currency"
|
4
|
-
require_relative "support/hash.rb"
|
5
|
-
require_relative "support/string.rb"
|
6
|
-
require_relative "support/symbol.rb"
|
7
4
|
|
8
5
|
module CurrencyQuote
|
9
6
|
class Error < StandardError; end
|
@@ -14,10 +14,14 @@ class CurrencyQuote::Currency
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def get_quotation
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
if currency == "Dolar Estadounidense"
|
18
|
+
return get_dolar_quotation
|
19
|
+
else
|
20
|
+
get_dolar_quotation
|
21
|
+
make_get_to_bcra
|
22
|
+
get_currency_quotation
|
23
|
+
return struct
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
private
|
@@ -36,7 +40,7 @@ class CurrencyQuote::Currency
|
|
36
40
|
index = data.index(currency)
|
37
41
|
if index
|
38
42
|
quote = data[index + 1].gsub(",", ".").to_f
|
39
|
-
quote = 1 if quote == 0
|
43
|
+
quote = 1.0 if quote == 0
|
40
44
|
@sell = (dolar.sell * quote).to_f
|
41
45
|
@buy = (dolar.buy * quote).to_f
|
42
46
|
else
|
data/lib/currency_quote/dolar.rb
CHANGED
@@ -2,6 +2,7 @@ class CurrencyQuote::Dolar
|
|
2
2
|
require 'open-uri'
|
3
3
|
require 'nokogiri'
|
4
4
|
require 'date'
|
5
|
+
require "addressable/uri"
|
5
6
|
|
6
7
|
attr_accessor :date, :doc, :sell, :buy
|
7
8
|
|
@@ -20,14 +21,14 @@ class CurrencyQuote::Dolar
|
|
20
21
|
private
|
21
22
|
|
22
23
|
def make_get_to_bna
|
23
|
-
|
24
|
-
|
24
|
+
params = Addressable::URI.new
|
25
|
+
params.query_values = {
|
25
26
|
id: 'billetes',
|
26
27
|
fecha: date,
|
27
28
|
filtroEuro: 0,
|
28
29
|
filtroDolar: 1
|
29
30
|
}
|
30
|
-
url = "#{BASE_URL}?#{
|
31
|
+
url = "#{BASE_URL}?#{params.query}"
|
31
32
|
|
32
33
|
@doc = Nokogiri::HTML( URI.open(url) )
|
33
34
|
end
|
@@ -35,8 +36,8 @@ class CurrencyQuote::Dolar
|
|
35
36
|
def extract_data
|
36
37
|
data = @doc.css("td").map(&:text)
|
37
38
|
@date = data[data.size - 1]
|
38
|
-
@sell = data[data.size - 2].to_f
|
39
|
-
@buy = data[data.size - 3].to_f
|
39
|
+
@sell = data[data.size - 2].gsub(",", ".").to_f
|
40
|
+
@buy = data[data.size - 3].gsub(",", ".").to_f
|
40
41
|
end
|
41
42
|
|
42
43
|
def struct
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: currency_quote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Facundo A. Díaz Martínez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -34,9 +34,6 @@ files:
|
|
34
34
|
- lib/currency_quote/currency.rb
|
35
35
|
- lib/currency_quote/dolar.rb
|
36
36
|
- lib/currency_quote/version.rb
|
37
|
-
- lib/support/hash.rb
|
38
|
-
- lib/support/string.rb
|
39
|
-
- lib/support/symbol.rb
|
40
37
|
homepage: https://www.sesocio.com
|
41
38
|
licenses:
|
42
39
|
- MIT
|
data/lib/support/hash.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
|
3
|
-
def to_query(namespace = nil)
|
4
|
-
query = collect do |key, value|
|
5
|
-
value.to_s.to_query(namespace ? "#{namespace}[#{key}]" : key)
|
6
|
-
end.compact
|
7
|
-
|
8
|
-
query.sort! unless namespace.to_s.include?("[]")
|
9
|
-
query.join("&")
|
10
|
-
end
|
11
|
-
alias_method :to_param, :to_query
|
12
|
-
end
|
data/lib/support/string.rb
DELETED