rollin 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rollin/article.rb +3 -2
- data/lib/rollin/blog.rb +4 -0
- data/spec/article_spec.rb +5 -1
- data/spec/blog_spec.rb +4 -0
- 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: b6ef7f3be9c83a460825f763d4c06d1b2b0ac1a6
|
4
|
+
data.tar.gz: ab3c26c1af266bb7ca8caf4ef57e9e6c15b02548
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b52239b44ea70fd8e6d887f36958600aaa4183ee42bb34a2b3212a1cbb73919f1ba111b26f19ca688877d23c0bdc36d83e844189c6770ba48a18c7a78d37b37
|
7
|
+
data.tar.gz: e4c68146f52c7edce5aad218527fcf0e06b4011cc4569ff36a47fe1615c5eee9ab5e1239b1defce396f71df57bb0e2655a208051e67718b010d79c0d26de7f2e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.12
|
data/lib/rollin/article.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
class Rollin::Article
|
2
|
-
attr_reader :title, :year, :month, :day
|
2
|
+
attr_reader :id, :title, :year, :month, :day
|
3
3
|
|
4
4
|
def initialize(source_file)
|
5
5
|
@source_file = source_file
|
6
6
|
filename = File.basename(@source_file)
|
7
|
-
@
|
7
|
+
@id = filename[0, filename.length - 3]
|
8
|
+
@title = filename[11, filename.length - 11 - 3].gsub('_', ' ')
|
8
9
|
@year = filename[0, 4].to_i
|
9
10
|
@month = filename[5, 2].to_i
|
10
11
|
@day = filename[8, 2].to_i
|
data/lib/rollin/blog.rb
CHANGED
@@ -3,6 +3,10 @@ class Rollin::Blog
|
|
3
3
|
@articles_folder = options[:articles_folder] || 'articles'
|
4
4
|
end
|
5
5
|
|
6
|
+
def find_article_by_id(article_id)
|
7
|
+
articles.find { |article| article.id == article_id }
|
8
|
+
end
|
9
|
+
|
6
10
|
def articles
|
7
11
|
Dir["#{@articles_folder}/**/*.mk"].sort.map do |article_source|
|
8
12
|
Rollin::Article.new(article_source)
|
data/spec/article_spec.rb
CHANGED
@@ -3,8 +3,12 @@ require './spec/spec_helper'
|
|
3
3
|
describe Rollin::Article do
|
4
4
|
subject (:article) { Rollin::Article.new('spec/fixtures/articles/2013_05_01_My_first_post.mk') }
|
5
5
|
|
6
|
+
it 'tells article id' do
|
7
|
+
article.id.should == '2013_05_01_My_first_post'
|
8
|
+
end
|
9
|
+
|
6
10
|
it 'tells article title' do
|
7
|
-
article.title == 'My first post'
|
11
|
+
article.title.should == 'My first post'
|
8
12
|
end
|
9
13
|
|
10
14
|
it 'compiles article body to html' do
|
data/spec/blog_spec.rb
CHANGED
@@ -11,5 +11,9 @@ describe Rollin::Blog do
|
|
11
11
|
it 'has the right amount of monthly archives' do
|
12
12
|
blog.monthly_archive.size.should == 2
|
13
13
|
end
|
14
|
+
|
15
|
+
it 'finds article by its id' do
|
16
|
+
blog.find_article_by_id('2013_05_01_My_first_post').title.should == 'My first post'
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|