bunto-paginate 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9fd58dd5cdd829e64b7febce0b29c48baaec91cb
4
+ data.tar.gz: f86c921fec5e1d9092d49fce3f73c3ac02fad83b
5
+ SHA512:
6
+ metadata.gz: cb484aa2ce8cb11220e12765ae946e88e263fb08244db274fbcb7d787786c1c2201412e3f5ea0870cc8d77b7fadf17f26a278e85898a507538119e839d38de3a
7
+ data.tar.gz: 7909696e9786fa7186c3332ffca2578638226aeb9085f86923b08363b4df1ebf0af35d8a35d937b05fee0c28ca9d13097060b07b21c7d99f6b4aed0cc373d44a
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ spec/dest
16
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,36 @@
1
+ language: ruby
2
+ cache: bundler
3
+ sudo: false
4
+ rvm:
5
+ - 2.2
6
+ - 2.1
7
+ - 2.0
8
+ - 1.9.3
9
+ before_script: bundle update
10
+ script: script/cibuild
11
+ notifications:
12
+ irc:
13
+ on_success: change
14
+ on_failure: change
15
+ channels:
16
+ - irc.freenode.org#bunto
17
+ template:
18
+ - '%{repository}#%{build_number} (%{branch}) %{message} %{build_url}'
19
+ email:
20
+ on_success: never
21
+ on_failure: never
22
+
23
+ matrix:
24
+ exclude:
25
+ - rvm: 1.9.3
26
+ env: BUNTO_VERSION=2.0.0
27
+ - env: BUNTO_VERSION=1.0.0
28
+ rvm: 2.1
29
+ - rvm: 2.2
30
+ env: BUNTO_VERSION=2.4
31
+
32
+ env:
33
+ matrix:
34
+ - ""
35
+ - BUNTO_VERSION=2.4
36
+ - BUNTO_VERSION=3.0.0
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bunto-paginate.gemspec
4
+ gemspec
5
+
6
+ if ENV["BUNTO_VERSION"]
7
+ gem "bunto", "~> #{ENV["BUNTO_VERSION"]}"
8
+ end
data/History.markdown ADDED
@@ -0,0 +1,3 @@
1
+ ## 1.0.0 / 2016-02-08
2
+
3
+ * Birthday!
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016-present Parker Moore
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Bunto::Paginate
2
+
3
+ Default pagination generator for Bunto.
4
+
5
+ [![Build Status](https://secure.travis-ci.org/bunto/bunto-paginate.svg?branch=master)](https://travis-ci.org/bunto/bunto-paginate)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'bunto-paginate'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install bunto-paginate
20
+
21
+ ## Usage
22
+
23
+ Once the gem is installed on your system, Bunto will auto-require it. Just set the following configuration
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( http://github.com/bunto/bunto-paginate/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bunto-paginate/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bunto-paginate"
8
+ spec.version = Bunto::Paginate::VERSION
9
+ spec.authors = ["Parker Moore", "Suriyaa Kudo"]
10
+ spec.email = ["parkrmoore@gmail.com", "SuriyaaKudoIsc@users.noreply.github.com"]
11
+ spec.summary = %q{Built-in Pagination Generator for Bunto}
12
+ spec.homepage = "https://github.com/bunto/bunto-paginate"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bunto", "~> 1.0"
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+ end
@@ -0,0 +1,8 @@
1
+ require "bunto-paginate/version"
2
+ require "bunto-paginate/pager"
3
+ require "bunto-paginate/pagination"
4
+
5
+ module Bunto
6
+ module Paginate
7
+ end
8
+ end
@@ -0,0 +1,141 @@
1
+ module Bunto
2
+ module Paginate
3
+ class Pager
4
+ attr_reader :page, :per_page, :posts, :total_posts, :total_pages,
5
+ :previous_page, :previous_page_path, :next_page, :next_page_path
6
+
7
+ # Calculate the number of pages.
8
+ #
9
+ # all_posts - The Array of all Posts.
10
+ # per_page - The Integer of entries per page.
11
+ #
12
+ # Returns the Integer number of pages.
13
+ def self.calculate_pages(all_posts, per_page)
14
+ (all_posts.size.to_f / per_page.to_i).ceil
15
+ end
16
+
17
+ # Determine if pagination is enabled the site.
18
+ #
19
+ # site - the Bunto::Site object
20
+ #
21
+ # Returns true if pagination is enabled, false otherwise.
22
+ def self.pagination_enabled?(site)
23
+ !site.config['paginate'].nil? &&
24
+ site.pages.size > 0
25
+ end
26
+
27
+ # Static: Determine if a page is a possible candidate to be a template page.
28
+ # Page's name must be `index.html` and exist in any of the directories
29
+ # between the site source and `paginate_path`.
30
+ #
31
+ # config - the site configuration hash
32
+ # page - the Bunto::Page about which we're inquiring
33
+ #
34
+ # Returns true if the
35
+ def self.pagination_candidate?(config, page)
36
+ page_dir = File.dirname(File.expand_path(remove_leading_slash(page.path), config['source']))
37
+ paginate_path = remove_leading_slash(config['paginate_path'])
38
+ paginate_path = File.expand_path(paginate_path, config['source'])
39
+ page.name == 'index.html' &&
40
+ in_hierarchy(config['source'], page_dir, File.dirname(paginate_path))
41
+ end
42
+
43
+ # Determine if the subdirectories of the two paths are the same relative to source
44
+ #
45
+ # source - the site source
46
+ # page_dir - the directory of the Bunto::Page
47
+ # paginate_path - the absolute paginate path (from root of FS)
48
+ #
49
+ # Returns whether the subdirectories are the same relative to source
50
+ def self.in_hierarchy(source, page_dir, paginate_path)
51
+ return false if paginate_path == File.dirname(paginate_path)
52
+ return false if paginate_path == Pathname.new(source).parent
53
+ page_dir == paginate_path ||
54
+ in_hierarchy(source, page_dir, File.dirname(paginate_path))
55
+ end
56
+
57
+ # Static: Return the pagination path of the page
58
+ #
59
+ # site - the Bunto::Site object
60
+ # num_page - the pagination page number
61
+ #
62
+ # Returns the pagination path as a string
63
+ def self.paginate_path(site, num_page)
64
+ return nil if num_page.nil?
65
+ return Pagination.first_page_url(site) if num_page <= 1
66
+ format = site.config['paginate_path']
67
+ if format.include?(":num")
68
+ format = format.sub(':num', num_page.to_s)
69
+ else
70
+ raise ArgumentError.new("Invalid pagination path: '#{format}'. It must include ':num'.")
71
+ end
72
+ ensure_leading_slash(format)
73
+ end
74
+
75
+ # Static: Return a String version of the input which has a leading slash.
76
+ # If the input already has a forward slash in position zero, it will be
77
+ # returned unchanged.
78
+ #
79
+ # path - a String path
80
+ #
81
+ # Returns the path with a leading slash
82
+ def self.ensure_leading_slash(path)
83
+ path[0..0] == "/" ? path : "/#{path}"
84
+ end
85
+
86
+ # Static: Return a String version of the input without a leading slash.
87
+ #
88
+ # path - a String path
89
+ #
90
+ # Returns the input without the leading slash
91
+ def self.remove_leading_slash(path)
92
+ ensure_leading_slash(path)[1..-1]
93
+ end
94
+
95
+ # Initialize a new Pager.
96
+ #
97
+ # site - the Bunto::Site object
98
+ # page - The Integer page number.
99
+ # all_posts - The Array of all the site's Posts.
100
+ # num_pages - The Integer number of pages or nil if you'd like the number
101
+ # of pages calculated.
102
+ def initialize(site, page, all_posts, num_pages = nil)
103
+ @page = page
104
+ @per_page = site.config['paginate'].to_i
105
+ @total_pages = num_pages || Pager.calculate_pages(all_posts, @per_page)
106
+
107
+ if @page > @total_pages
108
+ raise RuntimeError, "page number can't be greater than total pages: #{@page} > #{@total_pages}"
109
+ end
110
+
111
+ init = (@page - 1) * @per_page
112
+ offset = (init + @per_page - 1) >= all_posts.size ? all_posts.size : (init + @per_page - 1)
113
+
114
+ @total_posts = all_posts.size
115
+ @posts = all_posts[init..offset]
116
+ @previous_page = @page != 1 ? @page - 1 : nil
117
+ @previous_page_path = Pager.paginate_path(site, @previous_page)
118
+ @next_page = @page != @total_pages ? @page + 1 : nil
119
+ @next_page_path = Pager.paginate_path(site, @next_page)
120
+ end
121
+
122
+ # Convert this Pager's data to a Hash suitable for use by Liquid.
123
+ #
124
+ # Returns the Hash representation of this Pager.
125
+ def to_liquid
126
+ {
127
+ 'page' => page,
128
+ 'per_page' => per_page,
129
+ 'posts' => posts,
130
+ 'total_posts' => total_posts,
131
+ 'total_pages' => total_pages,
132
+ 'previous_page' => previous_page,
133
+ 'previous_page_path' => previous_page_path,
134
+ 'next_page' => next_page,
135
+ 'next_page_path' => next_page_path
136
+ }
137
+ end
138
+
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,85 @@
1
+ module Bunto
2
+ module Paginate
3
+ class Pagination < Generator
4
+ # This generator is safe from arbitrary code execution.
5
+ safe true
6
+
7
+ # This generator should be passive with regard to its execution
8
+ priority :lowest
9
+
10
+ # Generate paginated pages if necessary.
11
+ #
12
+ # site - The Site.
13
+ #
14
+ # Returns nothing.
15
+ def generate(site)
16
+ if Pager.pagination_enabled?(site)
17
+ if template = self.class.template_page(site)
18
+ paginate(site, template)
19
+ else
20
+ Bunto.logger.warn "Pagination:", "Pagination is enabled, but I couldn't find " +
21
+ "an index.html page to use as the pagination template. Skipping pagination."
22
+ end
23
+ end
24
+ end
25
+
26
+ # Paginates the blog's posts. Renders the index.html file into paginated
27
+ # directories, e.g.: page2/index.html, page3/index.html, etc and adds more
28
+ # site-wide data.
29
+ #
30
+ # site - The Site.
31
+ # page - The index.html Page that requires pagination.
32
+ #
33
+ # {"paginator" => { "page" => <Number>,
34
+ # "per_page" => <Number>,
35
+ # "posts" => [<Post>],
36
+ # "total_posts" => <Number>,
37
+ # "total_pages" => <Number>,
38
+ # "previous_page" => <Number>,
39
+ # "next_page" => <Number> }}
40
+ def paginate(site, page)
41
+ all_posts = site.site_payload['site']['posts'].reject { |post| post['hidden'] }
42
+ pages = Pager.calculate_pages(all_posts, site.config['paginate'].to_i)
43
+ (1..pages).each do |num_page|
44
+ pager = Pager.new(site, num_page, all_posts, pages)
45
+ if num_page > 1
46
+ newpage = Page.new(site, site.source, page.dir, page.name)
47
+ newpage.pager = pager
48
+ newpage.dir = Pager.paginate_path(site, num_page)
49
+ site.pages << newpage
50
+ else
51
+ page.pager = pager
52
+ end
53
+ end
54
+ end
55
+
56
+ # Static: Fetch the URL of the template page. Used to determine the
57
+ # path to the first pager in the series.
58
+ #
59
+ # site - the Bunto::Site object
60
+ #
61
+ # Returns the url of the template page
62
+ def self.first_page_url(site)
63
+ if page = Pagination.template_page(site)
64
+ page.url
65
+ else
66
+ nil
67
+ end
68
+ end
69
+
70
+ # Public: Find the Bunto::Page which will act as the pager template
71
+ #
72
+ # site - the Bunto::Site object
73
+ #
74
+ # Returns the Bunto::Page which will act as the pager template
75
+ def self.template_page(site)
76
+ site.pages.select do |page|
77
+ Pager.pagination_candidate?(site.config, page)
78
+ end.sort do |one, two|
79
+ two.path.size <=> one.path.size
80
+ end.first
81
+ end
82
+
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,5 @@
1
+ module Bunto
2
+ module Paginate
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
data/script/bootstrap ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle install
data/script/cibuild ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rspec
@@ -0,0 +1,178 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe(Bunto::Paginate::Pager) do
4
+
5
+ it "calculate number of pages" do
6
+ expect(described_class.calculate_pages([], '2')).to eql(0)
7
+ expect(described_class.calculate_pages([1], '2')).to eql(1)
8
+ expect(described_class.calculate_pages([1,2], '2')).to eql(1)
9
+ expect(described_class.calculate_pages([1,2,3], '2')).to eql(2)
10
+ expect(described_class.calculate_pages([1,2,3,4], '2')).to eql(2)
11
+ expect(described_class.calculate_pages([1,2,3,4,5], '2')).to eql(3)
12
+ end
13
+
14
+ context "with the default paginate_path" do
15
+ let(:site) { build_site }
16
+
17
+ it "determines the correct pagination path for each page" do
18
+ if Bunto::VERSION < '3.0.0'
19
+ expect(described_class.paginate_path(site, 1)).to eql("/index.html")
20
+ else
21
+ expect(described_class.paginate_path(site, 1)).to eql("/")
22
+ end
23
+
24
+ expect(described_class.paginate_path(site, 2)).to eql("/page2")
25
+ end
26
+ end
27
+
28
+ context "with paginate_path set to a subdirectory with no index.html" do
29
+ let(:site) { build_site({'paginate_path' => '/blog/page-:num'}) }
30
+
31
+ it "determines the correct pagination path for each page" do
32
+ if Bunto::VERSION < '3.0.0'
33
+ expect(described_class.paginate_path(site, 1)).to eql("/index.html")
34
+ else
35
+ expect(described_class.paginate_path(site, 1)).to eql("/")
36
+ end
37
+
38
+ expect(described_class.paginate_path(site, 2)).to eql("/blog/page-2")
39
+ end
40
+ end
41
+
42
+ context "with paginate_path set to a subdirectory with no index.html with num pages being in subdirectories" do
43
+ let(:site) { build_site({'paginate_path' => '/blog/page/:num'}) }
44
+
45
+ it "determines the correct pagination path for each page" do
46
+ if Bunto::VERSION < '3.0.0'
47
+ expect(described_class.paginate_path(site, 1)).to eql("/index.html")
48
+ else
49
+ expect(described_class.paginate_path(site, 1)).to eql("/")
50
+ end
51
+
52
+ expect(described_class.paginate_path(site, 2)).to eql("/blog/page/2")
53
+ end
54
+ end
55
+
56
+ context "with paginate_path set to a subdirectory wherein an index.html exists" do
57
+ let(:site) { build_site({'paginate_path' => '/contacts/page:num'}) }
58
+
59
+ it "determines the correct pagination path for each page" do
60
+ if Bunto::VERSION < '3.0.0'
61
+ expect(described_class.paginate_path(site, 1)).to eql("/contacts/index.html")
62
+ else
63
+ expect(described_class.paginate_path(site, 1)).to eql("/contacts/")
64
+ end
65
+
66
+ expect(described_class.paginate_path(site, 2)).to eql("/contacts/page2")
67
+ end
68
+ end
69
+
70
+ context "with paginate_path set to a subdir wherein an index.html exists with pages in subdirs" do
71
+ let(:site) { build_site({'paginate_path' => '/contacts/page/:num'}) }
72
+
73
+ it "determines the correct pagination path for each page" do
74
+ if Bunto::VERSION < '3.0.0'
75
+ expect(described_class.paginate_path(site, 1)).to eql("/contacts/index.html")
76
+ else
77
+ expect(described_class.paginate_path(site, 1)).to eql("/contacts/")
78
+ end
79
+
80
+ expect(described_class.paginate_path(site, 2)).to eql("/contacts/page/2")
81
+ end
82
+ end
83
+
84
+ context "with an paginate_path devoid of :num" do
85
+ let(:site) { build_site({'paginate_path' => '/blog/page'}) }
86
+
87
+ it "determines the correct pagination path for each page" do
88
+ expect(-> { described_class.paginate_path(site, 1) }).to raise_error
89
+ end
90
+ end
91
+
92
+ context "pagination disabled" do
93
+ let(:site) { build_site('paginate' => nil) }
94
+
95
+ it "report that pagination is disabled" do
96
+ expect(described_class.pagination_enabled?(site)).to be_falsey
97
+ end
98
+ end
99
+
100
+ context "pagination enabled for 2" do
101
+ let(:site) { build_site('paginate' => 2) }
102
+ if Bunto::VERSION < '3.0.0'
103
+ let(:posts) { site.posts }
104
+ else
105
+ let(:posts) { site.posts.docs }
106
+ end
107
+
108
+ it "report that pagination is enabled" do
109
+ expect(described_class.pagination_enabled?(site)).to be_truthy
110
+ end
111
+
112
+ context "with 4 posts" do
113
+ if Bunto::VERSION < '3.0.0'
114
+ let(:posts) { site.posts[1..4] }
115
+ else
116
+ let(:posts) { site.posts.docs[1..4] }
117
+ end
118
+
119
+ it "create first pager" do
120
+ pager = described_class.new(site, 1, posts)
121
+ expect(pager.posts.size).to eql(2)
122
+ expect(pager.total_pages).to eql(2)
123
+ expect(pager.previous_page).to be_nil
124
+ expect(pager.next_page).to eql(2)
125
+ end
126
+
127
+ it "create second pager" do
128
+ pager = described_class.new(site, 2, posts)
129
+ expect(pager.posts.size).to eql(2)
130
+ expect(pager.total_pages).to eql(2)
131
+ expect(pager.previous_page).to eql(1)
132
+ expect(pager.next_page).to be_nil
133
+ end
134
+
135
+ it "not create third pager" do
136
+ expect { described_class.new(site, 3, posts) }.to raise_error
137
+ end
138
+ end
139
+
140
+ context "with 5 posts" do
141
+ if Bunto::VERSION < '3.0.0'
142
+ let(:posts) { site.posts[1..5] }
143
+ else
144
+ let(:posts) { site.posts.docs[1..5] }
145
+ end
146
+
147
+ it "create first pager" do
148
+ pager = described_class.new(site, 1, posts)
149
+ expect(pager.posts.size).to eql(2)
150
+ expect(pager.total_pages).to eql(3)
151
+ expect(pager.previous_page).to be_nil
152
+ expect(pager.next_page).to eql(2)
153
+ end
154
+
155
+ it "create second pager" do
156
+ pager = described_class.new(site, 2, posts)
157
+ expect(pager.posts.size).to eql(2)
158
+ expect(pager.total_pages).to eql(3)
159
+ expect(pager.previous_page).to eql(1)
160
+ expect(pager.next_page).to eql(3)
161
+ end
162
+
163
+ it "create third pager" do
164
+ pager = described_class.new(site, 3, posts)
165
+ expect(pager.posts.size).to eql(1)
166
+ expect(pager.total_pages).to eql(3)
167
+ expect(pager.previous_page).to eql(2)
168
+ expect(pager.next_page).to be_nil
169
+ end
170
+
171
+ it "not create fourth pager" do
172
+ expect { described_class.new(site, 4, posts) }.to raise_error(RuntimeError)
173
+ end
174
+
175
+ end
176
+ end
177
+
178
+ end
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,2 @@
1
+ ---
2
+ ---
@@ -0,0 +1,2 @@
1
+ ---
2
+ ---
@@ -0,0 +1,97 @@
1
+ require 'bunto'
2
+ require File.expand_path("../lib/bunto-paginate", File.dirname(__FILE__))
3
+
4
+ module TestMethods
5
+ def test_dir(*subdirs)
6
+ File.join(File.dirname(__FILE__), *subdirs)
7
+ end
8
+
9
+ def dest_dir(*subdirs)
10
+ test_dir('dest', *subdirs)
11
+ end
12
+
13
+ def source_dir(*subdirs)
14
+ test_dir('source', *subdirs)
15
+ end
16
+
17
+ def build_configs(overrides, base_hash = Bunto::Configuration::DEFAULTS)
18
+ Bunto::Utils.deep_merge_hashes(base_hash, overrides)
19
+ end
20
+
21
+ def site_configuration(overrides = {})
22
+ build_configs({
23
+ "source" => source_dir,
24
+ "destination" => dest_dir
25
+ }, build_configs(overrides))
26
+ end
27
+
28
+ def build_site(config = {})
29
+ site = Bunto::Site.new(site_configuration(
30
+ {"paginate" => 1}.merge(config)
31
+ ))
32
+ site.process
33
+ site
34
+ end
35
+ end
36
+
37
+ RSpec.configure do |config|
38
+ config.expect_with :rspec do |expectations|
39
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
40
+ end
41
+
42
+ # rspec-mocks config goes here. You can use an alternate test double
43
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
44
+ config.mock_with :rspec do |mocks|
45
+ # Prevents you from mocking or stubbing a method that does not exist on
46
+ # a real object. This is generally recommended, and will default to
47
+ # `true` in RSpec 4.
48
+ mocks.verify_partial_doubles = true
49
+ end
50
+
51
+ # These two settings work together to allow you to limit a spec run
52
+ # to individual examples or groups you care about by tagging them with
53
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
54
+ # get run.
55
+ config.filter_run :focus
56
+ config.run_all_when_everything_filtered = true
57
+
58
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
59
+ # For more details, see:
60
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
61
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
62
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
63
+ config.disable_monkey_patching!
64
+
65
+ # This setting enables warnings. It's recommended, but in some cases may
66
+ # be too noisy due to issues in dependencies.
67
+ # config.warnings = true
68
+
69
+ # Many RSpec users commonly either run the entire suite or an individual
70
+ # file, and it's useful to allow more verbose output when running an
71
+ # individual spec file.
72
+ if config.files_to_run.one?
73
+ # Use the documentation formatter for detailed output,
74
+ # unless a formatter has already been configured
75
+ # (e.g. via a command-line flag).
76
+ config.default_formatter = 'doc'
77
+ end
78
+
79
+ # Print the 10 slowest examples and example groups at the
80
+ # end of the spec run, to help surface which specs are running
81
+ # particularly slow.
82
+ config.profile_examples = 10
83
+
84
+ # Run specs in random order to surface order dependencies. If you find an
85
+ # order dependency and want to debug it, you can fix the order by providing
86
+ # the seed, which is printed after each run.
87
+ # --seed 1234
88
+ config.order = :random
89
+
90
+ # Seed global randomization in this process using the `--seed` CLI option.
91
+ # Setting this allows you to use `--seed` to deterministically reproduce
92
+ # test failures related to randomization by passing the same `--seed` value
93
+ # as the one that triggered the failure.
94
+ Kernel.srand config.seed
95
+
96
+ include TestMethods
97
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bunto-paginate
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Parker Moore
8
+ - Suriyaa Kudo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-02-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bunto
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.5'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.5'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '3.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3.0'
70
+ description:
71
+ email:
72
+ - parkrmoore@gmail.com
73
+ - SuriyaaKudoIsc@users.noreply.github.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - Gemfile
82
+ - History.markdown
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bunto-paginate.gemspec
87
+ - lib/bunto-paginate.rb
88
+ - lib/bunto-paginate/pager.rb
89
+ - lib/bunto-paginate/pagination.rb
90
+ - lib/bunto-paginate/version.rb
91
+ - script/bootstrap
92
+ - script/cibuild
93
+ - spec/pager_spec.rb
94
+ - spec/pagination_spec.rb
95
+ - spec/source/_posts/2014-05-20-blah.html
96
+ - spec/source/_posts/2014-05-21-bleh.html
97
+ - spec/source/_posts/2014-05-22-humor.html
98
+ - spec/source/_posts/2014-05-23-hey-there.html
99
+ - spec/source/_posts/2014-05-24-whateva.html
100
+ - spec/source/_posts/2014-05-25-oh-yes.html
101
+ - spec/source/contacts/index.html
102
+ - spec/source/index.html
103
+ - spec/spec_helper.rb
104
+ homepage: https://github.com/bunto/bunto-paginate
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.2.2
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Built-in Pagination Generator for Bunto
128
+ test_files:
129
+ - spec/pager_spec.rb
130
+ - spec/pagination_spec.rb
131
+ - spec/source/_posts/2014-05-20-blah.html
132
+ - spec/source/_posts/2014-05-21-bleh.html
133
+ - spec/source/_posts/2014-05-22-humor.html
134
+ - spec/source/_posts/2014-05-23-hey-there.html
135
+ - spec/source/_posts/2014-05-24-whateva.html
136
+ - spec/source/_posts/2014-05-25-oh-yes.html
137
+ - spec/source/contacts/index.html
138
+ - spec/source/index.html
139
+ - spec/spec_helper.rb