serum 0.1.0 → 0.2.0
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.
- data/README.md +2 -2
- data/lib/serum.rb +1 -1
- data/lib/serum/post.rb +4 -0
- data/lib/serum/site.rb +12 -1
- data/serum.gemspec +1 -1
- data/test/source/2013-01-02-post-excerpt.markdown +1 -0
- data/test/test_post.rb +9 -0
- data/test/test_site.rb +10 -0
- metadata +1 -1
data/README.md
CHANGED
@@ -43,11 +43,11 @@ a simple directory of posts.
|
|
43
43
|
|
44
44
|
Maybe more aptly named "deleter" considering this project's origin.
|
45
45
|
|
46
|
-
[Brad Fults](http://github.com/h3h) ([bfults@gmail.com]
|
46
|
+
[Brad Fults](http://github.com/h3h) ([bfults@gmail.com](mailto:bfults@gmail.com))
|
47
47
|
|
48
48
|
## Acknowledgements
|
49
49
|
|
50
|
-
Serum is based entirely on [Jekyll](http://jekyllrb.com/) from
|
50
|
+
Serum is based entirely on [Jekyll](http://jekyllrb.com/) from Tom Preston-Werner.
|
51
51
|
Thank you, Tom.
|
52
52
|
|
53
53
|
## License
|
data/lib/serum.rb
CHANGED
data/lib/serum/post.rb
CHANGED
data/lib/serum/site.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Serum
|
2
2
|
class Site
|
3
3
|
attr_accessor :config, :posts, :static_files, :exclude, :include, :source
|
4
|
-
attr_accessor :time, :baseurl
|
4
|
+
attr_accessor :time, :baseurl, :slugs_to_posts
|
5
5
|
|
6
6
|
# Public: Initialize a new Site.
|
7
7
|
#
|
@@ -29,6 +29,16 @@ module Serum
|
|
29
29
|
end
|
30
30
|
self.posts = []
|
31
31
|
self.static_files = []
|
32
|
+
self.slugs_to_posts = {}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Looks up a post by its slug.
|
36
|
+
#
|
37
|
+
# slug - A String denoting the slug for the post.
|
38
|
+
#
|
39
|
+
# Returns the found Post or nil.
|
40
|
+
def find_by_slug(slug)
|
41
|
+
self.slugs_to_posts[slug]
|
32
42
|
end
|
33
43
|
|
34
44
|
# Recursively traverse directories to find posts and static files
|
@@ -73,6 +83,7 @@ module Serum
|
|
73
83
|
|
74
84
|
if post.published && post.date <= self.time
|
75
85
|
self.posts << post
|
86
|
+
self.slugs_to_posts[post.slug] = post
|
76
87
|
end
|
77
88
|
end
|
78
89
|
end
|
data/serum.gemspec
CHANGED
data/test/test_post.rb
CHANGED
@@ -65,6 +65,15 @@ class TestPost < Test::Unit::TestCase
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
context "with slug specified in YAML front matter" do
|
69
|
+
setup do
|
70
|
+
@post = setup_post("2013-01-02-post-excerpt.markdown")
|
71
|
+
end
|
72
|
+
should "allow the slug to be overridden by the YAML" do
|
73
|
+
assert_equal("gray-brains", @post.slug)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
68
77
|
should "read yaml front-matter" do
|
69
78
|
@post.read_yaml(@source, @real_file)
|
70
79
|
|
data/test/test_site.rb
CHANGED
@@ -64,5 +64,15 @@ class TestSite < Test::Unit::TestCase
|
|
64
64
|
assert_equal files, @site.filter_entries(files)
|
65
65
|
end
|
66
66
|
|
67
|
+
should "provide a find_by_slug method" do
|
68
|
+
post = @site.find_by_slug("complex")
|
69
|
+
assert_equal "2008-11-21-complex.textile", post.name
|
70
|
+
end
|
71
|
+
|
72
|
+
should "provide a find_by_slug method when the slug is overridden" do
|
73
|
+
post = @site.find_by_slug("gray-brains")
|
74
|
+
assert_equal "2013-01-02-post-excerpt.markdown", post.name
|
75
|
+
end
|
76
|
+
|
67
77
|
end
|
68
78
|
end
|