planet 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/planet/blog.rb +29 -12
- data/lib/planet/post.rb +13 -8
- data/lib/planet/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a452a7fa90ffe5f8068a88ac07983ee2ce13a3b5
|
4
|
+
data.tar.gz: db39ed053a48787f6057462204c267778d32f1b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49068d50bc0f7afdb365d42a5f273aa35efcce2e6476b2f35596ef5f6adcbb19357aeb75a9bb05d13c222d8b5403e1b7c572c65eda2d3e33d156a38502ad8ede
|
7
|
+
data.tar.gz: d10d441aadc823b766e1d295f6ae68b0caf78dd134fd4c6a45ade0ce86da08e7e954ebc226943eb00cba3a57b6c3903b8a869a60946bb58a5ec92575768ce470
|
data/lib/planet/blog.rb
CHANGED
@@ -4,18 +4,32 @@ require 'planet/parsers'
|
|
4
4
|
class Planet
|
5
5
|
class Blog
|
6
6
|
|
7
|
-
attr_accessor :url,
|
7
|
+
attr_accessor :url,
|
8
|
+
:feed,
|
9
|
+
:type,
|
10
|
+
:name,
|
11
|
+
:author,
|
12
|
+
:image,
|
13
|
+
:twitter,
|
14
|
+
:posts,
|
15
|
+
:planet,
|
16
|
+
:rss_data
|
8
17
|
|
9
18
|
def initialize(attributes = {})
|
10
|
-
self.url
|
11
|
-
self.feed
|
12
|
-
self.type
|
13
|
-
self.name
|
14
|
-
self.author
|
15
|
-
self.image
|
16
|
-
self.twitter
|
17
|
-
self.posts
|
18
|
-
self.planet
|
19
|
+
self.url = attributes[:url]
|
20
|
+
self.feed = attributes[:feed]
|
21
|
+
self.type = attributes[:type]
|
22
|
+
self.name = attributes[:name]
|
23
|
+
self.author = attributes[:author]
|
24
|
+
self.image = attributes[:image]
|
25
|
+
self.twitter = attributes[:twitter]
|
26
|
+
self.posts = attributes.fetch(:posts, [])
|
27
|
+
self.planet = attributes[:planet]
|
28
|
+
|
29
|
+
# Feedzirra parsed data is made available for when the information
|
30
|
+
# provides is not enough. Transparency should help use cases we're
|
31
|
+
# not considering.
|
32
|
+
self.rss_data = nil
|
19
33
|
|
20
34
|
# get parser-manager instance
|
21
35
|
@parsers = Parsers.new
|
@@ -33,12 +47,14 @@ class Planet
|
|
33
47
|
|
34
48
|
def on_fetch_success(feed)
|
35
49
|
self.name ||= feed.title || 'the source'
|
36
|
-
self.url
|
50
|
+
self.url ||= feed.url
|
37
51
|
|
38
52
|
if self.url.nil?
|
39
53
|
abort "#{ self.author }'s blog does not have a url field on it's feed, you will need to specify it on planet.yml"
|
40
54
|
end
|
41
55
|
|
56
|
+
self.rss_data = feed
|
57
|
+
|
42
58
|
feed.entries.each do |entry|
|
43
59
|
next unless whitelisted?(entry)
|
44
60
|
content = if entry.content
|
@@ -54,7 +70,8 @@ class Planet
|
|
54
70
|
content: content,
|
55
71
|
date: entry.published,
|
56
72
|
url: entry.url,
|
57
|
-
blog: self
|
73
|
+
blog: self,
|
74
|
+
rss_data: entry
|
58
75
|
)
|
59
76
|
|
60
77
|
puts "=> Found post titled #{ @post.title } - by #{ @post.blog.author }"
|
data/lib/planet/post.rb
CHANGED
@@ -2,21 +2,22 @@ require 'mustache'
|
|
2
2
|
|
3
3
|
class Planet::Post
|
4
4
|
|
5
|
-
attr_accessor :title, :content, :date, :url, :blog
|
5
|
+
attr_accessor :title, :content, :date, :url, :blog, :rss_data
|
6
6
|
|
7
7
|
def initialize(attributes = {})
|
8
|
-
self.title
|
9
|
-
self.content
|
10
|
-
self.date
|
11
|
-
self.url
|
12
|
-
self.blog
|
8
|
+
self.title = attributes[:title]
|
9
|
+
self.content = attributes[:content]
|
10
|
+
self.date = attributes[:date]
|
11
|
+
self.url = attributes[:url]
|
12
|
+
self.blog = attributes[:blog]
|
13
|
+
self.rss_data = attributes[:rss_data]
|
13
14
|
end
|
14
15
|
|
15
16
|
def to_s
|
16
17
|
"#{ header }#{ content }#{ footer }"
|
17
18
|
end
|
18
19
|
|
19
|
-
def
|
20
|
+
def to_h
|
20
21
|
{
|
21
22
|
post_content: self.content,
|
22
23
|
post_title: self.title,
|
@@ -27,10 +28,14 @@ class Planet::Post
|
|
27
28
|
blog_name: self.blog.name,
|
28
29
|
post_url: self.url,
|
29
30
|
twitter: self.blog.twitter,
|
30
|
-
twitter_url: "http://twitter.com/#{ self.blog.twitter }"
|
31
|
+
twitter_url: "http://twitter.com/#{ self.blog.twitter }",
|
32
|
+
post_rss_data: self.rss_data,
|
33
|
+
blog_rss_data: self.blog.rss_data
|
31
34
|
}
|
32
35
|
end
|
33
36
|
|
37
|
+
alias_method :to_hash, :to_h
|
38
|
+
|
34
39
|
def header
|
35
40
|
## TODO: We need categories/tags
|
36
41
|
file = self.blog.planet.config.fetch('templates_directory', '_layouts/') + 'header.md'
|
data/lib/planet/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: planet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PoTe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|