eba 1.0.0.1 → 1.0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71d4d45aff8d5cbe3dd24ff254ac58280b612663
4
- data.tar.gz: bd5077be7f5154ec19e85ffc6664c24911636ac5
3
+ metadata.gz: 7225cb1b71fcdb62cbfd263f43fa495e7c41dbd6
4
+ data.tar.gz: ae01f92abcff72673ac8ce2f61b338552b05b49a
5
5
  SHA512:
6
- metadata.gz: 738ce5f25715bfeb82839702b0e758cd7ff5a67a976c5cefba972c6c9cdc7899bea50e1ab29c695ff4e651b619e5630f5771cf79cc83791980b04d6d379762b8
7
- data.tar.gz: 3a6204920a4d53b8b5f343b7f10f028b30e1bb903bf0d07367bd15acc98edeaa8944f4933755e57cc16c92244cba511a1b32478e9a51eb4d75f4708723532886
6
+ metadata.gz: 5ab33001a3c7e74d5a7360a909d953c4be95c7ed5f9954b79f406ae3b63b0c7322e874b9fe8d640b00551284b3951b670461a8d7dbd051346ab3124a017cf740
7
+ data.tar.gz: 776d2d1b749b53c3bb540a2ee209d0b6ae4ff0ffc50a9f8188ba9160d924a7607e6a414d324414c55c45d6edc09fe3ef2d72a872c94062c1faf39b06647cb98b
Binary file
@@ -38,11 +38,15 @@ class BCB < Encoder
38
38
  # List of all operations available for the webservice,
39
39
  # useful for expanding the gem
40
40
  def list_operations()
41
- puts @service.operations
41
+ return @service.operations
42
42
  end
43
43
 
44
44
  def get_last_value(series_code)
45
- response = @service.call(:get_ultimo_valor_xml, message: {in0: "#{series_code}"})
45
+ begin
46
+ response = @service.call(:get_ultimo_valor_xml, message: {in0: "#{series_code}"})
47
+ rescue
48
+ return nil
49
+ end
46
50
  xmlResult = Nokogiri::XML(response.to_hash[:get_ultimo_valor_xml_response][:get_ultimo_valor_xml_return], nil, 'UTF-8')
47
51
 
48
52
  # As it's a brazillian database it's column identifications are in portuguese,
@@ -88,6 +92,7 @@ class BCB < Encoder
88
92
  results[code] = Nokogiri::XML(response.to_hash[:get_valores_series_xml_response] \
89
93
  [:get_valores_series_xml_return])
90
94
  rescue
95
+ results[code] = nil
91
96
  puts "Failure trying to extract #{code}"
92
97
  end
93
98
 
@@ -100,20 +105,21 @@ class BCB < Encoder
100
105
  # as series name, periodicity, etc.
101
106
  base_data = get_last_value(code)
102
107
 
103
-
104
- # Encode enforces data data is being read as UTF-8, as
105
- # portuguese uses a huge ammount of special characters and
106
- # accentuations.
107
- result.css("ITEM").each do |item|
108
- data_collection << DataBCB.new(encode(base_data.name),
109
- code,
110
- base_data.periodicity,
111
- encode(base_data.unit),
112
- "1",
113
- item.css("DATA").text.split("/")[0],
114
- item.css("DATA").text.split("/")[1],
115
- item.css("VALOR").text)
108
+ if result != nil then
109
+ # Encode enforces data data is being read as UTF-8, as
110
+ # portuguese uses a huge ammount of special characters and
111
+ # accentuations.
112
+ result.css("ITEM").each do |item|
113
+ data_collection << DataBCB.new(encode(base_data.name),
114
+ code,
115
+ base_data.periodicity,
116
+ encode(base_data.unit),
117
+ "1",
118
+ item.css("DATA").text.split("/")[0],
119
+ item.css("DATA").text.split("/")[1],
120
+ item.css("VALOR").text)
116
121
  end
122
+ end
117
123
  end
118
124
 
119
125
  return data_collection
@@ -6,12 +6,17 @@ module Eba
6
6
  # ff - commits on feature
7
7
  # hh - commits on hotfix
8
8
 
9
- VERSION = "1.0.0.1"
9
+ VERSION = "1.0.1.1"
10
10
 
11
11
  #Version 1.0.0.1
12
12
  #
13
13
  # Updater gemspec.
14
14
  # Added classes Encoder and DataBCB for user.
15
15
 
16
-
16
+ #Version 1.0.1.1
17
+ # List operations now returns a string instead of printing the methods of the webservice.
18
+ # get_last_value in BCB will return nil if the supplied code is invalid.
19
+ # get_all_data_for_array will now return data for an invalid code, but will still prompt an error mesage.
20
+ # added rspec tests, guarantying consistency
21
+ # spec/valid_certificate contains a certificate which is valid at this moment (2016-11-22)
17
22
  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.0.0.1
4
+ version: 1.0.1.1
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-11-21 00:00:00.000000000 Z
11
+ date: 2016-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -117,6 +117,7 @@ files:
117
117
  - bin/setup
118
118
  - eba.gemspec
119
119
  - lib/eba.rb
120
+ - lib/eba/.bcb.rb.swp
120
121
  - lib/eba/bcb.rb
121
122
  - lib/eba/data.rb
122
123
  - lib/eba/encoder.rb