persona 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ autoload :Page, 'persona/page'
11
11
  #ROUTES
12
12
 
13
13
  get '/' do
14
- @posts = load_posts
14
+ @posts = Post.all
15
15
  erb :index
16
16
  end
17
17
 
@@ -64,14 +64,3 @@ not_found do
64
64
  erb :not_found
65
65
  end
66
66
 
67
-
68
- def load_posts
69
- posts = Dir.entries('./contents/posts').sort.reverse.reject do |it|
70
- not it.end_with? '.txt'
71
- end
72
-
73
- posts.map do |it|
74
- Post.new it
75
- end
76
- end
77
-
@@ -2,8 +2,10 @@ class Post
2
2
 
3
3
  attr_reader :content, :title, :author, :url, :date, :excerpt, :is_excerpt
4
4
 
5
+ POST_FOLDER = './contents/posts'
6
+
5
7
  def initialize(file_name)
6
- f = File.open("./contents/posts/#{file_name}","r")
8
+ f = File.open("#{POST_FOLDER}/#{file_name}","r")
7
9
  @content = f.content_as_string
8
10
  @title = f.metadata 'title'
9
11
  @author = f.metadata 'author'
@@ -22,6 +24,16 @@ class Post
22
24
  Post.new "#{y}-#{m}-#{d}-#{name}.txt"
23
25
  end
24
26
 
27
+ def self.all
28
+ posts = Dir.entries("#{POST_FOLDER}").sort.reverse.reject do |it|
29
+ not it.end_with? '.txt'
30
+ end
31
+
32
+ posts.map do |it|
33
+ Post.new it
34
+ end
35
+ end
36
+
25
37
  private
26
38
 
27
39
  MORE_TAG = '<!--more-->'
@@ -1,3 +1,3 @@
1
1
  module Persona
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 4
9
- version: 0.0.4
8
+ - 5
9
+ version: 0.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Filippo Diotalevi
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-26 00:00:00 +01:00
17
+ date: 2011-01-27 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency