currency_quote 0.1.6 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +7 -1
- data/currency_quote.gemspec +3 -1
- data/lib/currency_quote/currency.rb +10 -10
- data/lib/currency_quote/dolar.rb +2 -1
- data/lib/currency_quote/version.rb +1 -1
- metadata +31 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 403e17ea3aacaa228865ab8672a3187971105d9e9ca988ba872151078564896f
|
4
|
+
data.tar.gz: d8d0b773152e7fffe3013a56f70def54d2d3d6d2eb8959d3d1e07da73a91e5bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65ac6aa4c42c94321596240aacb69015e4e4f469c0e1246ef6f8fc342e256d2e6f63bc884fc4422aa3cf678b65f345e4d690bbae75c5fe460fb460ca3cdfbcce
|
7
|
+
data.tar.gz: 7a66cada67f6c9ae1369d8870afc650dc298b095a97efc349ebbc01b0c365138e8e402442b347afa9b72903b667119e3749a0ff1c8920ef669fa652fdfebd915
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
currency_quote (0.
|
4
|
+
currency_quote (0.2.0)
|
5
|
+
addressable
|
6
|
+
nokogiri
|
5
7
|
|
6
8
|
GEM
|
7
9
|
remote: https://rubygems.org/
|
8
10
|
specs:
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
9
13
|
diff-lcs (1.4.4)
|
10
14
|
mini_portile2 (2.4.0)
|
11
15
|
nokogiri (1.10.10)
|
12
16
|
mini_portile2 (~> 2.4.0)
|
17
|
+
public_suffix (4.0.6)
|
13
18
|
rake (12.3.3)
|
14
19
|
rspec (3.10.0)
|
15
20
|
rspec-core (~> 3.10.0)
|
@@ -29,6 +34,7 @@ PLATFORMS
|
|
29
34
|
ruby
|
30
35
|
|
31
36
|
DEPENDENCIES
|
37
|
+
addressable (~> 2.7)
|
32
38
|
currency_quote!
|
33
39
|
nokogiri (~> 1.10)
|
34
40
|
rake (~> 12.0)
|
data/currency_quote.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
#spec.description = %q{TODO: Write a longer description or delete this line.}
|
11
11
|
spec.homepage = "https://www.sesocio.com"
|
12
12
|
spec.license = "MIT"
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
14
14
|
|
15
15
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
16
16
|
|
@@ -26,4 +26,6 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.bindir = "exe"
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
|
+
spec.add_dependency 'nokogiri'
|
30
|
+
spec.add_dependency 'addressable'
|
29
31
|
end
|
@@ -3,7 +3,7 @@ class CurrencyQuote::Currency
|
|
3
3
|
require 'nokogiri'
|
4
4
|
require 'date'
|
5
5
|
|
6
|
-
attr_accessor :currency, :date, :dolar, :doc, :sell, :buy
|
6
|
+
attr_accessor :currency, :date, :dolar, :doc, :sell, :buy, :quote
|
7
7
|
|
8
8
|
BASE_URL = "https://www.bcra.gob.ar/publicacionesestadisticas/Cotizaciones_por_fecha_2.asp"
|
9
9
|
|
@@ -15,8 +15,7 @@ class CurrencyQuote::Currency
|
|
15
15
|
|
16
16
|
def get_quotation
|
17
17
|
if currency == "Dolar Estadounidense"
|
18
|
-
|
19
|
-
else
|
18
|
+
get_dolar_quotation
|
20
19
|
get_dolar_quotation
|
21
20
|
make_get_to_bcra
|
22
21
|
get_currency_quotation
|
@@ -32,24 +31,25 @@ class CurrencyQuote::Currency
|
|
32
31
|
|
33
32
|
def make_get_to_bcra
|
34
33
|
url = "#{BASE_URL}?date2=#{date}"
|
35
|
-
@doc = Nokogiri::HTML(
|
34
|
+
@doc = Nokogiri::HTML( open(url) )
|
36
35
|
end
|
37
36
|
|
38
37
|
def get_currency_quotation
|
39
38
|
data = @doc.css("td").map(&:text).collect(&:strip!)
|
40
39
|
index = data.index(currency)
|
41
40
|
if index
|
42
|
-
|
43
|
-
quote =
|
44
|
-
|
45
|
-
@
|
41
|
+
pass = data[index + 1].gsub(",", ".").to_f
|
42
|
+
@quote = data[index + 2].gsub(",", ".").to_f
|
43
|
+
pass = 1.0 if pass == 0
|
44
|
+
@sell = (dolar.sell * pass).to_f
|
45
|
+
@buy = (dolar.buy * pass).to_f
|
46
46
|
else
|
47
47
|
@sell = @buy = 0
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
def struct
|
52
|
-
s = Struct.new(:currency, :date, :sell, :buy)
|
53
|
-
s.new(currency, date, sell, buy)
|
52
|
+
s = Struct.new(:currency, :date, :sell, :buy, :quote)
|
53
|
+
s.new(currency, date, sell, buy, quote)
|
54
54
|
end
|
55
55
|
end
|
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
|
|
@@ -29,7 +30,7 @@ class CurrencyQuote::Dolar
|
|
29
30
|
}
|
30
31
|
url = "#{BASE_URL}?#{params.query}"
|
31
32
|
|
32
|
-
@doc = Nokogiri::HTML(
|
33
|
+
@doc = Nokogiri::HTML( open(url) )
|
33
34
|
end
|
34
35
|
|
35
36
|
def extract_data
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Facundo A. Díaz Martínez
|
@@ -9,7 +9,35 @@ autorequire:
|
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2020-11-17 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: addressable
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
description:
|
14
42
|
email:
|
15
43
|
- facundo.martinez@sesocio.com
|
@@ -48,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
48
76
|
requirements:
|
49
77
|
- - ">="
|
50
78
|
- !ruby/object:Gem::Version
|
51
|
-
version: 2.
|
79
|
+
version: 2.4.0
|
52
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
81
|
requirements:
|
54
82
|
- - ">="
|