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 +4 -4
- data/CHANGELOG.md +1 -1
- data/README.md +8 -5
- data/lib/dolarblue/configuration.rb +7 -0
- data/lib/dolarblue/exchange.rb +3 -3
- data/lib/dolarblue/instance_methods.rb +33 -4
- data/lib/dolarblue/version.rb +1 -1
- data/spec/dolarblue_spec.rb +14 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0e0e1e3e8e9d4f3ed37fcb0ed971b7274dea6b6
|
4
|
+
data.tar.gz: acc380a786ccbfd4b6f237b9fd3586d68c8f1453
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4162109567aacac67a32a9e6538f03281914f57920f966e5c28c6e122dae7275ecfbe4291c174693963a938e5a15af4dad7d301dc64bc234aeb6d60fc98cc1f0
|
7
|
+
data.tar.gz: df806af70e189d089105b04b385a9996a004faeb94e769f3e9b967c5a657cf417dc9f1b95b5782612b2650c23e78955df932a699e9882a9352289604242944b7
|
data/CHANGELOG.md
CHANGED
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
|
32
|
-
-
|
33
|
-
-
|
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
|
37
|
-
Blue
|
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
|
data/lib/dolarblue/exchange.rb
CHANGED
@@ -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 = '.' * (
|
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 = '.' * (
|
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
|
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
|
46
|
-
(
|
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
|
84
|
+
- Gap "tarjeta"..: #{gap_card_percent}%
|
85
|
+
- Gap (official).: #{gap_official_percent}%
|
57
86
|
|
58
87
|
Information sources:
|
59
88
|
#{@official.output_link}
|
data/lib/dolarblue/version.rb
CHANGED
data/spec/dolarblue_spec.rb
CHANGED
@@ -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.
|
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.
|
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
|
|