dimples 6.2.1 → 6.2.2

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
  SHA1:
3
- metadata.gz: 96343858172cce426b369da61bb47accbf3a614f
4
- data.tar.gz: 66216803513d5bc1ec30ab66c60d3cf4851d1dcd
3
+ metadata.gz: 21a60d2b84e1719f4e61d24bf855fbcf51ebb21a
4
+ data.tar.gz: fdc5daaa67484d85c6fa745f8a4df44184543fb2
5
5
  SHA512:
6
- metadata.gz: 64a53d14330f3299f9818b10bc2687cb0c6f9eabb8f0a98c9418a11ea6128048ecf4cd751ac98c9c51b57706a3507b05eabc81ed06a71797d1c54dea1673ff07
7
- data.tar.gz: '08305d4b7201679a64cf18cdc50d21bd7e858f63453e86ab76f60910f3936c2597d3cc28e9daab6572a1119961d277d6a0f00a0a436463e7b31f3d7c6cc7d068'
6
+ metadata.gz: 485c8d88d322a27221e219de92ba0144d76bc7358c2f1026261efc22672451770d8fbb3b72143f15a20b795452714b12c2a3ed374fb2b7f0db23051ac4998bd3
7
+ data.tar.gz: 5333091633ef50a30261559a3ee0c53bfc199c37e7793f9d581c38c8145a85c78b6a9c1cf8d2b4b1a0309c2ecba5f5e4f5ce7c5f133dcd49722d687394281a15
@@ -24,7 +24,8 @@ Usage:
24
24
  dimples <#{valid_commands.join('|')}> [options]
25
25
 
26
26
  Options:
27
- BANNER
27
+ BANNER
28
+
28
29
  opt :config, 'Config file path', type: :string
29
30
  opt :source, 'Source directory', type: :string
30
31
  opt :destination, 'Destination directory', type: :string
@@ -2,6 +2,7 @@
2
2
 
3
3
  $LOAD_PATH.unshift(__dir__)
4
4
 
5
+ require 'fileutils'
5
6
  require 'hashie'
6
7
  require 'tilt'
7
8
  require 'yaml'
@@ -86,6 +86,7 @@ module Dimples
86
86
 
87
87
  def previous_page_url
88
88
  return unless @previous_page
89
+
89
90
  @previous_page != 1 ? "#{@url}#{@page_prefix}#{@previous_page}" : @url
90
91
  end
91
92
 
@@ -3,7 +3,7 @@
3
3
  module Dimples
4
4
  # A single dated post on a site.
5
5
  class Post < Page
6
- POST_FILENAME = /(\d{4})-(\d{2})-(\d{2})-(.+)/
6
+ POST_FILENAME = /(\d{4})-(\d{2})-(\d{2})-(.+)/.freeze
7
7
 
8
8
  def initialize(site, path)
9
9
  super
@@ -125,13 +125,22 @@ module Dimples
125
125
 
126
126
  def copy_static_assets
127
127
  return unless Dir.exist?(@paths[:static])
128
+
128
129
  FileUtils.cp_r(File.join(@paths[:static], '.'), @paths[:destination])
129
130
  rescue StandardError => e
130
131
  raise GenerationError, "Failed to copy site assets (#{e.message})"
131
132
  end
132
133
 
133
134
  def publish_posts
134
- @posts.each { |post| publish_post(post) }
135
+ @posts.each do |post|
136
+ path = File.join(
137
+ @paths[:destination],
138
+ post.date.strftime(@config.paths.posts),
139
+ post.slug
140
+ )
141
+
142
+ post.write(path)
143
+ end
135
144
 
136
145
  if @config.generation.main_feed
137
146
  publish_feeds(@posts, @paths[:destination])
@@ -147,31 +156,19 @@ module Dimples
147
156
  )
148
157
  end
149
158
 
150
- def publish_post(post)
151
- path = File.join(
152
- @paths[:destination],
153
- post.date.strftime(@config.paths.posts),
154
- post.slug
155
- )
156
-
157
- post.write(path)
158
- end
159
-
160
159
  def publish_pages
161
- @pages.each { |page| publish_page(page) }
162
- end
163
-
164
- def publish_page(page)
165
- path = if page.path
166
- File.dirname(page.path).sub(
167
- @paths[:pages],
160
+ @pages.each do |page|
161
+ path = if page.path
162
+ File.dirname(page.path).sub(
163
+ @paths[:pages],
164
+ @paths[:destination]
165
+ )
166
+ else
168
167
  @paths[:destination]
169
- )
170
- else
171
- @paths[:destination]
172
- end
168
+ end
173
169
 
174
- page.write(path)
170
+ page.write(path)
171
+ end
175
172
  end
176
173
 
177
174
  def publish_archives
@@ -217,41 +214,35 @@ module Dimples
217
214
  end
218
215
 
219
216
  def publish_categories
220
- @categories.each_value { |category| publish_category(category) }
221
- end
222
-
223
- def publish_category(category)
224
- path = File.join(
225
- @paths[:destination],
226
- @config.paths.categories,
227
- category.slug
228
- )
229
-
230
- category_posts = category.posts.reverse
231
- context = { page: { title: category.name, category: category } }
232
-
233
- Dimples::Pager.paginate(
234
- self,
235
- category_posts,
236
- path,
237
- @config.layouts.category,
238
- context
239
- )
240
-
241
- publish_feeds(category_posts, path, context)
217
+ @categories.each_value do |category|
218
+ path = File.join(
219
+ @paths[:destination],
220
+ @config.paths.categories,
221
+ category.slug
222
+ )
223
+
224
+ category_posts = category.posts.reverse
225
+ context = { page: { title: category.name, category: category } }
226
+
227
+ Dimples::Pager.paginate(
228
+ self,
229
+ category_posts,
230
+ path,
231
+ @config.layouts.category,
232
+ context
233
+ )
234
+
235
+ publish_feeds(category_posts, path, context)
236
+ end
242
237
  end
243
238
 
244
239
  def publish_feeds(posts, path, context = {})
245
240
  @config.feed_formats.each do |format|
246
- publish_feed(format, posts, path, context)
247
- end
248
- end
241
+ feed = Feed.new(self, format)
249
242
 
250
- def publish_feed(format, posts, path, context = {})
251
- feed = Feed.new(self, format)
252
-
253
- feed.feed_posts = posts.slice(0, @config.pagination.per_page)
254
- feed.write(path, context)
243
+ feed.feed_posts = posts.slice(0, @config.pagination.per_page)
244
+ feed.write(path, context)
245
+ end
255
246
  end
256
247
  end
257
248
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- VERSION = '6.2.1'
4
+ VERSION = '6.2.2'
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: 6.2.1
4
+ version: 6.2.2
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-09-26 00:00:00.000000000 Z
11
+ date: 2018-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie