planet 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/planet +1 -1
- data/lib/planet.rb +47 -38
- data/lib/version.rb +13 -0
- metadata +9 -9
- data/lib/planet_version.rb +0 -3
data/bin/planet
CHANGED
data/lib/planet.rb
CHANGED
@@ -1,40 +1,6 @@
|
|
1
1
|
require 'simple-rss'
|
2
2
|
require 'open-uri'
|
3
3
|
|
4
|
-
class Blog < Struct.new(:feed, :author, :image, :posts)
|
5
|
-
end
|
6
|
-
|
7
|
-
class Post < Struct.new(:title, :content, :date, :link, :blog)
|
8
|
-
|
9
|
-
def to_hash
|
10
|
-
{
|
11
|
-
title: title,
|
12
|
-
date: date.strftime('%Y-%m-%d %H:%M'),
|
13
|
-
link: link,
|
14
|
-
content: content,
|
15
|
-
author: blog.author
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
def header
|
20
|
-
## TODO: We need categories/tags
|
21
|
-
"---
|
22
|
-
title: \"%{title}\"
|
23
|
-
kind: article
|
24
|
-
author: %{author}
|
25
|
-
created_at: %{date}
|
26
|
-
---
|
27
|
-
" % self.to_hash
|
28
|
-
end
|
29
|
-
|
30
|
-
def file_name
|
31
|
-
name_date = date ? date.strftime('%Y-%m-%d') : nil
|
32
|
-
name_title = title.downcase.scan(/\w+/).join('-')
|
33
|
-
|
34
|
-
[name_date, name_title].join('-')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
4
|
class Planet
|
39
5
|
|
40
6
|
def initialize
|
@@ -99,11 +65,54 @@ class Planet
|
|
99
65
|
posts(filter: {date: true, order: :date}).each do |post|
|
100
66
|
file_name = '_posts/'.concat post.file_name
|
101
67
|
|
102
|
-
File.open(file_name + '.markdown', "w+") { |f|
|
103
|
-
|
104
|
-
|
105
|
-
|
68
|
+
File.open(file_name + '.markdown', "w+") { |f| f.write(post.to_s) }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class Post < Struct.new(:title, :content, :date, :link, :blog)
|
73
|
+
|
74
|
+
def to_hash
|
75
|
+
{
|
76
|
+
title: title,
|
77
|
+
date: date.strftime('%Y-%m-%d %H:%M'),
|
78
|
+
link: link,
|
79
|
+
content: content,
|
80
|
+
author: blog.author
|
106
81
|
}
|
107
82
|
end
|
83
|
+
|
84
|
+
def header
|
85
|
+
## TODO: We need categories/tags
|
86
|
+
"---
|
87
|
+
title: \"%{title}\"
|
88
|
+
kind: article
|
89
|
+
created_at: %{date}
|
90
|
+
layout: post
|
91
|
+
---
|
92
|
+
" % self.to_hash
|
93
|
+
end
|
94
|
+
|
95
|
+
def file_name
|
96
|
+
name_date = date ? date.strftime('%Y-%m-%d') : nil
|
97
|
+
name_title = title.downcase.scan(/\w+/).join('-')
|
98
|
+
|
99
|
+
[name_date, name_title].join('-')
|
100
|
+
end
|
101
|
+
|
102
|
+
def footer
|
103
|
+
"
|
104
|
+
<div class=\"author\">
|
105
|
+
<img src=\"#{ self.blog.image }\"/ style=\"width: 107px; height: 20px;\">
|
106
|
+
<i>Post by #{ self.blog.author } - <a href=\"#{ self.link }\">read it from the source</a></i>
|
107
|
+
</div>
|
108
|
+
"
|
109
|
+
end
|
110
|
+
|
111
|
+
def to_s
|
112
|
+
self.header + self.content + self.footer
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
class Blog < Struct.new(:feed, :author, :image, :posts)
|
108
117
|
end
|
109
118
|
end
|
data/lib/version.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: planet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &2151836920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2151836920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: gli
|
27
|
-
requirement: &
|
27
|
+
requirement: &2151835780 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2151835780
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: simple-rss
|
38
|
-
requirement: &
|
38
|
+
requirement: &2151834540 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2151834540
|
47
47
|
description:
|
48
48
|
email: pote@tardis.com.uy
|
49
49
|
executables:
|
@@ -52,7 +52,7 @@ extensions: []
|
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
54
|
- bin/planet
|
55
|
-
- lib/
|
55
|
+
- lib/version.rb
|
56
56
|
- lib/planet.rb
|
57
57
|
homepage: http://poteland.com
|
58
58
|
licenses: []
|
data/lib/planet_version.rb
DELETED