currency_quote 0.1.1 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +51 -0
- data/Gemfile.lock +1 -1
- data/README.md +44 -2
- data/lib/currency_quote.rb +0 -3
- data/lib/currency_quote/currency.rb +17 -9
- data/lib/currency_quote/dolar.rb +7 -7
- 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: 05b59a0a6e0d996c10c78a563df3b1200a7b1f3e963b5bc3e1e00f10b41007f5
|
4
|
+
data.tar.gz: 257469dd947673467073115a40315e27220599955a10c1d071586edecfbef847
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39d79dee89f3968c51f0233102e7ab9318c04c4afaf1fc3fad860bbe71c39940cdeb4be53552c5927ead60e961232846363cd38855153ff37da155ba2fb81241
|
7
|
+
data.tar.gz: 2fcf7217d9fc20833e6978086b6b92759b7126db4aa07670f380c4084e3dd2d16ae33f25421eab677545688412911f017d3643456139166c0fc432b44047d0d4
|
data/.gitignore
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
/.bundle/
|
2
3
|
/.yardoc
|
3
4
|
/_yardoc/
|
@@ -9,3 +10,53 @@
|
|
9
10
|
|
10
11
|
# rspec failure tracking
|
11
12
|
.rspec_status
|
13
|
+
# These are some examples of commonly ignored file patterns.
|
14
|
+
# You should customize this list as applicable to your project.
|
15
|
+
# Learn more about .gitignore:
|
16
|
+
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
|
17
|
+
|
18
|
+
# Node artifact files
|
19
|
+
node_modules/
|
20
|
+
dist/
|
21
|
+
|
22
|
+
# Compiled Java class files
|
23
|
+
*.class
|
24
|
+
|
25
|
+
# Compiled Python bytecode
|
26
|
+
*.py[cod]
|
27
|
+
|
28
|
+
# Log files
|
29
|
+
*.log
|
30
|
+
|
31
|
+
# Package files
|
32
|
+
*.jar
|
33
|
+
|
34
|
+
# Maven
|
35
|
+
target/
|
36
|
+
dist/
|
37
|
+
|
38
|
+
# JetBrains IDE
|
39
|
+
.idea/
|
40
|
+
|
41
|
+
# Unit test reports
|
42
|
+
TEST*.xml
|
43
|
+
|
44
|
+
# Generated by MacOS
|
45
|
+
.DS_Store
|
46
|
+
|
47
|
+
# Generated by Windows
|
48
|
+
Thumbs.db
|
49
|
+
|
50
|
+
# Applications
|
51
|
+
*.app
|
52
|
+
*.exe
|
53
|
+
*.war
|
54
|
+
|
55
|
+
# Large media files
|
56
|
+
*.mp4
|
57
|
+
*.tiff
|
58
|
+
*.avi
|
59
|
+
*.flv
|
60
|
+
*.mov
|
61
|
+
*.wmv
|
62
|
+
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -22,8 +22,50 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
### Cotizaciones disponibles
|
26
|
+
Bolívar Venezolano,
|
27
|
+
Cordoba Nicaraguense,
|
28
|
+
Corona Checa,
|
29
|
+
Corona Danesa,
|
30
|
+
Corona Noruega,
|
31
|
+
Corona Sueca,
|
32
|
+
Derecho Especial de Giro,
|
33
|
+
Dinar Serbia,
|
34
|
+
Dolar Australiano,
|
35
|
+
Dolar Canadiense,
|
36
|
+
Dolar de Singapur,
|
37
|
+
Dolar Estadounidense,
|
38
|
+
Dolar Hong Kong,
|
39
|
+
Dolar Neozelandes,
|
40
|
+
Euro (Unidad Monetaria Europe,
|
41
|
+
Florin (Antillas Holandesas),
|
42
|
+
Franco Suizo,
|
43
|
+
Guaraní Paraguayo,
|
44
|
+
Libra Esterlina,
|
45
|
+
Lira Turca,
|
46
|
+
Nuevo Sol Peruano,
|
47
|
+
Oro - Onza Troy,
|
48
|
+
Peso,
|
49
|
+
Peso Boliviano,
|
50
|
+
Peso Chileno,
|
51
|
+
Peso Colombiano,
|
52
|
+
Peso Mexicano,
|
53
|
+
Peso Uruguayo,
|
54
|
+
Plata - Onza Troy,
|
55
|
+
Rand Sudafricano,
|
56
|
+
Real (Brasil),
|
57
|
+
Rublo (Rusia),
|
58
|
+
Rupia (India),
|
59
|
+
Shekel (Israel),
|
60
|
+
Yen (Japón),
|
61
|
+
Yuan- China CNY,
|
62
|
+
Yuan-China Off Shore CNH
|
63
|
+
|
64
|
+
### Obtener cotización
|
65
|
+
quotation = CurrencyQuote::Currency.new(currency: "Peso Colombiano", date: "13/11/2020").get_quotation
|
66
|
+
|
67
|
+
Devuelve
|
68
|
+
$ #<struct Struct::Currency currency="Peso Colombiano", date="13/11/2020", sell=0.023289999999999998, buy=0.021646>
|
27
69
|
## Development
|
28
70
|
|
29
71
|
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.
|
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
|
@@ -34,14 +38,18 @@ class CurrencyQuote::Currency
|
|
34
38
|
def get_currency_quotation
|
35
39
|
data = @doc.css("td").map(&:text).collect(&:strip!)
|
36
40
|
index = data.index(currency)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
if index
|
42
|
+
quote = data[index + 1].gsub(",", ".").to_f
|
43
|
+
quote = 1.0 if quote == 0
|
44
|
+
@sell = (dolar.sell * quote).to_f
|
45
|
+
@buy = (dolar.buy * quote).to_f
|
46
|
+
else
|
47
|
+
@sell = @buy = 0
|
48
|
+
end
|
41
49
|
end
|
42
50
|
|
43
51
|
def struct
|
44
|
-
s = Struct.new(
|
52
|
+
s = Struct.new(:currency, :date, :sell, :buy)
|
45
53
|
s.new(currency, date, sell, buy)
|
46
54
|
end
|
47
55
|
end
|
data/lib/currency_quote/dolar.rb
CHANGED
@@ -20,27 +20,27 @@ class CurrencyQuote::Dolar
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def make_get_to_bna
|
23
|
-
|
24
|
-
|
23
|
+
params = Addressable::URI.new
|
24
|
+
params.query_values = {
|
25
25
|
id: 'billetes',
|
26
26
|
fecha: date,
|
27
27
|
filtroEuro: 0,
|
28
28
|
filtroDolar: 1
|
29
29
|
}
|
30
|
-
url = "#{BASE_URL}?#{
|
30
|
+
url = "#{BASE_URL}?#{params.query}"
|
31
31
|
|
32
32
|
@doc = Nokogiri::HTML( URI.open(url) )
|
33
33
|
end
|
34
34
|
|
35
35
|
def extract_data
|
36
|
-
|
36
|
+
data = @doc.css("td").map(&:text)
|
37
37
|
@date = data[data.size - 1]
|
38
|
-
@sell = data[data.size - 2].to_f
|
39
|
-
@buy = data[data.size - 3].to_f
|
38
|
+
@sell = data[data.size - 2].gsub(",", ".").to_f
|
39
|
+
@buy = data[data.size - 3].gsub(",", ".").to_f
|
40
40
|
end
|
41
41
|
|
42
42
|
def struct
|
43
|
-
s = Struct.new(
|
43
|
+
s = Struct.new(:date, :sell, :buy)
|
44
44
|
s.new(date, sell, buy)
|
45
45
|
end
|
46
46
|
end
|
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.6
|
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