lib/tumblr/post.rb in tumblr-rb-2.0.0 vs lib/tumblr/post.rb in tumblr-rb-2.1.0
- old
+ new
@@ -15,11 +15,11 @@
FIELDS = [
:blog_name, :id, :post_url, :type, :timestamp, :date, :format,
:reblog_key, :tags, :bookmarklet, :mobile, :source_url, :source_title,
:total_posts,
- :photos, :dialogue, :player # Post-specific response fields
+ :photos, :dialogue, :player, :text, :question, :asking_name, :asking_url # Post-specific response fields
]
# Some post types have several "body keys", which allow the YAML front-matter
# serialization to seem a bit more human. This separator separates those keys.
POST_BODY_SEPARATOR = "\n\n"
@@ -79,13 +79,16 @@
end
meta_data["type"] ||= infer_post_type_from_string(doc_body)
meta_data["format"] ||= "markdown"
post_type = get_post_type(meta_data["type"])
- post_body_parts = doc_body.split(POST_BODY_SEPARATOR)
-
- pairs = pair_post_body_types(post_type.post_body_keys, post_body_parts.dup)
+ pairs = if post_type.post_body_keys.length > 1
+ pair_post_body_types(post_type.post_body_keys, doc_body.split(POST_BODY_SEPARATOR).dup)
+ else
+ [[post_type.post_body_keys.first, doc_body]]
+ end
+
Hash[pairs].merge(meta_data)
end
# Pair the post body keys for a particular post type with a list of values.
# If the length list of values is greater than the list of keys, the last key
@@ -224,9 +227,13 @@
@format
end
def slug
@slug
+ end
+
+ def post_url
+ @post_url
end
# These are handy convenience methods.
def markdown?