Class: GovKit::TransparencyData::Categories

Inherits:
Object
  • Object
show all
Defined in:
lib/gov_kit/transparency_data.rb

Class Method Summary collapse

Class Method Details

.allObject

Contribution category code mapping table, in CSV format Returns an array of hashes, each with the following keys: :source, :code, :name, :industry, :order



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/gov_kit/transparency_data.rb', line 126

def self.all
  # This provides Ruby 1.8 & 1.9 CSV compatibility
  if CSV.const_defined? :Reader
    csv = FasterCSV
  else
    csv = CSV
  end
  categories = []
  open(GovKit::configuration.transparency_data_categories_url) do |f|
    csv.parse(f.read, :headers => true, :header_converters => :symbol) do |row|
     categories << row.to_hash
    end
  end
  categories
end