eia 1.1.4 → 1.2.5

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: 78e56f078ce2b8fa4d7f3f8713c445b541f17cea
4
- data.tar.gz: b910ec919b2afb31dfe25cce43b516343b4f6fd3
3
+ metadata.gz: 57da7351d5429bd4717f4a23b1dc368b077b1b5f
4
+ data.tar.gz: 3118696b19c2f10796286be0beedfbe804eecbf5
5
5
  SHA512:
6
- metadata.gz: 638f03d3aebcf0c8172aade71a8c66f5e36d5c7f07d626fbf4b22dc1c33246ba88539fb17f73f97a42fccf5b66ae1e94dc0510e0d1744032d5157f6530cd7603
7
- data.tar.gz: 8d9b12623b143a7df8480e26d9bbfb33188d2dba897ee0bd61e36e7c31180b9a17df9a1f15d9ac7720715a497eb09911ec558b0b7da2111421e49243b1c641f3
6
+ metadata.gz: 436af72e95d3a2efee71a95cbb4e1007fe26a357b0034b63cdca906111e5c9168ccb4a87ba256ec9783e4a02584cd76b6743b39615cc53cc356e41b1f8e26ea9
7
+ data.tar.gz: ad2411716c81fca684d6e39646ebaf8f0b4452abe80ff62949fbc564a0bc9a1bb5b739e3385483fcdb699981ea48d87a5b90209e367fa1df36cdd46a410979e5
data/lib/eia/data.rb CHANGED
@@ -1,10 +1,13 @@
1
1
  class DataIBGE
2
- def initialize(table_code, date, variable, location, product, unit, value, periodicity)
2
+ def initialize(table_code, date, variable, location, classification, unit, value, periodicity)
3
3
  @table_code = table_code
4
4
  @date = standardize_date(date, periodicity)
5
5
  @variable = variable
6
6
  @location = location
7
- @product = product
7
+
8
+ #is an array
9
+ @classification = classification
10
+
8
11
  @unit = unit
9
12
  @value = value
10
13
 
@@ -18,11 +21,11 @@ class DataIBGE
18
21
  #date is a four digit number
19
22
  if periodicity == 5 then
20
23
  return "01/01/#{date}"
21
- elsif periodicity == 4 then
24
+ elsif periodicity == 4 or periodicity == 3 then
22
25
  y = date[0..3]
23
26
  m = date[4..5]
24
27
 
25
- return "01/#{m}/#{y}"
28
+ return "01/#{m}/#{y}"
26
29
  else
27
30
  puts "\nError parsing date for DataIBGE. Attempted to parse #{date}.\n"
28
31
  return "ERROR"
@@ -45,8 +48,8 @@ class DataIBGE
45
48
  return @location
46
49
  end
47
50
 
48
- def product
49
- return @product
51
+ def classification
52
+ return @classification
50
53
  end
51
54
 
52
55
  def unit
@@ -97,6 +100,11 @@ class DataIBGE
97
100
  return false
98
101
  end
99
102
 
103
+ if @classification == nil or not @classification.class.to_s.eql? "Array" then
104
+ puts "Classification is invalid. Value is nil."
105
+ return false
106
+ end
107
+
100
108
  return true
101
109
  end
102
110
  end
data/lib/eia/ibge.rb CHANGED
@@ -65,12 +65,14 @@ class IBGE
65
65
  begin
66
66
  output = JSON.parse(json_string)
67
67
  heading = output.delete_at(0)
68
- identifier = heading["D1C"]
68
+ identifier = heading["D1N"]
69
69
 
70
70
  if identifier.include? "Trimestre Móvel" then
71
71
  periodicity = 4
72
72
  elsif identifier.include? "Ano" then
73
73
  periodicity = 5
74
+ elsif identifier.include? "Mês" then
75
+ periodicity = 2
74
76
  else
75
77
  puts "Error! Unexpected case! Found is: #{identifier}. Report to the dev team."
76
78
  return Array.new
@@ -82,7 +84,7 @@ class IBGE
82
84
  data = nil
83
85
  date = nil
84
86
  variable = nil
85
- product = nil
87
+ classification = Array.new
86
88
  location = nil
87
89
  unit = nil
88
90
  val = nil
@@ -95,18 +97,20 @@ class IBGE
95
97
  variable = value
96
98
  when "D3N" #location
97
99
  location = value
98
- when "D4N" #product
99
- product = value
100
100
  when "MN" #unit
101
101
  unit = value
102
102
  when "V" #value
103
103
  val = value.to_f
104
104
  else
105
- #This information is discarded
105
+ if key.include? "D" and key.include? "N" and key[1].to_i > 3 then
106
+ classification << "#{heading[key]}: #{value}"
107
+ end
108
+ #Else this information is discarded
106
109
  end
107
110
  end
108
111
 
109
- data_array << DataIBGE.new(table_code, date, variable, location, product, unit, val, periodicity)
112
+ data_array << DataIBGE.new(table_code, date, variable, location,
113
+ classification, unit, val, periodicity)
110
114
  end
111
115
 
112
116
  return data_array
data/lib/eia/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Eia
2
- VERSION = "1.1.4"
2
+ VERSION = "1.2.5"
3
3
 
4
4
  #Standard for version: xx.yy.zz
5
5
  # xx - release
@@ -39,4 +39,8 @@ module Eia
39
39
  # Adds getter for periodicity in data type, which I had forgot.
40
40
  # Also adds periodicity to integrity verification.
41
41
 
42
+ # Version 1.2.5
43
+ # Adds a new date classification for data.
44
+ # Renames procut as classification, as it's according what actual data in the source is like.
45
+ # Properly identifies classifications and stores then.
42
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - rCamposCruz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-14 00:00:00.000000000 Z
11
+ date: 2017-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement