rollin 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +7 -0
- data/VERSION +1 -0
- data/lib/rollin/article.rb +23 -0
- data/lib/rollin/blog.rb +28 -14
- data/lib/rollin/month_archive.rb +7 -0
- data/lib/rollin/version.rb +3 -1
- data/lib/rollin.rb +3 -0
- data/rollin.gemspec +2 -0
- data/spec/article_spec.rb +25 -0
- data/spec/blog_spec.rb +15 -0
- data/spec/fixtures/articles/2013_05_01_My_first_post.mk +3 -0
- data/spec/fixtures/articles/2013_05_02_My_second_post.mk +3 -0
- data/spec/fixtures/articles/2013_06_01_My_third_post.mk +3 -0
- data/spec/month_archive_spec.rb +16 -0
- data/spec/spec_helper.rb +5 -0
- metadata +48 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 669c21a394800ac2d402f09a9278d9c1811b41b2
|
4
|
+
data.tar.gz: 46c24726c6082ba0cda292028db3c4d543ab5dd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecb874bfc15b5cecbc3ee9f3881985dfce80c5febde3ec5f3131475c1a3da005fa775ceecadec9e791eff8c62aaef9fb19a4bcd779d49e399c5c422565d18124
|
7
|
+
data.tar.gz: f9dbbf12c76357efe510d72a9eca3cb85059f7970850d7c74696f8b1d39d07e0ff8b8fc665c91468d9ba8b6faae2ed2a121cb330981a15143fa6fb356c1c15e1
|
data/Rakefile
CHANGED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.6
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Rollin::Article
|
2
|
+
attr_reader :year, :month, :day
|
3
|
+
|
4
|
+
def initialize(source_file)
|
5
|
+
@source_file = source_file
|
6
|
+
filename = File.basename(@source_file)
|
7
|
+
@year = filename[0, 4].to_i
|
8
|
+
@month = filename[5, 2].to_i
|
9
|
+
@day = filename[8, 2].to_i
|
10
|
+
end
|
11
|
+
|
12
|
+
def date
|
13
|
+
Date.new(@year, @month, @day)
|
14
|
+
end
|
15
|
+
|
16
|
+
def body
|
17
|
+
redcarpet = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
|
18
|
+
autolink: true,
|
19
|
+
space_after_headers: true,
|
20
|
+
hard_wrap: true)
|
21
|
+
redcarpet.render(File.read(@source_file))
|
22
|
+
end
|
23
|
+
end
|
data/lib/rollin/blog.rb
CHANGED
@@ -1,21 +1,35 @@
|
|
1
1
|
class Rollin::Blog
|
2
|
-
def
|
3
|
-
|
4
|
-
Article.new(article_source)
|
5
|
-
end
|
2
|
+
def initialize(options = {})
|
3
|
+
@articles_folder = options[:articles_folder] || 'articles'
|
6
4
|
end
|
7
|
-
end
|
8
5
|
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
def articles
|
7
|
+
Dir["#{@articles_folder}/**/*.mk"].sort.map do |article_source|
|
8
|
+
Rollin::Article.new(article_source)
|
9
|
+
end
|
12
10
|
end
|
13
11
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
def monthly_archive
|
13
|
+
years = {}
|
14
|
+
articles.each do |article|
|
15
|
+
if years.has_key?(article.year)
|
16
|
+
year = years[article.year]
|
17
|
+
if year.has_key?(article.month)
|
18
|
+
year[article.month] << article
|
19
|
+
else
|
20
|
+
year[article.month] = [ article ]
|
21
|
+
end
|
22
|
+
else
|
23
|
+
years[article.year] = { article.month => [ article ] }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
archives_list = []
|
27
|
+
years.each do |year, months|
|
28
|
+
months.each do |month|
|
29
|
+
month_articles = articles.map { |article| article.year == year && article.month == month }
|
30
|
+
archives_list << Rollin::MonthArchive.new(year, month, month_articles)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
return archives_list
|
20
34
|
end
|
21
35
|
end
|
data/lib/rollin/version.rb
CHANGED
data/lib/rollin.rb
CHANGED
data/rollin.gemspec
CHANGED
@@ -0,0 +1,25 @@
|
|
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 'compiles article body to html' do
|
7
|
+
article.body.should == "<h2>This is my first post</h2>\n\n<p>And here we go!</p>\n"
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'tells article year' do
|
11
|
+
article.year == 2013
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'tells article month' do
|
15
|
+
article.month == 5
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'tells article day' do
|
19
|
+
article.day == 1
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'tells article date' do
|
23
|
+
article.date.should == Date.new(2013, 5, 1)
|
24
|
+
end
|
25
|
+
end
|
data/spec/blog_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
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 == 3
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'has the right amount of monthly archives' do
|
12
|
+
blog.monthly_archive.size.should == 2
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
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
|
data/spec/spec_helper.rb
ADDED
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.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- marano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: version
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: redcarpet
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,10 +93,20 @@ files:
|
|
65
93
|
- LICENSE.txt
|
66
94
|
- README.md
|
67
95
|
- Rakefile
|
96
|
+
- VERSION
|
68
97
|
- lib/rollin.rb
|
98
|
+
- lib/rollin/article.rb
|
69
99
|
- lib/rollin/blog.rb
|
100
|
+
- lib/rollin/month_archive.rb
|
70
101
|
- lib/rollin/version.rb
|
71
102
|
- rollin.gemspec
|
103
|
+
- spec/article_spec.rb
|
104
|
+
- spec/blog_spec.rb
|
105
|
+
- spec/fixtures/articles/2013_05_01_My_first_post.mk
|
106
|
+
- spec/fixtures/articles/2013_05_02_My_second_post.mk
|
107
|
+
- spec/fixtures/articles/2013_06_01_My_third_post.mk
|
108
|
+
- spec/month_archive_spec.rb
|
109
|
+
- spec/spec_helper.rb
|
72
110
|
homepage: http://github.com/marano/rollin
|
73
111
|
licenses:
|
74
112
|
- MIT
|
@@ -93,4 +131,11 @@ rubygems_version: 2.0.3
|
|
93
131
|
signing_key:
|
94
132
|
specification_version: 4
|
95
133
|
summary: A Ruby minimalistic blog engine ... WATTT!!?!??
|
96
|
-
test_files:
|
134
|
+
test_files:
|
135
|
+
- spec/article_spec.rb
|
136
|
+
- spec/blog_spec.rb
|
137
|
+
- spec/fixtures/articles/2013_05_01_My_first_post.mk
|
138
|
+
- spec/fixtures/articles/2013_05_02_My_second_post.mk
|
139
|
+
- spec/fixtures/articles/2013_06_01_My_third_post.mk
|
140
|
+
- spec/month_archive_spec.rb
|
141
|
+
- spec/spec_helper.rb
|