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

Commit

Permalink
Expose revision in sys data (#52)
Browse files Browse the repository at this point in the history
I need the ability to check if an entry is in draft e.g. revision is 0
and to display the revision number.

I noticed the API (and the contentful.rb gem) exposed it so wanted to
include it in the data import to Jekyll.
  • Loading branch information
benaldred authored and dlitvakb committed Aug 4, 2017
1 parent 4b3ca6f commit ab14b4f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
3 changes: 2 additions & 1 deletion lib/jekyll-contentful-data-import/mappers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def map_entry_metadata
'id' => entry.sys.fetch(:id, nil),
'created_at' => entry.sys.fetch(:created_at, nil),
'updated_at' => entry.sys.fetch(:updated_at, nil),
'content_type_id' => content_type.nil? ? nil : content_type.id
'content_type_id' => content_type.nil? ? nil : content_type.id,
'revision' => entry.sys.fetch(:revision, nil)
}
end

Expand Down
15 changes: 10 additions & 5 deletions spec/jekyll-contentful/mappers/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def initialize(id)
'id' => 'foo',
'created_at' => nil,
'updated_at' => nil,
'content_type_id' => 'content_type'
'content_type_id' => 'content_type',
'revision' => nil
}
}
expect(subject.map).to eq expected
Expand All @@ -109,7 +110,8 @@ def initialize(id)
'id' => 'foo',
'created_at' => nil,
'updated_at' => nil,
'content_type_id' => 'content_type'
'content_type_id' => 'content_type',
'revision' => nil
},
'asset' => {
'sys' => {
Expand All @@ -133,7 +135,8 @@ def initialize(id)
'id' => 'baz',
'created_at' => nil,
'updated_at' => nil,
'content_type_id' => 'content_type'
'content_type_id' => 'content_type',
'revision' => nil
},
},
'array' => [
Expand Down Expand Up @@ -164,7 +167,8 @@ def initialize(id)
'id' => 'foo',
'created_at' => nil,
'updated_at' => nil,
'content_type_id' => 'content_type'
'content_type_id' => 'content_type',
'revision' => nil
},
'foo' => {
'en-US' => 'bar',
Expand Down Expand Up @@ -201,7 +205,8 @@ def initialize(id)
'id' => 'foo',
'created_at' => nil,
'updated_at' => nil,
'content_type_id' => 'content_type'
'content_type_id' => 'content_type',
'revision' => nil
},
'asset' => {
"en-US" => {
Expand Down
18 changes: 12 additions & 6 deletions spec/jekyll-contentful/serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
'id' => 'foo',
'created_at' => nil,
'updated_at' => nil,
'content_type_id' => 'content_type'
'content_type_id' => 'content_type',
'revision' => nil
}
}
]
Expand All @@ -48,7 +49,8 @@
'id' => 'foo',
'created_at' => nil,
'updated_at' => nil,
'content_type_id' => 'content_type'
'content_type_id' => 'content_type',
'revision' => nil
},
'foobar' => 'bar'
}
Expand All @@ -73,14 +75,16 @@
'id' => 'foo',
'created_at' => nil,
'updated_at' => nil,
'content_type_id' => 'content_type'
'content_type_id' => 'content_type',
'revision' => nil
},
'foobar' => {
'sys' => {
'id' => 'foobar',
'created_at' => nil,
'updated_at' => nil,
'content_type_id' => 'content_type'
'content_type_id' => 'content_type',
'revision' => nil
},
'baz' => 1
}
Expand All @@ -103,7 +107,8 @@
'id' => 'foo',
'created_at' => nil,
'updated_at' => nil,
'content_type_id' => 'content_type'
'content_type_id' => 'content_type',
'revision' => nil
},
'foobar' => 'bar'
},
Expand All @@ -112,7 +117,8 @@
'id' => 'bar',
'created_at' => nil,
'updated_at' => nil,
'content_type_id' => 'content_type'
'content_type_id' => 'content_type',
'revision' => nil
},
'foobar' => 'baz'
}
Expand Down

0 comments on commit ab14b4f

Please sign in to comment.