dimples 5.1.0 → 5.1.1

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
- SHA256:
3
- metadata.gz: 6b63753932d375ea07672f810b718d628711fcfea4eca7903d4f42816eda0f48
4
- data.tar.gz: 5ccf23b0581915612adb9b7c4a6d045c2e0316b8d43cb58b764e16a40ffa0413
2
+ SHA1:
3
+ metadata.gz: 838304f8086ccf74e9a4c44feee78027747a3625
4
+ data.tar.gz: cfa7dc4bbedeb98446526fb1380c49c5070f1d6b
5
5
  SHA512:
6
- metadata.gz: 3647f33e23be41293053ba18653debd6388b7419011a56462a1aecd448ec1d908e9c66ac893136ed26e1b05630d1c14e0370aba31b0da2285a5056258aa6997e
7
- data.tar.gz: c183aa6bce34f42eefd0620a4e290ce85893969ddcb30656b3b5443ec29a93e9da1013e9ddcd370f673fee5a00410e94619003a8fb234d0bf7f428ccc78b300e
6
+ metadata.gz: 5ba760bbb200a9b9464325cc121529ca7616854354e53e4613a923b16f85c11bfe626478bf8df19b124b1b3c68559b777c2b328b9399f1c1a42a588229bc9cc9
7
+ data.tar.gz: 12484fa4f299017f487b0a95839d5d22c47f6d61b584ab764037ee60f34a20862d7b8b80391e264f4caacdeb501dd7985d519c57d10ce17ffa3594e3d175e600
@@ -3,8 +3,8 @@
3
3
  module Dimples
4
4
  # A single post category for a site.
5
5
  class Category
6
- attr_accessor :name
7
- attr_accessor :slug
6
+ attr_reader :name
7
+ attr_reader :slug
8
8
  attr_accessor :posts
9
9
 
10
10
  def initialize(site, slug)
data/lib/dimples/pager.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  module Dimples
4
4
  # A paginated collection of posts that can be walked forward or backwards.
5
5
  class Pager
6
+ PER_PAGE_DEFAULT = 10
7
+
6
8
  include Enumerable
7
9
 
8
10
  attr_reader :current_page
@@ -14,7 +16,7 @@ module Dimples
14
16
  def initialize(url, posts, options = {})
15
17
  @url = url
16
18
  @posts = posts
17
- @per_page = options[:per_page] || 10
19
+ @per_page = options[:per_page] || PER_PAGE_DEFAULT
18
20
  @page_prefix = options[:page_prefix] || 'page'
19
21
  @page_count = (posts.length.to_f / @per_page.to_i).ceil
20
22
 
@@ -22,9 +24,7 @@ module Dimples
22
24
  end
23
25
 
24
26
  def each(&block)
25
- (1..@page_count).each do |index|
26
- block.yield step_to(index)
27
- end
27
+ (1..@page_count).each { |index| block.yield step_to(index) }
28
28
  end
29
29
 
30
30
  def step_to(page)
@@ -12,18 +12,12 @@ module Dimples
12
12
  after_page_write
13
13
  ].freeze
14
14
 
15
- def self.inherited(subclass)
16
- (@subclasses ||= []) << subclass
17
- end
18
-
19
- def self.plugins(site)
20
- @plugins ||= @subclasses&.map { |subclass| subclass.new(site) }
15
+ class << self
16
+ attr_reader :subclasses
21
17
  end
22
18
 
23
- def self.send_event(site, event, item = nil)
24
- plugins(site)&.each do |plugin|
25
- plugin.process(event, item) if plugin.supports_event?(event)
26
- end
19
+ def self.inherited(subclass)
20
+ (@subclasses ||= []) << subclass
27
21
  end
28
22
 
29
23
  def initialize(site)
data/lib/dimples/site.rb CHANGED
@@ -71,8 +71,9 @@ module Dimples
71
71
 
72
72
  def read_templates
73
73
  @templates = {}
74
+ template_glob = File.join(@paths[:sources][:templates], '**', '*.*')
74
75
 
75
- globbed_files(@paths[:sources][:templates]).each do |path|
76
+ Dir.glob(template_glob).each do |path|
76
77
  basename = File.basename(path, File.extname(path))
77
78
  dir_name = File.dirname(path)
78
79
 
@@ -85,7 +86,9 @@ module Dimples
85
86
  end
86
87
 
87
88
  def read_posts
88
- @posts = globbed_files(@paths[:sources][:posts]).sort.map do |path|
89
+ post_glob = File.join(@paths[:sources][:posts], '**', '*.*')
90
+
91
+ @posts = Dir.glob(post_glob).sort.map do |path|
89
92
  Post.new(self, path).tap do |post|
90
93
  add_archive_post(post)
91
94
  categorise_post(post)
@@ -96,9 +99,8 @@ module Dimples
96
99
  end
97
100
 
98
101
  def read_pages
99
- @pages = globbed_files(@paths[:sources][:pages]).sort.map do |path|
100
- Page.new(self, path)
101
- end
102
+ page_glob = File.join(@paths[:sources][:pages], '**', '*.*')
103
+ @pages = Dir.glob(page_glob).sort.map { |path| Page.new(self, path) }
102
104
  end
103
105
 
104
106
  def add_archive_post(post)
@@ -264,10 +266,6 @@ module Dimples
264
266
  end
265
267
  end
266
268
 
267
- def globbed_files(path)
268
- Dir.glob(File.join(path, '**', '*.*'))
269
- end
270
-
271
269
  def archive_year(year)
272
270
  @archives[:year][year] ||= []
273
271
  end
@@ -280,8 +278,14 @@ module Dimples
280
278
  @archives[:day]["#{year}-#{month}-#{day}"] ||= []
281
279
  end
282
280
 
281
+ def plugins
282
+ @plugins ||= Plugin.subclasses&.map { |subclass| subclass.new(self) }
283
+ end
284
+
283
285
  def trigger_event(event, item = nil)
284
- Plugin.send_event(self, event, item)
286
+ plugins.each do |plugin|
287
+ plugin.process(event, item) if plugin.supports_event?(event)
288
+ end
285
289
  end
286
290
  end
287
291
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- VERSION = '5.1.0'
4
+ VERSION = '5.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dimples
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bogan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-03 00:00:00.000000000 Z
11
+ date: 2018-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -200,9 +200,9 @@ require_paths:
200
200
  - lib
201
201
  required_ruby_version: !ruby/object:Gem::Requirement
202
202
  requirements:
203
- - - ">="
203
+ - - "~>"
204
204
  - !ruby/object:Gem::Version
205
- version: '0'
205
+ version: '2.4'
206
206
  required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  requirements:
208
208
  - - ">="
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  version: '0'
211
211
  requirements: []
212
212
  rubyforge_project:
213
- rubygems_version: 2.7.6
213
+ rubygems_version: 2.6.14
214
214
  signing_key:
215
215
  specification_version: 4
216
216
  summary: A basic static site generator