dolarblue 0.1.0 → 0.2.0

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
  SHA1:
3
- metadata.gz: c9ae386656edae500a054d15ca7147b271c3ca77
4
- data.tar.gz: 0cd1a7ae029999db63984cf0a1f0927f82f94041
3
+ metadata.gz: a0e0e1e3e8e9d4f3ed37fcb0ed971b7274dea6b6
4
+ data.tar.gz: acc380a786ccbfd4b6f237b9fd3586d68c8f1453
5
5
  SHA512:
6
- metadata.gz: 42bd7e3a11d3e2ffb7b6112716feb86427c375a4311e9186ba1e30a8a49d8fe249189ce07c6e3f99d97bd02293499d24954468d284609ad1035769b5cad6812e
7
- data.tar.gz: 0fa7f6edf4e021a458253bf25477c555ad951fea6cd669e3d3940f96a4d0be0def9beadf611ba394cb7aecbced0180efebea2652cfb9e0df770bd7feaafc855d
6
+ metadata.gz: 4162109567aacac67a32a9e6538f03281914f57920f966e5c28c6e122dae7275ecfbe4291c174693963a938e5a15af4dad7d301dc64bc234aeb6d60fc98cc1f0
7
+ data.tar.gz: df806af70e189d089105b04b385a9996a004faeb94e769f3e9b967c5a657cf417dc9f1b95b5782612b2650c23e78955df932a699e9882a9352289604242944b7
data/CHANGELOG.md CHANGED
@@ -15,7 +15,7 @@
15
15
  * Added "dolar tarjeta" values for 20% government fees on AR credit cards. (Leo Gallucci)
16
16
 
17
17
  ### Bug Fixes
18
- * n/a
18
+ * Fixed 1 digit rounding to fill with 0. (Leo Gallucci)
19
19
 
20
20
  ### Chores
21
21
  * n/a
data/README.md CHANGED
@@ -28,13 +28,16 @@ Sample result:
28
28
 
29
29
  Obtaining latest AR$ vs US$ exchange values...Done.
30
30
 
31
- - Official: 5.01 / 5.06 (Updated 48 minutes and 43 seconds ago)
32
- - Blue....: 7.74 / 7.82 (Updated 4 hours and 27 minutes ago)
33
- - Gap.....: 55%
31
+ - Official.......: 5.05 / 5.10 (Updated 28 minutes ago)
32
+ - Dolar "Tarjeta": n/a / 6.12 (Updated 28 minutes ago)
33
+ - Blue...........: 7.97 / 8.05 (Updated 4 hours and 43 minutes ago)
34
+ - Gap "tarjeta"..: 32%
35
+ - Gap (official).: 58%
34
36
 
35
37
  Information sources:
36
- Official: https://twitter.com/cotizacionhoyar/status/309381355450560512
37
- Blue....: https://twitter.com/DolarBlue/status/309326405148233731
38
+ Official.......: https://twitter.com/cotizacionhoyar/status/313730158597120001
39
+ Blue...........: https://twitter.com/DolarBlue/status/313665928757927936
40
+
38
41
 
39
42
  ## Contributing
40
43
 
@@ -43,6 +43,13 @@ class Dolarblue
43
43
  def official_regexp
44
44
  /[Dd]olar: (\d+)[\.,](\d+)/
45
45
  end
46
+
47
+ # Dollar "tarjeta" AR fee on top of official value
48
+ #
49
+ # @return [Float] the dollar "tarjeta" AR fee to be applied, e.g. 1.2 for an extra 20% charge
50
+ def card_fee
51
+ 1.2
52
+ end
46
53
  end
47
54
 
48
55
  end
@@ -81,8 +81,8 @@ class Dolarblue
81
81
  # @return [String] output exchange values 1 line string
82
82
  def output_values
83
83
  ensure_valid
84
- dots = '.' * (8 - name.size).abs
85
- "- #{name}#{dots}: #{buy_value} / #{sell_value} (Updated #{updated_ago})"
84
+ dots = '.' * (15 - name.size).abs
85
+ "- #{name}#{dots}: #{'%.2f' %buy_value} / #{'%.2f' %sell_value} (Updated #{updated_ago})"
86
86
  end
87
87
 
88
88
  # Return a string suitable for user output with the link to the sources
@@ -90,7 +90,7 @@ class Dolarblue
90
90
  # @return [String] output links with sources from which the values where obtained
91
91
  def output_link
92
92
  ensure_valid
93
- dots = '.' * (8 - name.size).abs
93
+ dots = '.' * (15 - name.size).abs
94
94
  "#{name}#{dots}: #{source_url}"
95
95
  end
96
96
 
@@ -8,6 +8,7 @@ class Dolarblue
8
8
  # @return [Dolarblue] new instance
9
9
  def initialize(config = Configuration.instance)
10
10
  fail ArgumentError, "Expected a Dolarblue::Configuration instance as argument" unless config.is_a?(Configuration)
11
+ @card_fee = config.card_fee
11
12
  @blue = Dolarblue::Exchange.new('Blue', config.blue_screen_name, config.blue_regexp, config.buy_sell_factor)
12
13
  @official = Dolarblue::Exchange.new('Official', config.official_screen_name, config.official_regexp, config.buy_sell_factor)
13
14
  self
@@ -34,7 +35,7 @@ class Dolarblue
34
35
  # Returns the gap between the real (blue) dollar value versus the official
35
36
  #
36
37
  # @return [Float] percentile value between 0..1
37
- def gap
38
+ def gap_official
38
39
  fail "Need blue and official values to be setup before calculating the gap" unless @blue.sell_value && @blue.sell_value > 0 && @official.sell_value && @official.sell_value > 0
39
40
  (@blue.sell_value / @official.sell_value - 1)
40
41
  end
@@ -42,8 +43,34 @@ class Dolarblue
42
43
  # Returns the gap percentile between the real (blue) dollar value versus the official
43
44
  #
44
45
  # @return [Float] percentile value between 0..100
45
- def gap_percent
46
- (gap * 100).round(0)
46
+ def gap_official_percent
47
+ (gap_official * 100).round(0)
48
+ end
49
+
50
+ def card_fee_sell_value
51
+ (@official.sell_value * @card_fee).round(2)
52
+ end
53
+
54
+ # Returns the gap between the real (blue) dollar value versus the dollar "tarjeta" vale
55
+ #
56
+ # @return [Float] percentile value between 0..1
57
+ def gap_card
58
+ fail "Need blue and official values to be setup before calculating the gap" unless @blue.sell_value && @blue.sell_value > 0 && @official.sell_value && @official.sell_value > 0
59
+ (@blue.sell_value / card_fee_sell_value - 1)
60
+ end
61
+
62
+ # Returns the gap percentile between the real (blue) dollar value versus the official
63
+ #
64
+ # @return [Float] percentile value between 0..100
65
+ def gap_card_percent
66
+ (gap_card * 100).round(0)
67
+ end
68
+
69
+ # Return a string suitable for user output about dollar "tarjeta" values
70
+ #
71
+ # @return [String] output exchange values 1 line string
72
+ def card_output_values
73
+ %Q{- Dolar "Tarjeta": n/a / #{'%.2f' % card_fee_sell_value} (Updated #{@official.updated_ago})}
47
74
  end
48
75
 
49
76
  # Output string to be used by the binary `dolarblue`
@@ -52,8 +79,10 @@ class Dolarblue
52
79
  def output
53
80
  <<-OUTPUT
54
81
  #{@official.output_values}
82
+ #{card_output_values}
55
83
  #{@blue.output_values}
56
- - Gap.....: #{gap_percent}%
84
+ - Gap "tarjeta"..: #{gap_card_percent}%
85
+ - Gap (official).: #{gap_official_percent}%
57
86
 
58
87
  Information sources:
59
88
  #{@official.output_link}
@@ -1,3 +1,3 @@
1
1
  class Dolarblue
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -53,16 +53,25 @@ describe Dolarblue do
53
53
  describe '#output' do
54
54
  it 'has an output with real values' do
55
55
  subject.output.should match(/Blue/)
56
+ subject.output.should match(/Tarjeta/)
56
57
  end
57
58
  end
58
59
 
59
60
  describe 'gap values' do
60
- it 'has a valid gap value' do
61
- subject.gap.should be >= 0
61
+ it 'has a valid gap card value' do
62
+ subject.gap_card.should be >= 0
62
63
  end
63
64
 
64
- it 'has a valid gap % value' do
65
- subject.gap_percent.should be >= 0
65
+ it 'has a valid gap card % value' do
66
+ subject.gap_card_percent.should be >= 0
67
+ end
68
+
69
+ it 'has a valid gap official value' do
70
+ subject.gap_official.should be >= 0
71
+ end
72
+
73
+ it 'has a valid gap official % value' do
74
+ subject.gap_official_percent.should be >= 0
66
75
  end
67
76
  end
68
77
  end
@@ -76,6 +85,7 @@ describe Dolarblue do
76
85
  describe 'ClassMethods' do
77
86
  it 'has an get_output() class method to retrieve latest values' do
78
87
  Dolarblue.get_output.should match(/Blue/)
88
+ Dolarblue.get_output.should match(/Tarjeta/)
79
89
  end
80
90
  end
81
91
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dolarblue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo Gallucci