dimples 13.1.1 → 14.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a3a083ef71c4142029367c026394e4d499f4e8760ff3bf54712d3ee319322b8
4
- data.tar.gz: c8f2e5ee9b6fbfd7e35a4d496798ebd02cb2773d6f532d12138bf1db21b800fb
3
+ metadata.gz: 0cd730bee9db2d40308b4d6d5154ce35244821b905902e7bd395452aaf726ec5
4
+ data.tar.gz: e04f9a1b4a538f9aab53ef2d4db00a9309f9cd6f8ac24372c23d908e21970a52
5
5
  SHA512:
6
- metadata.gz: ebfa89f7de5099291e8416980b7e2fd9f129f2f1c436e1ac1815cd8688bd3eaecc1f7bd8283de1dd7a9b1759c66878337cd9aa8249521d7bb4d2ad18aa457581
7
- data.tar.gz: ec7e6e716c5c533e9013d6008deffb11741244963a2cf79869c85a5e2a3fa2e6e75e74ee66d8633fe9cb96b0b5f2e4685329f8f04c9c3ffd88a07d3a9464276d
6
+ metadata.gz: 850ea7a7863edd50da38a88c485d3d09e3456581cabf3636a2751def1e5d099e8dc98ef4a49227018231754a59c9823cbaed39e59f04647137fe6c48316bdb12
7
+ data.tar.gz: 23d23a7c7b6ce4807f8b604043789fde1758782a7e2a5972d73a64b23a4a44e7cefa11bd9d3497d30d4e996b76d227dddf660204e014635308f19d8ce492bc15
data/lib/dimples/pager.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- # A class for paginating a collection of posts.
4
+ # A class for paginating a collection of items.
5
5
  class Pager
6
6
  include Enumerable
7
7
 
@@ -9,17 +9,17 @@ module Dimples
9
9
 
10
10
  attr_reader :current_page, :previous_page, :next_page, :page_count
11
11
 
12
- def self.paginate(url:, posts:, options: {}, payload: {}, &block)
13
- new(url: url, posts: posts, options: options).paginate(payload: payload, &block)
12
+ def self.paginate(url:, items:, options: {}, payload: {}, &block)
13
+ new(url: url, items: items, options: options).paginate(payload: payload, &block)
14
14
  end
15
15
 
16
- def initialize(url:, posts:, options: {})
16
+ def initialize(url:, items:, options: {})
17
17
  @url = url
18
18
  @url << '/' unless @url[-1] == '/'
19
19
 
20
- @posts = posts
20
+ @items = items
21
21
  @options = DEFAULT_OPTIONS.merge(options)
22
- @page_count = (posts.length.to_f / @options[:per_page].to_i).ceil
22
+ @page_count = (items.length.to_f / @options[:per_page].to_i).ceil
23
23
 
24
24
  step_to(1)
25
25
  end
@@ -40,8 +40,8 @@ module Dimples
40
40
  @current_page
41
41
  end
42
42
 
43
- def posts_at(page)
44
- @posts.slice((page - 1) * @options[:per_page], @options[:per_page])
43
+ def items_at(page)
44
+ @items.slice((page - 1) * @options[:per_page], @options[:per_page])
45
45
  end
46
46
 
47
47
  def previous_page?
@@ -90,11 +90,11 @@ module Dimples
90
90
 
91
91
  def metadata
92
92
  {
93
- posts: posts_at(current_page),
94
93
  pagination: Context.from_hash(
94
+ items: items_at(current_page),
95
95
  current_page: @current_page,
96
96
  page_count: @page_count,
97
- post_count: @posts.count,
97
+ item_count: @items.count,
98
98
  previous_page: @previous_page,
99
99
  next_page: @next_page,
100
100
  urls: urls
data/lib/dimples/site.rb CHANGED
@@ -50,7 +50,7 @@ module Dimples
50
50
  end
51
51
 
52
52
  def data
53
- @data ||= scan_path(path: @config.source_paths[:data], extension: 'json') do |path|
53
+ @data ||= scan_path(path: @config.source_paths[:data], extension: '.json') do |path|
54
54
  Context.from_hash(JSON.parse(File.read(path)))
55
55
  end
56
56
  end
@@ -81,11 +81,11 @@ module Dimples
81
81
  Dir.children(path).each do |child|
82
82
  child_path = File.join(path, child)
83
83
 
84
- key = File.basename(child_path, ".#{extension}").to_sym
84
+ key = File.basename(child_path, extension).to_sym
85
85
  data[key] = if File.directory?(child_path)
86
86
  scan_path(path: child_path, extension:, &block)
87
87
  else
88
- yield child_path if block_given?
88
+ yield child_path if block_given? && File.extname(child_path) == extension
89
89
  end
90
90
  end
91
91
  end
@@ -96,7 +96,7 @@ module Dimples
96
96
 
97
97
  url = @config.build_paths[:posts].gsub(@config.build_paths[:root], '').concat('/')
98
98
 
99
- Pager.paginate(url: url, posts: posts, options: @config.pagination) do |url, payload|
99
+ Pager.paginate(url: url, items: posts, options: @config.pagination) do |url, payload|
100
100
  templates[:posts].generate(
101
101
  output_path: File.join(@config.build_paths[:root], url),
102
102
  payload: payload
@@ -134,7 +134,7 @@ module Dimples
134
134
  categories.each do |category, posts|
135
135
  Pager.paginate(
136
136
  url: "/categories/#{category}/",
137
- posts: posts,
137
+ items: posts,
138
138
  payload: { title: category.capitalize, category: category },
139
139
  options: @config.pagination
140
140
  ) do |url, payload|
@@ -23,6 +23,8 @@ module Dimples
23
23
  end
24
24
 
25
25
  ERB.new(contents).result(binding)
26
+ rescue => e
27
+ raise "Failed to render template at #{path}: #{e}"
26
28
  end
27
29
  end
28
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- VERSION = '13.1.1'
4
+ VERSION = '14.0.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dimples
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.1.1
4
+ version: 14.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bogan