Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Fix Location Serialization #44

Merged
merged 1 commit into from
Apr 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Change Log

## Unreleased
### Fixed
* Fixed wrong serialization for Location fields

## v1.5.0

Expand Down
9 changes: 4 additions & 5 deletions lib/jekyll-contentful-data-import/mappers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,10 @@ def map_entry(child)
end

def map_location(location)
result = {}
location.properties.each do |k, v|
result[k.to_s] = v
end
result
{
'lat' => location.latitude,
'lon' => location.longitude
}
end

def map_link(link)
Expand Down
6 changes: 2 additions & 4 deletions spec/jekyll-contentful/mappers/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ def fields(locale = nil)
end

class LocationDouble < Contentful::Location
attr_reader :lat, :lon

def initialize(lat, lon)
@lat = lat
@lon = lon
end

def properties
{ 'lat' => @lat, 'lon' => @lon }
end
end

class LinkDouble < Contentful::Link
Expand Down