currency_quote 0.1.3 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c53cd739f292d46b462b70e99d93f3797f41df61758104293c77f4bf8573ffc
4
- data.tar.gz: 382045e0d812adeb655fe084bb13463c9f7bb688081ec406a91d98815f55b494
3
+ metadata.gz: a40c658e70dd631e2ebfe07cb250b1aee1917b65d152b76704f508877eee6413
4
+ data.tar.gz: eccea7c2458ad7f76686fb6b8e5c471c1cceb6fd57dbcbe537ee82f3c7da1408
5
5
  SHA512:
6
- metadata.gz: c4fc3365c86ac13ead56a1bf3dae0dc0a57072c7806ba23d2196ff5fa9165a8afcb70dd676789a0abb0d9b8d97ae86bf24b406fbca36efaf74453754c5a3d4a3
7
- data.tar.gz: '096fe84138e2fde1b9b082658d7c6748bd8ffa4602f3de6b7e56270e78a75ced9b513da9ff35ecbc9becaf5e6eddcb6952c8365338a216e3a40feedcaf71e5c0'
6
+ metadata.gz: f799969d09d60bd074429f6d5a91f7a8fda187d9f5c645e3e14f5950897651934ca0dc7ba50596c47a6c8b4f26a755d9b3088e71f471593e910f6345eb525502
7
+ data.tar.gz: c00160541e39ec418cea55f75024bc186591cced6f91fe77132ee825885a44b355319f25cf94d08e6a07645463c63b7438277cc0ec44aaef8a2a99b954d8f6ea
data/Gemfile CHANGED
@@ -7,3 +7,5 @@ gem "rake", "~> 12.0"
7
7
  gem "rspec", "~> 3.0"
8
8
 
9
9
  gem "nokogiri", "~> 1.10"
10
+
11
+ gem "addressable", "~> 2.7"
@@ -1,15 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- currency_quote (0.1.2)
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)
@@ -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
- get_dolar_quotation
18
- make_get_to_bcra
19
- get_currency_quotation
20
- return struct
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
@@ -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
- opts = {
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}?#{opts.to_param}"
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
@@ -1,3 +1,3 @@
1
1
  module CurrencyQuote
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.8"
3
3
  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.3
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-16 00:00:00.000000000 Z
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
@@ -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
@@ -1,8 +0,0 @@
1
- class String
2
- require "cgi"
3
-
4
- def to_query(key)
5
- "#{CGI.escape(key.to_s)}=#{CGI.escape(self)}"
6
- end
7
- alias_method :to_param, :to_query
8
- end
@@ -1,8 +0,0 @@
1
- class Symbol
2
- require "cgi"
3
-
4
- def to_query
5
- CGI.escape(self.to_s)
6
- end
7
- alias_method :to_param, :to_query
8
- end