googleplus_markdown 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/googleplus_markdown.rb +27 -29
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a086f570759bcbf2c861786142a740c0bfc7199d
|
4
|
+
data.tar.gz: 3bb8a832dd19afb1ae101cf888f6d7c0f8e80e01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f233df432f7be94a08f86f0c703ce3b9419e3e2f219a06df76237fc046242ae1d3edaf50fc2c873efb17cc5fc3555c2fe7eeb8252042bf3d8a766c45d865d26
|
7
|
+
data.tar.gz: 99ddd43456e76f9d21a11d74208404b6de117681c6964071a0db69300aaf3a3254169cf9a9b9cc0c65af305ac4c2bd14d773377727a846ec0e874bd161fc1112
|
data/lib/googleplus_markdown.rb
CHANGED
@@ -9,36 +9,34 @@ require 'json'
|
|
9
9
|
class GooglePlusMarkdown
|
10
10
|
|
11
11
|
def convert(data)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
markdown.concat("#{attach_images(data)}\n")
|
32
|
-
|
33
|
-
# If anybody replied to these posts, let's retrieve the replies
|
34
|
-
# and tack them onto the end. Some of them are actually worth a damn.
|
35
|
-
replies = data['object']['replies']['items']
|
36
|
-
unless(replies == nil)
|
37
|
-
markdown.concat("#{retrieve_replies(replies)}")
|
38
|
-
end
|
12
|
+
# Let's declare the output string.
|
13
|
+
markdown = ""
|
14
|
+
|
15
|
+
# I need the creation date so I can set the file name.
|
16
|
+
# Of course, Google can't just call it a 'created' date.
|
17
|
+
date_created = data['published']
|
18
|
+
file_name = "#{date_created}.md"
|
19
|
+
|
20
|
+
# Instead of doing multiple writes to a file, I'm going to
|
21
|
+
# build a string that I can pass around to various functions.
|
22
|
+
# When I'm done, I'll write *that* to the file.
|
23
|
+
markdown.concat(generate_front_matter(data))
|
24
|
+
|
25
|
+
# I'm getting the raw text of the post, with Google+'s half-assed
|
26
|
+
# implementation of Textile for markup.
|
27
|
+
markdown.concat("#{retrieve_post_content(data)}\n\n")
|
28
|
+
|
29
|
+
# Let's get some photos tacked onto the end, shall we?
|
30
|
+
markdown.concat("#{attach_images(data)}\n")
|
39
31
|
|
40
|
-
|
32
|
+
# If anybody replied to these posts, let's retrieve the replies
|
33
|
+
# and tack them onto the end. Some of them are actually worth a damn.
|
34
|
+
replies = data['object']['replies']['items']
|
35
|
+
unless(replies == nil)
|
36
|
+
markdown.concat("#{retrieve_replies(replies)}")
|
41
37
|
end
|
38
|
+
|
39
|
+
handle_file_io(markdown, file_name)
|
42
40
|
end
|
43
41
|
|
44
42
|
private
|
@@ -153,7 +151,7 @@ class GooglePlusMarkdown
|
|
153
151
|
|
154
152
|
def retrieve_post_content(data)
|
155
153
|
post_content = data['object']['originalContent']
|
156
|
-
|
154
|
+
|
157
155
|
attachment = Hash.new
|
158
156
|
unless data['object']['attachments'] == nil
|
159
157
|
attachment = data['object']['attachments'][0]
|