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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3f10043797a9bca9f1ba85f58c9e78e2f6072ba
4
- data.tar.gz: 26ed44e3f4fb01059819d29a866ce16bcba02241
3
+ metadata.gz: a452a7fa90ffe5f8068a88ac07983ee2ce13a3b5
4
+ data.tar.gz: db39ed053a48787f6057462204c267778d32f1b2
5
5
  SHA512:
6
- metadata.gz: f7086f6942ac55ff20da540e2cb732fa9e3cbab1588f759ceea56294012bf8c181b73c2027659dbe9322ecf1cd05e038d432a24cac3bbb1e1913e22a82196db0
7
- data.tar.gz: d36c5070f39fe5a634eaf8276ef0e74499e7feaf68eecf9db4584ed656c521fe009c65474facaeb700b61d2f31e10b6d056515cfedb43f206df25f3cb266c757
6
+ metadata.gz: 49068d50bc0f7afdb365d42a5f273aa35efcce2e6476b2f35596ef5f6adcbb19357aeb75a9bb05d13c222d8b5403e1b7c572c65eda2d3e33d156a38502ad8ede
7
+ data.tar.gz: d10d441aadc823b766e1d295f6ae68b0caf78dd134fd4c6a45ade0ce86da08e7e954ebc226943eb00cba3a57b6c3903b8a869a60946bb58a5ec92575768ce470
@@ -4,18 +4,32 @@ require 'planet/parsers'
4
4
  class Planet
5
5
  class Blog
6
6
 
7
- attr_accessor :url, :feed, :type, :name, :author, :image, :twitter, :posts, :planet
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 = attributes[:url]
11
- self.feed = attributes[:feed]
12
- self.type = attributes[:type]
13
- self.name = attributes[:name]
14
- self.author = attributes[:author]
15
- self.image = attributes[:image]
16
- self.twitter = attributes[:twitter]
17
- self.posts = attributes.fetch(:posts, [])
18
- self.planet = attributes[: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 ||= feed.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 }"
@@ -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 = attributes[:title]
9
- self.content = attributes[:content]
10
- self.date = attributes[:date]
11
- self.url = attributes[:url]
12
- self.blog = attributes[: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 to_hash
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'
@@ -2,7 +2,7 @@ class Planet
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- PATCH = 1
5
+ PATCH = 2
6
6
 
7
7
  def self.to_s
8
8
  [MAJOR, MINOR, PATCH].join('.')
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.1
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: 2013-10-23 00:00:00.000000000 Z
11
+ date: 2014-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli