rollin 0.0.16 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -23
- data/VERSION +1 -1
- data/lib/rollin/article.rb +49 -2
- data/lib/rollin/blog.rb +15 -5
- data/lib/rollin.rb +1 -0
- data/rollin.gemspec +2 -0
- data/spec/fixtures/{articles/2013_05_01_My_first_post.mk → 2013_05_01_My_first_post.mk} +0 -0
- data/spec/fixtures/{articles/2013_05_02_My_second_post.mk → 2013_05_02_My_second_post.mk} +4 -0
- data/spec/fixtures/2013_06_01_My_third_post.mk +11 -0
- data/spec/fixtures/{articles/2014_01_01_My_fourth_post.mk → 2014_01_01_My_fourth_post.mk} +0 -0
- data/spec/rollin_spec.rb +129 -0
- data/spec/spec_helper.rb +16 -0
- metadata +40 -18
- data/spec/annual_archive_spec.rb +0 -20
- data/spec/article_spec.rb +0 -33
- data/spec/blog_spec.rb +0 -29
- data/spec/fixtures/articles/2013_06_01_My_third_post.mk +0 -3
- data/spec/month_archive_spec.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eec28f29a0e5d44ec5f898ec1cc57a5e2ceb7309
|
4
|
+
data.tar.gz: 747351059a59ee276bb140861d2b742fc4c976b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb937284f72d047aba71e4cda7a0e1ba18ef88b66a842c784ff7a97c916f3233da72ae190169752981e5fdf9a1ffdb63aee7ee6a9f3080a328e02bea71c4ad9d
|
7
|
+
data.tar.gz: 1cc3d83c410c5febc1df9cc58257c614db44748d97e71e1bf4942ff65c0b8cb15dd03e24b656c2c0d43dc577c9b9edac463f6461bd8f92828af8128b7a4b7a5c
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# rollin
|
2
2
|
|
3
3
|
A Ruby minimalistic filesystem based blog engine made for developers.
|
4
4
|
|
5
|
-
Different from other blog engines
|
5
|
+
Different from other blog engines, rollin only does what matters, and leave the rest to you.
|
6
6
|
|
7
|
-
|
7
|
+
It currently supports Markdown format and uses the Github's awesome redcarpet.
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -18,41 +18,39 @@ Add the dependency to your Gemfile:
|
|
18
18
|
|
19
19
|
First you will need to have the following structure in your filesystem.
|
20
20
|
|
21
|
-
├──
|
21
|
+
├── posts
|
22
22
|
└── 2013_05_01_My_first_post.mk
|
23
23
|
|
24
24
|
### Articles
|
25
|
-
|
26
|
-
In your code.
|
27
25
|
|
28
|
-
blog = Rollin::Blog.new({
|
26
|
+
blog = Rollin::Blog.new({articles_folder: "posts"}) # Defaults to "articles"
|
29
27
|
|
30
|
-
|
28
|
+
first_post = blog.articles.first
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
first_post.id # => "2013_05_01_My_first_post"
|
31
|
+
first_post.title # => "My first post"
|
32
|
+
first_post.body # => "<h3>My first post!</h3>\n<p>blah blah blah</p>"
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
first_post.date # => #<Date: 2013-05-01 ((2456414j,0s,0n),+0s,2299161j)>
|
35
|
+
first_post.year # => 2013
|
36
|
+
first_post.month # => 05
|
37
|
+
first_post.day # => 01
|
40
38
|
|
41
39
|
### Monthly archive
|
42
40
|
|
43
|
-
|
41
|
+
may_archive = blog.monthly_archive.first
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
may_archive.year # => 2013
|
44
|
+
may_archive.month # => 5
|
45
|
+
may_archive.articles # => [ Rollin::Article(:title => "My first post" ...) ]
|
48
46
|
|
49
47
|
### Annual archive
|
50
48
|
|
51
|
-
|
49
|
+
twenty_thirteen_archive = blog.annual_archive.first
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
twenty_thirteen_archive.year # => 2013
|
52
|
+
twenty_thirteen_archive.articles # => [ Rollin::Article(:title => "My first post" ...) ]
|
53
|
+
twenty_thirteen_archive.monthly_archive # => [ Rollin::MonthArchive(:year => 2013, :month => 5 ...) ]
|
56
54
|
|
57
55
|
### Finding an article
|
58
56
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/rollin/article.rb
CHANGED
@@ -1,16 +1,63 @@
|
|
1
1
|
class Rollin::Article
|
2
|
-
attr_reader :id, :
|
2
|
+
attr_reader :id, :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
|
-
@
|
8
|
+
@title_from_filename = filename[11, filename.length - 11 - 3].gsub('_', ' ')
|
9
9
|
@year = filename[0, 4].to_i
|
10
10
|
@month = filename[5, 2].to_i
|
11
11
|
@day = filename[8, 2].to_i
|
12
12
|
end
|
13
13
|
|
14
|
+
def title
|
15
|
+
metatags[:title] || @title_from_filename
|
16
|
+
end
|
17
|
+
|
18
|
+
def matches?(search)
|
19
|
+
search = search.clone
|
20
|
+
|
21
|
+
return true if @id == search
|
22
|
+
|
23
|
+
if search.has_key?(:year)
|
24
|
+
return false if search.delete(:year) != @year
|
25
|
+
if search.has_key?(:month)
|
26
|
+
return false if search.delete(:month) != @month
|
27
|
+
if search.has_key?(:day)
|
28
|
+
return false if search.delete(:day) != @day
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
if search.keys.empty?
|
34
|
+
return true
|
35
|
+
else
|
36
|
+
search.each do |key, value|
|
37
|
+
return true if metatags[key] != nil && (metatags[key] == value || metatags[key].include?(value))
|
38
|
+
end
|
39
|
+
return false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def metatags
|
44
|
+
# Stolen from Jekyll
|
45
|
+
begin
|
46
|
+
content = File.read(@source_file)
|
47
|
+
|
48
|
+
if content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
49
|
+
content = $POSTMATCH
|
50
|
+
return YAML.safe_load($1).inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
51
|
+
end
|
52
|
+
rescue SyntaxError => e
|
53
|
+
puts "YAML Exception reading #{File.join(@source_file)}: #{e.message}"
|
54
|
+
rescue Exception => e
|
55
|
+
puts "Error reading file #{File.join(@source_file)}: #{e.message}"
|
56
|
+
end
|
57
|
+
|
58
|
+
return {}
|
59
|
+
end
|
60
|
+
|
14
61
|
def date
|
15
62
|
Date.new(@year, @month, @day)
|
16
63
|
end
|
data/lib/rollin/blog.rb
CHANGED
@@ -3,13 +3,15 @@ class Rollin::Blog
|
|
3
3
|
@articles_folder = options[:articles_folder] || 'articles'
|
4
4
|
end
|
5
5
|
|
6
|
-
def
|
7
|
-
|
6
|
+
def article(search)
|
7
|
+
read_articles.find { |article| article.matches?(search) }
|
8
8
|
end
|
9
9
|
|
10
|
-
def articles
|
11
|
-
|
12
|
-
|
10
|
+
def articles(search=nil)
|
11
|
+
if search.nil?
|
12
|
+
read_articles
|
13
|
+
else
|
14
|
+
read_articles.select { |article| article.matches?(search) }
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
@@ -27,4 +29,12 @@ class Rollin::Blog
|
|
27
29
|
Rollin::MonthArchive.new(year, month, articles_for_month)
|
28
30
|
end
|
29
31
|
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def read_articles
|
36
|
+
Dir["#{@articles_folder}/**/*.mk"].sort.map do |article_source|
|
37
|
+
Rollin::Article.new(article_source)
|
38
|
+
end
|
39
|
+
end
|
30
40
|
end
|
data/lib/rollin.rb
CHANGED
data/rollin.gemspec
CHANGED
@@ -21,7 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "pry"
|
24
25
|
spec.add_development_dependency "version"
|
25
26
|
|
26
27
|
spec.add_dependency "redcarpet"
|
28
|
+
spec.add_dependency "safe_yaml"
|
27
29
|
end
|
File without changes
|
File without changes
|
data/spec/rollin_spec.rb
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Fixtures
|
4
|
+
#
|
5
|
+
# 2013_05_01_My_first_post.mk
|
6
|
+
# 2013_05_02_My_second_post.mk
|
7
|
+
# 2013_06_01_My_third_post.mk
|
8
|
+
# 2014_01_01_My_fourth_post.mk
|
9
|
+
|
10
|
+
describe 'how rollin works' do
|
11
|
+
|
12
|
+
subject (:blog) { Rollin::Blog.new(articles_folder: 'spec/fixtures') }
|
13
|
+
|
14
|
+
context 'article content' do
|
15
|
+
let (:article) { blog.articles.first }
|
16
|
+
let (:article_with_title_metatag) { blog.articles[1] }
|
17
|
+
let (:article_with_custom_metatags) { blog.articles[2] }
|
18
|
+
|
19
|
+
it 'exposes article information and content' do
|
20
|
+
article.id.should == '2013_05_01_My_first_post'
|
21
|
+
article.title.should == 'My first post'
|
22
|
+
article.year.should == 2013
|
23
|
+
article.month.should == 5
|
24
|
+
article.day.should == 1
|
25
|
+
article.date.should == Date.new(2013, 5, 1)
|
26
|
+
article.body.should == "<h2>This is my first post</h2>\n\n<p>And here we go!</p>\n"
|
27
|
+
article.metatags.should be_empty
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'allows article title definition with metatag' do
|
31
|
+
article_with_title_metatag.title.should == 'This is a super post!'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'exposes the list of defined metatags' do
|
35
|
+
article_with_custom_metatags.metatags.should == { tags: ['manero', 'massa', 'bacana'], published: false }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'searching for articles' do
|
40
|
+
let (:first_article) { blog.articles.first }
|
41
|
+
let (:second_article) { blog.articles[1] }
|
42
|
+
let (:third_article) { blog.articles[2] }
|
43
|
+
let (:article_with_custom_metatags) { blog.articles[2] }
|
44
|
+
|
45
|
+
it 'searches by article id' do
|
46
|
+
blog.article('2013_05_01_My_first_post').should == first_article
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'searches by metatags' do
|
50
|
+
blog.article(tags: 'manero').should == article_with_custom_metatags
|
51
|
+
blog.articles(tags: 'manero').should == [ article_with_custom_metatags ]
|
52
|
+
|
53
|
+
blog.article(published: false).should == article_with_custom_metatags
|
54
|
+
blog.articles(published: false).should == [ article_with_custom_metatags ]
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'searches by date' do
|
58
|
+
blog.articles(year: 2013).should include(first_article, second_article, third_article)
|
59
|
+
blog.articles(year: 2013, month: 5).should include(first_article, second_article)
|
60
|
+
blog.articles(year: 2013, month: 5, day: 1).should include(first_article)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'narrows search by date when searching for metatags' do
|
64
|
+
blog.articles(year: 2013, :tags => 'manero').should { article_with_custom_metatags }
|
65
|
+
blog.articles(year: 2014, :tags => 'manero').should be_empty
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'listing articles' do
|
70
|
+
let (:first_article) { TestArticle.new(id: '2013_05_01_My_first_post', title: 'My first post', date: Date.new(2013, 5, 1)) }
|
71
|
+
let (:second_article) { TestArticle.new(id: '2013_05_02_My_second_post', title: 'This is a super post!', date: Date.new(2013, 5, 2)) }
|
72
|
+
let (:third_article) { TestArticle.new(id: '2013_06_01_My_third_post', title: 'My third post', date: Date.new(2013, 6, 1)) }
|
73
|
+
let (:fourth_article) { TestArticle.new(id: '2014_01_01_My_fourth_post', title: 'My fourth post', date: Date.new(2014, 1, 1)) }
|
74
|
+
|
75
|
+
it 'lists all articles' do
|
76
|
+
blog.should have(4).articles
|
77
|
+
|
78
|
+
blog.articles[0].should == first_article
|
79
|
+
blog.articles[1].should == second_article
|
80
|
+
blog.articles[2].should == third_article
|
81
|
+
blog.articles[3].should == fourth_article
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'provides monthly archive' do
|
85
|
+
blog.monthly_archive.should have(3).articles
|
86
|
+
|
87
|
+
blog.monthly_archive[0].year.should == 2013
|
88
|
+
blog.monthly_archive[0].month.should == 5
|
89
|
+
blog.monthly_archive[0].should have(2).articles
|
90
|
+
blog.monthly_archive[0].articles.should include(first_article, second_article)
|
91
|
+
|
92
|
+
blog.monthly_archive[1].year.should == 2013
|
93
|
+
blog.monthly_archive[1].month.should == 6
|
94
|
+
blog.monthly_archive[1].should have(1).articles
|
95
|
+
blog.monthly_archive[1].articles.should include(third_article)
|
96
|
+
|
97
|
+
blog.monthly_archive[2].year.should == 2014
|
98
|
+
blog.monthly_archive[2].month.should == 1
|
99
|
+
blog.monthly_archive[2].should have(1).articles
|
100
|
+
blog.monthly_archive[2].articles.should include(fourth_article)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'provides annual archive' do
|
104
|
+
blog.should have(2).annual_archive
|
105
|
+
|
106
|
+
blog.annual_archive[0].year.should == 2013
|
107
|
+
blog.annual_archive[0].should have(2).monthly_archive
|
108
|
+
blog.annual_archive[0].monthly_archive[0].year.should == 2013
|
109
|
+
blog.annual_archive[0].monthly_archive[0].month.should == 5
|
110
|
+
blog.annual_archive[0].monthly_archive[0].should have(2).articles
|
111
|
+
blog.annual_archive[0].monthly_archive[0].articles.should include(first_article, second_article)
|
112
|
+
blog.annual_archive[0].monthly_archive[1].year.should == 2013
|
113
|
+
blog.annual_archive[0].monthly_archive[1].month.should == 6
|
114
|
+
blog.annual_archive[0].monthly_archive[1].should have(1).articles
|
115
|
+
blog.annual_archive[0].monthly_archive[1].articles.should include(third_article)
|
116
|
+
blog.annual_archive[0].should have(3).articles
|
117
|
+
blog.annual_archive[0].articles.should include(first_article, second_article, third_article)
|
118
|
+
|
119
|
+
blog.annual_archive[1].year.should == 2014
|
120
|
+
blog.annual_archive[1].should have(1).monthly_archive
|
121
|
+
blog.annual_archive[1].monthly_archive[0].year.should == 2014
|
122
|
+
blog.annual_archive[1].monthly_archive[0].month.should == 1
|
123
|
+
blog.annual_archive[1].monthly_archive[0].should have(1).articles
|
124
|
+
blog.annual_archive[1].monthly_archive[0].articles.should include(fourth_article)
|
125
|
+
blog.annual_archive[1].should have(1).articles
|
126
|
+
blog.annual_archive[1].articles.should include(fourth_article)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,3 +3,19 @@ require 'bundler/setup'
|
|
3
3
|
Bundler.require :development
|
4
4
|
|
5
5
|
require './lib/rollin'
|
6
|
+
|
7
|
+
class Rollin::Article
|
8
|
+
def ==(other)
|
9
|
+
id == other.id && title == other.title && date == other.date
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class TestArticle
|
14
|
+
attr_reader :id, :title, :date
|
15
|
+
|
16
|
+
def initialize(properties)
|
17
|
+
@id = properties[:id]
|
18
|
+
@title = properties[:title]
|
19
|
+
@date = properties[:date]
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rollin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- marano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: version
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +94,20 @@ dependencies:
|
|
80
94
|
- - '>='
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: safe_yaml
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
83
111
|
description: ''
|
84
112
|
email:
|
85
113
|
- thiagomarano@gmail.com
|
@@ -102,14 +130,11 @@ files:
|
|
102
130
|
- lib/rollin/version.rb
|
103
131
|
- lib/rollin/year_archive.rb
|
104
132
|
- rollin.gemspec
|
105
|
-
- spec/
|
106
|
-
- spec/
|
107
|
-
- spec/
|
108
|
-
- spec/fixtures/
|
109
|
-
- spec/
|
110
|
-
- spec/fixtures/articles/2013_06_01_My_third_post.mk
|
111
|
-
- spec/fixtures/articles/2014_01_01_My_fourth_post.mk
|
112
|
-
- spec/month_archive_spec.rb
|
133
|
+
- spec/fixtures/2013_05_01_My_first_post.mk
|
134
|
+
- spec/fixtures/2013_05_02_My_second_post.mk
|
135
|
+
- spec/fixtures/2013_06_01_My_third_post.mk
|
136
|
+
- spec/fixtures/2014_01_01_My_fourth_post.mk
|
137
|
+
- spec/rollin_spec.rb
|
113
138
|
- spec/spec_helper.rb
|
114
139
|
homepage: http://github.com/marano/rollin
|
115
140
|
licenses:
|
@@ -136,12 +161,9 @@ signing_key:
|
|
136
161
|
specification_version: 4
|
137
162
|
summary: A Ruby minimalistic blog engine ... WATTT!!?!??
|
138
163
|
test_files:
|
139
|
-
- spec/
|
140
|
-
- spec/
|
141
|
-
- spec/
|
142
|
-
- spec/fixtures/
|
143
|
-
- spec/
|
144
|
-
- spec/fixtures/articles/2013_06_01_My_third_post.mk
|
145
|
-
- spec/fixtures/articles/2014_01_01_My_fourth_post.mk
|
146
|
-
- spec/month_archive_spec.rb
|
164
|
+
- spec/fixtures/2013_05_01_My_first_post.mk
|
165
|
+
- spec/fixtures/2013_05_02_My_second_post.mk
|
166
|
+
- spec/fixtures/2013_06_01_My_third_post.mk
|
167
|
+
- spec/fixtures/2014_01_01_My_fourth_post.mk
|
168
|
+
- spec/rollin_spec.rb
|
147
169
|
- spec/spec_helper.rb
|
data/spec/annual_archive_spec.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Rollin::YearArchive do
|
4
|
-
let (:article) { Rollin::Article.new('spec/fixtures/2013_05_01_My_first_post.mk') }
|
5
|
-
subject (:month_archive) { Rollin::MonthArchive.new(2013, 05, [ article ]) }
|
6
|
-
subject (:year_archive) { Rollin::YearArchive.new(2013, [ month_archive ]) }
|
7
|
-
|
8
|
-
it 'tells the year' do
|
9
|
-
year_archive.year.should == 2013
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'has monthly archives' do
|
13
|
-
year_archive.monthly_archive.size.should == 1
|
14
|
-
year_archive.monthly_archive.first.should == month_archive
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'has a list of articles' do
|
18
|
-
year_archive.articles.first.should == article
|
19
|
-
end
|
20
|
-
end
|
data/spec/article_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require './spec/spec_helper'
|
2
|
-
|
3
|
-
describe Rollin::Article do
|
4
|
-
subject (:article) { Rollin::Article.new('spec/fixtures/articles/2013_05_01_My_first_post.mk') }
|
5
|
-
|
6
|
-
it 'tells article id' do
|
7
|
-
article.id.should == '2013_05_01_My_first_post'
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'tells article title' do
|
11
|
-
article.title.should == 'My first post'
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'compiles article body to html' do
|
15
|
-
article.body.should == "<h2>This is my first post</h2>\n\n<p>And here we go!</p>\n"
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'tells article year' do
|
19
|
-
article.year.should == 2013
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'tells article month' do
|
23
|
-
article.month.should == 5
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'tells article day' do
|
27
|
-
article.day.should == 1
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'tells article date' do
|
31
|
-
article.date.should == Date.new(2013, 5, 1)
|
32
|
-
end
|
33
|
-
end
|
data/spec/blog_spec.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require './spec/spec_helper'
|
2
|
-
|
3
|
-
describe Rollin::Blog do
|
4
|
-
context 'reading articles from articles folder' do
|
5
|
-
subject (:blog) { Rollin::Blog.new(articles_folder: 'spec/fixtures/articles') }
|
6
|
-
|
7
|
-
it 'has the right amount of articles' do
|
8
|
-
blog.articles.size.should == 4
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'has monthly archives' do
|
12
|
-
blog.monthly_archive.size.should == 3
|
13
|
-
blog.monthly_archive.first.class.should == Rollin::MonthArchive
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'has annual archives' do
|
17
|
-
blog.annual_archive.size.should == 2
|
18
|
-
blog.annual_archive.first.class.should == Rollin::YearArchive
|
19
|
-
blog.annual_archive.first.monthly_archive.size.should == 2
|
20
|
-
blog.annual_archive.first.monthly_archive.first.class.should == Rollin::MonthArchive
|
21
|
-
blog.annual_archive.first.monthly_archive.first.articles.size.should == 2
|
22
|
-
blog.annual_archive.first.monthly_archive.first.articles.first.class.should == Rollin::Article
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'finds article by its id' do
|
26
|
-
blog.find_article_by_id('2013_05_01_My_first_post').title.should == 'My first post'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/spec/month_archive_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
describe Rollin::MonthArchive do
|
2
|
-
let (:article) { Rollin::Article.new('spec/fixtures/2013_05_01_My_first_post.mk') }
|
3
|
-
subject (:month_archive) { Rollin::MonthArchive.new(2013, 05, [ article ]) }
|
4
|
-
|
5
|
-
it 'tells the year' do
|
6
|
-
month_archive.year.should == 2013
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'tells the month' do
|
10
|
-
month_archive.month.should == 5
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'has a list of articles' do
|
14
|
-
month_archive.articles.first.should == article
|
15
|
-
end
|
16
|
-
end
|