Sha256: 00e72bc251c9583dc02ff1ceeea52c45eb26f8b69c83b0023d74c0d24e13473a
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
module WhosGotDirt module Responses module Entity # Converts entities from the LittleSis API to Popolo format. # # @see http://api.littlesis.org/documentation class LittleSis < Helpers::LittleSisHelper @count_field = 'Entities' @template = { '@type' => 'Entity', 'type' => '/primary_type', 'name' => '/name', 'description' => '/description', 'identifiers' => [{ 'identifier' => '/id', 'scheme' => 'LittleSis', }], 'links' => [{ 'url' => '/website', 'note' => 'Website', }, { 'url' => '/uri', 'note' => 'LittleSis page', }, { 'url' => '/api_uri', 'note' => 'LittleSis API detail', }], 'updated_at' => '/updated_at', # Class-specific. 'start_date' => lambda{|data| if JsonPointer.new(data, '/primary_type').value == 'Person' k = 'birth_date' else # 'Org' k = 'founding_date' end [k, JsonPointer.new(data, '/start_date').value] }, 'end_date' => lambda{|data| if JsonPointer.new(data, '/primary_type').value == 'Person' k = 'death_date' else # 'Org' k = 'dissolution_date' end [k, JsonPointer.new(data, '/end_date').value] }, 'parent_id' => '/parent_id', # API-specific. 'is_current' => '/is_current', 'summary' => '/summary', } # Transforms the parsed response body into results. # # @return [Array<Hash>] the results def to_a parsed_body['Data']['Entities']['Entity'].map do |data| Result.new('Entity', renderer.result(data), self).finalize! end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
whos_got_dirt-0.0.2 | lib/whos_got_dirt/responses/entity/little_sis.rb |