jekyll 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jekyll might be problematic. Click here for more details.

@@ -1,3 +1,16 @@
1
+ ==
2
+ * Bug Fixes
3
+ * Require redcloth >= 4.2.1 in tests (#92)
4
+
5
+ == 0.5.5
6
+ * Bug Fixes
7
+ * Fix pagination % 0 bug (#78)
8
+ * Ensure all posts are processed first (#71)
9
+
10
+ == NOTE
11
+ * After this point I will no longer be giving credit in the history;
12
+ that is what the commit log is for.
13
+
1
14
  == 0.5.4 / 2009-08-23
2
15
  * Bug Fixes
3
16
  * Do not allow symlinks (security vulnerability)
@@ -1,4 +1,5 @@
1
1
  ---
2
- :patch: 4
2
+ :patch: 5
3
3
  :major: 0
4
4
  :minor: 5
5
+ :build:
@@ -29,7 +29,7 @@ Feature: Create sites
29
29
  Scenario: Basic site with layout and a post
30
30
  Given I have a _layouts directory
31
31
  And I have a _posts directory
32
- And I have the following post:
32
+ And I have the following posts:
33
33
  | title | date | layout | content |
34
34
  | Wargames | 3/27/2009 | default | The only winning move is not to play. |
35
35
  And I have a default layout that contains "Post Layout: {{ content }}"
@@ -37,6 +37,36 @@ Feature: Create sites
37
37
  Then the _site directory should exist
38
38
  And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html"
39
39
 
40
+ Scenario: Basic site with layouts, pages, posts and files
41
+ Given I have a _layouts directory
42
+ And I have a page layout that contains "Page Layout: {{ site.posts.size }}"
43
+ And I have a post layout that contains "Post Layout: {{ content }}"
44
+ And I have an "index.html" page with layout "page" that contains "site index page"
45
+ And I have a blog directory
46
+ And I have a "blog/index.html" page with layout "page" that contains "category index page"
47
+ And I have an "about.html" file that contains "No replacement {{ site.posts.size }}"
48
+ And I have an "another_file" file that contains ""
49
+ And I have a _posts directory
50
+ And I have the following posts:
51
+ | title | date | layout | content |
52
+ | entry1 | 3/27/2009 | post | content for entry1. |
53
+ | entry2 | 4/27/2009 | post | content for entry2. |
54
+ And I have a category/_posts directory
55
+ And I have the following posts in "category":
56
+ | title | date | layout | content |
57
+ | entry3 | 5/27/2009 | post | content for entry3. |
58
+ | entry4 | 6/27/2009 | post | content for entry4. |
59
+ When I run jekyll
60
+ Then the _site directory should exist
61
+ And I should see "Page Layout: 4" in "_site/index.html"
62
+ And I should see "No replacement \{\{ site.posts.size \}\}" in "_site/about.html"
63
+ And I should see "" in "_site/another_file"
64
+ And I should see "Page Layout: 4" in "_site/blog/index.html"
65
+ And I should see "Post Layout: <p>content for entry1.</p>" in "_site/2009/03/27/entry1.html"
66
+ And I should see "Post Layout: <p>content for entry2.</p>" in "_site/2009/04/27/entry2.html"
67
+ And I should see "Post Layout: <p>content for entry3.</p>" in "_site/category/2009/05/27/entry3.html"
68
+ And I should see "Post Layout: <p>content for entry4.</p>" in "_site/category/2009/06/27/entry4.html"
69
+
40
70
  Scenario: Basic site with include tag
41
71
  Given I have a _includes directory
42
72
  And I have an "index.html" page that contains "Basic Site with include tag: {% include about.textile %}"
@@ -6,35 +6,22 @@ Feature: Site pagination
6
6
  Scenario Outline: Paginate with N posts per page
7
7
  Given I have a configuration file with "paginate" set to "<num>"
8
8
  And I have a _layouts directory
9
- And I have an "index.html" file that contains "Basic Site"
9
+ And I have an "index.html" file that contains "{{ paginator.posts.size }}"
10
10
  And I have a _posts directory
11
11
  And I have the following post:
12
12
  | title | date | layout | content |
13
13
  | Wargames | 3/27/2009 | default | The only winning move is not to play. |
14
14
  | Wargames2 | 4/27/2009 | default | The only winning move is not to play2. |
15
- | Wargames3 | 5/27/2009 | default | The only winning move is not to play2. |
15
+ | Wargames3 | 5/27/2009 | default | The only winning move is not to play3. |
16
+ | Wargames4 | 6/27/2009 | default | The only winning move is not to play4. |
16
17
  When I run jekyll
17
- Then the _site/page2 directory should exist
18
- And the _site/page2/index.html file should exist
19
-
18
+ Then the _site/page<exist> directory should exist
19
+ And the "_site/page<exist>/index.html" file should exist
20
+ And I should see "<posts>" in "_site/page<exist>/index.html"
21
+ And the "_site/page<not_exist>/index.html" file should not exist
22
+
20
23
  Examples:
21
- | num |
22
- | 1 |
23
- | 2 |
24
-
25
- Scenario: Correct liquid paginator replacements
26
- Given I have a configuration file with "paginate" set to "1"
27
- And I have a _layouts directory
28
- And I have an "index.html" file that contains "{{ paginator.page }}"
29
- And I have a _posts directory
30
- And I have the following post:
31
- | title | date | layout | content |
32
- | Wargames | 3/27/2009 | default | The only winning move is not to play. |
33
- | Wargames2 | 4/27/2009 | default | The only winning move is not to play2. |
34
- When I run jekyll
35
- Then the _site/index.html file should exist
36
- And I should see "1" in "_site/index.html"
37
- Then the _site/page2 directory should exist
38
- And the _site/page2/index.html file should exist
39
- And I should see "2" in "_site/page2/index.html"
40
-
24
+ | num | exist | posts | not_exist |
25
+ | 1 | 4 | 1 | 5 |
26
+ | 2 | 2 | 2 | 3 |
27
+ | 3 | 2 | 1 | 3 |
@@ -13,7 +13,7 @@ Given /^I have a blank site in "(.*)"$/ do |path|
13
13
  end
14
14
 
15
15
  # Like "I have a foo file" but gives a yaml front matter so jekyll actually processes it
16
- Given /^I have an "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text|
16
+ Given /^I have an? "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text|
17
17
  File.open(file, 'w') do |f|
18
18
  f.write <<EOF
19
19
  ---
@@ -25,7 +25,7 @@ EOF
25
25
  end
26
26
  end
27
27
 
28
- Given /^I have an "(.*)" file that contains "(.*)"$/ do |file, text|
28
+ Given /^I have an? "(.*)" file that contains "(.*)"$/ do |file, text|
29
29
  File.open(file, 'w') do |f|
30
30
  f.write(text)
31
31
  f.close
@@ -40,7 +40,7 @@ Given /^I have a (.*) layout that contains "(.*)"$/ do |layout, text|
40
40
  end
41
41
 
42
42
  Given /^I have a (.*) directory$/ do |dir|
43
- FileUtils.mkdir(dir)
43
+ FileUtils.mkdir_p(dir)
44
44
  end
45
45
 
46
46
  Given /^I have the following posts?(?: (.*) "(.*)")?:$/ do |direction, folder, table|
@@ -115,14 +115,14 @@ Then /^the (.*) directory should exist$/ do |dir|
115
115
  assert File.directory?(dir)
116
116
  end
117
117
 
118
- Then /^the (.*) file should exist$/ do |file|
119
- assert File.file?(file)
120
- end
121
-
122
118
  Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
123
119
  assert_match Regexp.new(text), File.open(file).readlines.join
124
120
  end
125
121
 
122
+ Then /^the "(.*)" file should exist$/ do |file|
123
+ assert File.file?(file)
124
+ end
125
+
126
126
  Then /^the "(.*)" file should not exist$/ do |file|
127
127
  assert !File.exists?(file)
128
128
  end
@@ -1,12 +1,15 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{jekyll}
5
- s.version = "0.5.4"
8
+ s.version = "0.5.5"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Tom Preston-Werner"]
9
- s.date = %q{2009-08-24}
12
+ s.date = %q{2010-01-08}
10
13
  s.default_executable = %q{jekyll}
11
14
  s.description = %q{Jekyll is a simple, blog aware, static site generator.}
12
15
  s.email = %q{tom@mojombo.com}
@@ -47,6 +50,7 @@ Gem::Specification.new do |s|
47
50
  "lib/jekyll/pager.rb",
48
51
  "lib/jekyll/post.rb",
49
52
  "lib/jekyll/site.rb",
53
+ "lib/jekyll/static_file.rb",
50
54
  "lib/jekyll/tags/highlight.rb",
51
55
  "lib/jekyll/tags/include.rb",
52
56
  "test/helper.rb",
@@ -133,3 +137,4 @@ Gem::Specification.new do |s|
133
137
  s.add_dependency(%q<open4>, [">= 0.9.6"])
134
138
  end
135
139
  end
140
+
@@ -26,6 +26,7 @@ require 'jekyll/filters'
26
26
  require 'jekyll/tags/highlight'
27
27
  require 'jekyll/tags/include'
28
28
  require 'jekyll/albino'
29
+ require 'jekyll/static_file'
29
30
 
30
31
  module Jekyll
31
32
  # Default options. Overriden by values in _config.yml or command-line opts.
@@ -4,7 +4,7 @@ module Jekyll
4
4
 
5
5
  def self.calculate_pages(all_posts, per_page)
6
6
  num_pages = all_posts.size / per_page.to_i
7
- num_pages.abs + 1 if all_posts.size % per_page.to_i != 0
7
+ num_pages = num_pages + 1 if all_posts.size % per_page.to_i != 0
8
8
  num_pages
9
9
  end
10
10
 
@@ -1,7 +1,7 @@
1
1
  module Jekyll
2
2
 
3
3
  class Site
4
- attr_accessor :config, :layouts, :posts, :categories, :exclude,
4
+ attr_accessor :config, :layouts, :posts, :pages, :static_files, :categories, :exclude,
5
5
  :source, :dest, :lsi, :pygments, :permalink_style, :tags
6
6
 
7
7
  # Initialize the site
@@ -25,6 +25,8 @@ module Jekyll
25
25
  def reset
26
26
  self.layouts = {}
27
27
  self.posts = []
28
+ self.pages = []
29
+ self.static_files = []
28
30
  self.categories = Hash.new { |hash, key| hash[key] = [] }
29
31
  self.tags = Hash.new { |hash, key| hash[key] = [] }
30
32
  end
@@ -87,21 +89,29 @@ module Jekyll
87
89
  end
88
90
 
89
91
  # Do the actual work of processing the site and generating the
90
- # real deal.
92
+ # real deal. Now has 4 phases; reset, read, render, write. This allows
93
+ # rendering to have full site payload available.
91
94
  #
92
95
  # Returns nothing
93
96
  def process
94
97
  self.reset
95
- self.read_layouts
96
- self.transform_pages
97
- self.write_posts
98
+ self.read
99
+ self.render
100
+ self.write
98
101
  end
99
102
 
100
- # Read all the files in <source>/_layouts into memory for later use.
103
+ def read
104
+ self.read_layouts # existing implementation did this at top level only so preserved that
105
+ self.read_directories
106
+ end
107
+
108
+ # Read all the files in <source>/<dir>/_layouts and create a new Layout
109
+ # object with each one.
101
110
  #
102
111
  # Returns nothing
103
- def read_layouts
104
- base = File.join(self.source, "_layouts")
112
+ def read_layouts(dir = '')
113
+ base = File.join(self.source, dir, "_layouts")
114
+ return unless File.exists?(base)
105
115
  entries = []
106
116
  Dir.chdir(base) { entries = filter_entries(Dir['*.*']) }
107
117
 
@@ -109,17 +119,16 @@ module Jekyll
109
119
  name = f.split(".")[0..-2].join(".")
110
120
  self.layouts[name] = Layout.new(self, base, f)
111
121
  end
112
- rescue Errno::ENOENT => e
113
- # ignore missing layout dir
114
122
  end
115
123
 
116
- # Read all the files in <base>/_posts and create a new Post object with each one.
124
+ # Read all the files in <source>/<dir>/_posts and create a new Post
125
+ # object with each one.
117
126
  #
118
127
  # Returns nothing
119
128
  def read_posts(dir)
120
129
  base = File.join(self.source, dir, '_posts')
121
- entries = []
122
- Dir.chdir(base) { entries = filter_entries(Dir['**/*']) }
130
+ return unless File.exists?(base)
131
+ entries = Dir.chdir(base) { filter_entries(Dir['**/*']) }
123
132
 
124
133
  # first pass processes, but does not yet render post content
125
134
  entries.each do |f|
@@ -135,10 +144,11 @@ module Jekyll
135
144
  end
136
145
 
137
146
  self.posts.sort!
147
+ end
138
148
 
139
- # second pass renders each post now that full site payload is available
140
- self.posts.each do |post|
141
- post.render(self.layouts, site_payload)
149
+ def render
150
+ [self.posts, self.pages].flatten.each do |convertible|
151
+ convertible.render(self.layouts, site_payload)
142
152
  end
143
153
 
144
154
  self.categories.values.map { |ps| ps.sort! { |a, b| b <=> a} }
@@ -147,55 +157,50 @@ module Jekyll
147
157
  # ignore missing layout dir
148
158
  end
149
159
 
150
- # Write each post to <dest>/<year>/<month>/<day>/<slug>
160
+ # Write static files, pages and posts
151
161
  #
152
162
  # Returns nothing
153
- def write_posts
163
+ def write
154
164
  self.posts.each do |post|
155
165
  post.write(self.dest)
156
166
  end
167
+ self.pages.each do |page|
168
+ page.write(self.dest)
169
+ end
170
+ self.static_files.each do |sf|
171
+ sf.write(self.dest)
172
+ end
157
173
  end
158
174
 
159
- # Copy all regular files from <source> to <dest>/ ignoring
160
- # any files/directories that are hidden or backup files (start
161
- # with "." or "#" or end with "~") or contain site content (start with "_")
162
- # unless they are "_posts" directories or web server files such as
163
- # '.htaccess'
175
+ # Reads the directories and finds posts, pages and static files that will
176
+ # become part of the valid site according to the rules in +filter_entries+.
164
177
  # The +dir+ String is a relative path used to call this method
165
178
  # recursively as it descends through directories
166
179
  #
167
180
  # Returns nothing
168
- def transform_pages(dir = '')
181
+ def read_directories(dir = '')
169
182
  base = File.join(self.source, dir)
170
183
  entries = filter_entries(Dir.entries(base))
171
- directories = entries.select { |e| File.directory?(File.join(base, e)) }
172
- files = entries.reject { |e| File.directory?(File.join(base, e)) || File.symlink?(File.join(base, e)) }
173
-
174
- # we need to make sure to process _posts *first* otherwise they
175
- # might not be available yet to other templates as {{ site.posts }}
176
- if directories.include?('_posts')
177
- directories.delete('_posts')
178
- read_posts(dir)
179
- end
180
184
 
181
- [directories, files].each do |entries|
182
- entries.each do |f|
183
- if File.directory?(File.join(base, f))
184
- next if self.dest.sub(/\/$/, '') == File.join(base, f)
185
- transform_pages(File.join(dir, f))
186
- elsif Pager.pagination_enabled?(self.config, f)
185
+ self.read_posts(dir)
186
+
187
+ entries.each do |f|
188
+ f_abs = File.join(base, f)
189
+ f_rel = File.join(dir, f)
190
+ if File.directory?(f_abs)
191
+ next if self.dest.sub(/\/$/, '') == f_abs
192
+ read_directories(f_rel)
193
+ elsif !File.symlink?(f_abs)
194
+ if Pager.pagination_enabled?(self.config, f)
187
195
  paginate_posts(f, dir)
188
196
  else
189
- first3 = File.open(File.join(self.source, dir, f)) { |fd| fd.read(3) }
197
+ first3 = File.open(f_abs) { |fd| fd.read(3) }
190
198
  if first3 == "---"
191
199
  # file appears to have a YAML header so process it as a page
192
- page = Page.new(self, self.source, dir, f)
193
- page.render(self.layouts, site_payload)
194
- page.write(self.dest)
200
+ pages << Page.new(self, self.source, dir, f)
195
201
  else
196
- # otherwise copy the file without transforming it
197
- FileUtils.mkdir_p(File.join(self.dest, dir))
198
- FileUtils.cp(File.join(self.source, dir, f), File.join(self.dest, dir, f))
202
+ # otherwise treat it as a static file
203
+ static_files << StaticFile.new(self, self.source, dir, f)
199
204
  end
200
205
  end
201
206
  end
@@ -228,19 +233,19 @@ module Jekyll
228
233
  end
229
234
 
230
235
  # Filter out any files/directories that are hidden or backup files (start
231
- # with "." or "#" or end with "~") or contain site content (start with "_")
232
- # unless they are "_posts" directories or web server files such as
233
- # '.htaccess'
236
+ # with "." or "#" or end with "~"), or contain site content (start with "_"),
237
+ # or are excluded in the site configuration, unless they are web server
238
+ # files such as '.htaccess'
234
239
  def filter_entries(entries)
235
240
  entries = entries.reject do |e|
236
- unless ['_posts', '.htaccess'].include?(e)
241
+ unless ['.htaccess'].include?(e)
237
242
  ['.', '_', '#'].include?(e[0..0]) || e[-1..-1] == '~' || self.exclude.include?(e)
238
243
  end
239
244
  end
240
245
  end
241
246
 
242
247
  # Paginates the blog's posts. Renders the index.html file into paginated directories, ie: page2, page3...
243
- # and adds more wite-wide data
248
+ # and adds more site-wide data
244
249
  #
245
250
  # {"paginator" => { "page" => <Number>,
246
251
  # "per_page" => <Number>,
@@ -252,7 +257,6 @@ module Jekyll
252
257
  def paginate_posts(file, dir)
253
258
  all_posts = self.posts.sort { |a,b| b <=> a }
254
259
  pages = Pager.calculate_pages(all_posts, self.config['paginate'].to_i)
255
- pages += 1
256
260
  (1..pages).each do |num_page|
257
261
  pager = Pager.new(self.config, num_page, all_posts, pages)
258
262
  page = Page.new(self, self.source, dir, file)
@@ -0,0 +1,28 @@
1
+ module Jekyll
2
+
3
+ class StaticFile
4
+ # Initialize a new StaticFile.
5
+ # +site+ is the Site
6
+ # +base+ is the String path to the <source>
7
+ # +dir+ is the String path between <source> and the file
8
+ # +name+ is the String filename of the file
9
+ #
10
+ # Returns <StaticFile>
11
+ def initialize(site, base, dir, name)
12
+ @site = site
13
+ @base = base
14
+ @dir = dir
15
+ @name = name
16
+ end
17
+
18
+ # Write the static file to the destination directory.
19
+ # +dest+ is the String path to the destination dir
20
+ #
21
+ # Returns nothing
22
+ def write(dest)
23
+ FileUtils.mkdir_p(File.join(dest, @dir))
24
+ FileUtils.cp(File.join(@base, @dir, @name), File.join(dest, @dir, @name))
25
+ end
26
+ end
27
+
28
+ end
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- gem 'RedCloth', '= 4.2.1'
2
+ gem 'RedCloth', '>= 4.2.1'
3
3
 
4
4
  require File.join(File.dirname(__FILE__), *%w[.. lib jekyll])
5
5
 
@@ -13,6 +13,10 @@ class TestGeneratedSite < Test::Unit::TestCase
13
13
  @index = File.read(dest_dir('index.html'))
14
14
  end
15
15
 
16
+ should "ensure post count is as expected" do
17
+ assert_equal 17, @site.posts.size
18
+ end
19
+
16
20
  should "insert site.posts into the index" do
17
21
  assert @index.include?("#{@site.posts.size} Posts")
18
22
  end
@@ -1,11 +1,38 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
3
  class TestPager < Test::Unit::TestCase
4
- context "pagination enabled" do
4
+
5
+ should "calculate number of pages" do
6
+ assert_equal(0, Pager.calculate_pages([], '2'))
7
+ assert_equal(1, Pager.calculate_pages([1], '2'))
8
+ assert_equal(1, Pager.calculate_pages([1,2], '2'))
9
+ assert_equal(2, Pager.calculate_pages([1,2,3], '2'))
10
+ assert_equal(2, Pager.calculate_pages([1,2,3,4], '2'))
11
+ assert_equal(3, Pager.calculate_pages([1,2,3,4,5], '2'))
12
+ end
13
+
14
+ context "pagination disabled" do
15
+ setup do
16
+ stub(Jekyll).configuration do
17
+ Jekyll::DEFAULTS.merge({
18
+ 'source' => source_dir,
19
+ 'destination' => dest_dir
20
+ })
21
+ end
22
+ @config = Jekyll.configuration
23
+ end
24
+
25
+ should "report that pagination is disabled" do
26
+ assert !Pager.pagination_enabled?(@config, 'index.html')
27
+ end
28
+
29
+ end
30
+
31
+ context "pagination enabled for 2" do
5
32
  setup do
6
33
  stub(Jekyll).configuration do
7
34
  Jekyll::DEFAULTS.merge({
8
- 'source' => source_dir,
35
+ 'source' => source_dir,
9
36
  'destination' => dest_dir,
10
37
  'paginate' => 2
11
38
  })
@@ -13,35 +40,74 @@ class TestPager < Test::Unit::TestCase
13
40
 
14
41
  @config = Jekyll.configuration
15
42
  @site = Site.new(@config)
16
- @posts = @site.read_posts('')
43
+ @site.process
44
+ @posts = @site.posts
17
45
  end
18
46
 
19
- should "calculate number of pages" do
20
- assert_equal(2, Pager.calculate_pages(@posts, @config['paginate']))
47
+ should "report that pagination is enabled" do
48
+ assert Pager.pagination_enabled?(@config, 'index.html')
21
49
  end
22
50
 
23
- should "create first pager" do
24
- pager = Pager.new(@config, 1, @posts)
25
- assert_equal(@config['paginate'].to_i, pager.posts.size)
26
- assert_equal(2, pager.total_pages)
27
- assert_nil(pager.previous_page)
28
- assert_equal(2, pager.next_page)
29
- end
30
-
31
- should "create second pager" do
32
- pager = Pager.new(@config, 2, @posts)
33
- assert_equal(@posts.size - @config['paginate'].to_i, pager.posts.size)
34
- assert_equal(2, pager.total_pages)
35
- assert_equal(1, pager.previous_page)
36
- assert_nil(pager.next_page)
37
- end
38
-
39
- should "not create third pager" do
40
- assert_raise(RuntimeError) { Pager.new(@config, 3, @posts) }
51
+ context "with 4 posts" do
52
+ setup do
53
+ @posts = @site.posts[1..4] # limit to 4
54
+ end
55
+
56
+ should "create first pager" do
57
+ pager = Pager.new(@config, 1, @posts)
58
+ assert_equal(2, pager.posts.size)
59
+ assert_equal(2, pager.total_pages)
60
+ assert_nil(pager.previous_page)
61
+ assert_equal(2, pager.next_page)
62
+ end
63
+
64
+ should "create second pager" do
65
+ pager = Pager.new(@config, 2, @posts)
66
+ assert_equal(2, pager.posts.size)
67
+ assert_equal(2, pager.total_pages)
68
+ assert_equal(1, pager.previous_page)
69
+ assert_nil(pager.next_page)
70
+ end
71
+
72
+ should "not create third pager" do
73
+ assert_raise(RuntimeError) { Pager.new(@config, 3, @posts) }
74
+ end
75
+
41
76
  end
42
-
43
- should "report that pagination is enabled" do
44
- assert Pager.pagination_enabled?(@config, 'index.html')
77
+
78
+ context "with 5 posts" do
79
+ setup do
80
+ @posts = @site.posts[1..5] # limit to 5
81
+ end
82
+
83
+ should "create first pager" do
84
+ pager = Pager.new(@config, 1, @posts)
85
+ assert_equal(2, pager.posts.size)
86
+ assert_equal(3, pager.total_pages)
87
+ assert_nil(pager.previous_page)
88
+ assert_equal(2, pager.next_page)
89
+ end
90
+
91
+ should "create second pager" do
92
+ pager = Pager.new(@config, 2, @posts)
93
+ assert_equal(2, pager.posts.size)
94
+ assert_equal(3, pager.total_pages)
95
+ assert_equal(1, pager.previous_page)
96
+ assert_equal(3, pager.next_page)
97
+ end
98
+
99
+ should "create third pager" do
100
+ pager = Pager.new(@config, 3, @posts)
101
+ assert_equal(1, pager.posts.size)
102
+ assert_equal(3, pager.total_pages)
103
+ assert_equal(2, pager.previous_page)
104
+ assert_nil(pager.next_page)
105
+ end
106
+
107
+ should "not create fourth pager" do
108
+ assert_raise(RuntimeError) { Pager.new(@config, 4, @posts) }
109
+ end
110
+
45
111
  end
46
112
  end
47
113
  end
@@ -19,11 +19,17 @@ class TestSite < Test::Unit::TestCase
19
19
  before_posts = @site.posts.length
20
20
  before_layouts = @site.layouts.length
21
21
  before_categories = @site.categories.length
22
+ before_tags = @site.tags.length
23
+ before_pages = @site.pages.length
24
+ before_static_files = @site.static_files.length
22
25
 
23
26
  @site.process
24
27
  assert_equal before_posts, @site.posts.length
25
28
  assert_equal before_layouts, @site.layouts.length
26
29
  assert_equal before_categories, @site.categories.length
30
+ assert_equal before_tags, @site.tags.length
31
+ assert_equal before_pages, @site.pages.length
32
+ assert_equal before_static_files, @site.static_files.length
27
33
  end
28
34
 
29
35
  should "read layouts" do
@@ -52,10 +58,10 @@ class TestSite < Test::Unit::TestCase
52
58
  should "filter entries" do
53
59
  ent1 = %w[foo.markdown bar.markdown baz.markdown #baz.markdown#
54
60
  .baz.markdow foo.markdown~]
55
- ent2 = %w[.htaccess _posts bla.bla]
61
+ ent2 = %w[.htaccess _posts _pages bla.bla]
56
62
 
57
63
  assert_equal %w[foo.markdown bar.markdown baz.markdown], @site.filter_entries(ent1)
58
- assert_equal ent2, @site.filter_entries(ent2)
64
+ assert_equal %w[.htaccess bla.bla], @site.filter_entries(ent2)
59
65
  end
60
66
 
61
67
  should "filter entries with exclude" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-24 00:00:00 -07:00
12
+ date: 2010-01-08 00:00:00 -08:00
13
13
  default_executable: jekyll
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -113,6 +113,7 @@ files:
113
113
  - lib/jekyll/pager.rb
114
114
  - lib/jekyll/post.rb
115
115
  - lib/jekyll/site.rb
116
+ - lib/jekyll/static_file.rb
116
117
  - lib/jekyll/tags/highlight.rb
117
118
  - lib/jekyll/tags/include.rb
118
119
  - test/helper.rb