eba 1.4.3 → 1.5.3
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/lib/eba/bcb.rb +50 -18
- data/lib/eba/data.rb +13 -3
- data/lib/eba/version.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55af898e71af162b85311da79aa89d7548475f16
|
4
|
+
data.tar.gz: 8d4c33a83231025fb5c94b6d70123db580f27619
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3451a3d6aadbae4f38a11b7292535ebf52829398a48cf94c26a4faf03df66d114069c8dde10fa6b03288d4e1c8de8c9de493d33eae90bddb72300abc25aeaf1c
|
7
|
+
data.tar.gz: 0ad0448c43666985704b8c8337ee07bf0e90ba551257caa0a83e96a650e16ce6262aa04ea29e7178d83e2114136afc221dd7f1ffbf1f437059587c2802ea3064
|
data/lib/eba/bcb.rb
CHANGED
@@ -34,8 +34,8 @@ class BCB < Encoder
|
|
34
34
|
|
35
35
|
|
36
36
|
@service = Savon.client({wsdl: "https://www3.bcb.gov.br/sgspub/JSP/sgsgeral/FachadaWSSGS.wsdl",
|
37
|
-
ssl_cert_file: @pub_key
|
38
|
-
|
37
|
+
ssl_cert_file: @pub_key,
|
38
|
+
headers: {'Accept-Encoding' => 'gzip, deflate'}})
|
39
39
|
end
|
40
40
|
|
41
41
|
# List of all operations available for the webservice,
|
@@ -76,6 +76,26 @@ class BCB < Encoder
|
|
76
76
|
return result
|
77
77
|
end
|
78
78
|
|
79
|
+
def build_bcb_data(name, code, periodicity, unit, day, month, year, value)
|
80
|
+
encoded_name = encode(name)
|
81
|
+
encoded_periodicity = encode(periodicity)
|
82
|
+
encoded_unit = encode(unit)
|
83
|
+
encoded_day = encode(day)
|
84
|
+
encoded_month = encode(month)
|
85
|
+
encoded_year = encode(year)
|
86
|
+
encoded_value = encode(value)
|
87
|
+
|
88
|
+
is_unseasoned = name.include? " - com ajuste sazonal"
|
89
|
+
|
90
|
+
if is_unseasoned then
|
91
|
+
name.slice! " - com ajuste sazonal"
|
92
|
+
end
|
93
|
+
|
94
|
+
return Data_bcb.new(encoded_name, code, encoded_periodicity,
|
95
|
+
encoded_unit, encoded_day, encoded_month,
|
96
|
+
encoded_year, encoded_value, is_unseasoned)
|
97
|
+
end
|
98
|
+
|
79
99
|
def get_last_value(series_code)
|
80
100
|
begin
|
81
101
|
response = @service.call(:get_ultimo_valor_xml, message: {in0: "#{series_code}"})
|
@@ -93,14 +113,14 @@ class BCB < Encoder
|
|
93
113
|
# MES = MONTH
|
94
114
|
# ANO = YEAR
|
95
115
|
# VALOR = VALUE
|
96
|
-
return
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
116
|
+
return build_bcb_data(xmlResult.search("NOME").text,
|
117
|
+
series_code,
|
118
|
+
xmlResult.search("PERIODICIDADE").text,
|
119
|
+
xmlResult.search("UNIDADE").text,
|
120
|
+
xmlResult.search("DIA").text,
|
121
|
+
xmlResult.search("MES").text,
|
122
|
+
xmlResult.search("ANO").text,
|
123
|
+
xmlResult.search("VALOR").text)
|
104
124
|
end
|
105
125
|
|
106
126
|
# Ensure that date is in the format dd/MM/YYY
|
@@ -151,14 +171,26 @@ class BCB < Encoder
|
|
151
171
|
|
152
172
|
if serie.inspect.include? comp
|
153
173
|
serie.css("ITEM").each do |item|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
174
|
+
dia = "1"
|
175
|
+
mes = "1"
|
176
|
+
ano = "1"
|
177
|
+
data = item.css("DATA").text.split("/")
|
178
|
+
|
179
|
+
if base_data.periodicity == 'D' then
|
180
|
+
dia = data[0]
|
181
|
+
mes = data[1]
|
182
|
+
ano = data[2]
|
183
|
+
else
|
184
|
+
mes = data[0]
|
185
|
+
ano = data[1]
|
186
|
+
end
|
187
|
+
|
188
|
+
data_collection << build_bcb_data(base_data.name,
|
189
|
+
array[i],
|
190
|
+
base_data.periodicity,
|
191
|
+
base_data.unit,
|
192
|
+
dia, mes, ano,
|
193
|
+
item.css("VALOR").text)
|
162
194
|
end
|
163
195
|
end
|
164
196
|
|
data/lib/eba/data.rb
CHANGED
@@ -8,11 +8,12 @@ class Data_bcb
|
|
8
8
|
@date = ""
|
9
9
|
@value = 0.0
|
10
10
|
@pk = 0
|
11
|
+
@seasonally_adjusted = false
|
11
12
|
|
12
13
|
# Initialization is expected to express the state of a single row of
|
13
14
|
# data inside the BCB's Database.
|
14
15
|
def initialize(series_name, series_code, series_periodicity, series_unit,
|
15
|
-
series_day, series_month, series_year, series_value)
|
16
|
+
series_day, series_month, series_year, series_value, seasonally_adjusted)
|
16
17
|
|
17
18
|
@name = series_name
|
18
19
|
@pk = series_code
|
@@ -20,6 +21,7 @@ class Data_bcb
|
|
20
21
|
@unit = series_unit
|
21
22
|
@date = standardizes_date(series_day, series_month, series_year)
|
22
23
|
@value = series_value.to_f
|
24
|
+
@seasonally_adjusted = seasonally_adjusted
|
23
25
|
end
|
24
26
|
|
25
27
|
# Return an "identification key" with data which should
|
@@ -56,6 +58,10 @@ class Data_bcb
|
|
56
58
|
return @value
|
57
59
|
end
|
58
60
|
|
61
|
+
def seasonally_adjusted
|
62
|
+
return @seasonally_adjusted
|
63
|
+
end
|
64
|
+
|
59
65
|
# The Webservice will always supply the date in three separate fields,
|
60
66
|
# this methods aim to convert it to a standard dd.mm.YYYY string.
|
61
67
|
def standardizes_date(day, month, year)
|
@@ -73,7 +79,11 @@ class Data_bcb
|
|
73
79
|
end
|
74
80
|
|
75
81
|
def print()
|
76
|
-
return "Name: #{@name}\
|
82
|
+
return "Name: #{@name}\n" +
|
83
|
+
"BCB Code: #{@pk}\n" +
|
84
|
+
"Periodicity: #{@periodicity}\n" +
|
85
|
+
"Unit: #{@unit} Seasonally Adjusted? #{@seasonally_adjusted ? 'YES' : 'NO'}\n" +
|
86
|
+
"Date: #{@date} Value: #{@value}\n"
|
77
87
|
end
|
78
88
|
|
79
89
|
# Simple comparission between two DataBCB objects.
|
@@ -81,6 +91,6 @@ class Data_bcb
|
|
81
91
|
return (@name == data_bcb.name and @pk == data_bcb.pk \
|
82
92
|
and @periodicity == data_bcb.periodicity \
|
83
93
|
and @unit == data_bcb.unit and @date == data_bcb.date \
|
84
|
-
and @value = data_bcb.value)
|
94
|
+
and @value = data_bcb.value and @seasonally_adjusted == data_bcb.seasonally_adjusted)
|
85
95
|
end
|
86
96
|
end
|
data/lib/eba/version.rb
CHANGED
@@ -5,7 +5,7 @@ module Eba
|
|
5
5
|
# ff - commits on feature
|
6
6
|
# hh - commits on hotfix
|
7
7
|
|
8
|
-
VERSION = "1.
|
8
|
+
VERSION = "1.5.3"
|
9
9
|
|
10
10
|
#Version 1.0.1
|
11
11
|
#
|
@@ -36,4 +36,8 @@ module Eba
|
|
36
36
|
|
37
37
|
#Version 1.4.3
|
38
38
|
# get_all_data_for_array now handles different periodicities for any ammount of codes.
|
39
|
+
|
40
|
+
#Version 1.5.3
|
41
|
+
# adds flag in data to mark seasonally adjusted data
|
42
|
+
# adds detection for seasonally adjusted data
|
39
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Campos Cruz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|