dimples 6.5.0 → 6.6.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: 6c408ebc105da1277ad32d6cc979cd8be0ac1d01a063dee1bd96e62a4a8f7066
4
- data.tar.gz: 48a27e0263f74bc939f043ef961c95113be22280377ecdaf992967461bf4c3e9
3
+ metadata.gz: b8a5a0e150bc568f6593260d6af73dfcdfc2979ff7e39866d3cc798c706955ff
4
+ data.tar.gz: 7c5521a81ac0325d431c1027287bf216e4669b341bcf5e6f6fabfa9f05beb0a5
5
5
  SHA512:
6
- metadata.gz: 4294ccad6f74b54cd8546d12f23ce976bffccfd6852a3ef1711103cc9459649dd247b360ba14eb77ebe42bad145fe355e88eb6be62d792bad8f2768351c48918
7
- data.tar.gz: 787ef8197927275b4667aeb454a660ea3e7a34a8c1a17ba172de8504828bd3e020baf3f5ffdcb708a4d521ab786279fa03481221f17c98d45c9e7e96d681fff8
6
+ metadata.gz: 73b0502dcdd803eef073c4d075d7f3d2eaa9f6a9b8897f1c5d21d0c49b7c3682c91aba70b7b89c4140c65a14df7e6a0ed83fdaa42b6925327521929cdd37f58b
7
+ data.tar.gz: 3750f6c5e82b6d4f84a659bb8f15a36c969cd4698eaa736946f4fd81d7a5a28ec49e3d3529820d6a0b1cd3b3ac6f2e786b83431b0de40bf21a16d60fbd505de3
data/bin/dimples CHANGED
@@ -29,7 +29,6 @@ Options:
29
29
  opt :config, 'Config file path', type: :string
30
30
  opt :source, 'Source directory', type: :string
31
31
  opt :destination, 'Destination directory', type: :string
32
- opt :verbose, 'Verbose mode', default: false
33
32
  end
34
33
 
35
34
  Optimist.educate if ARGV.empty?
@@ -47,19 +46,19 @@ source_path = if options[:source]
47
46
 
48
47
  config_path = options[:config] || File.join(source_path, 'config.json')
49
48
 
50
- if File.exist?(config_path)
51
- begin
52
- file_contents = File.read(config_path)
53
- Optimist.die "Config file is empty (#{config_path})" if file_contents.empty?
54
-
55
- config = JSON.parse(file_contents, symbolize_names: true)
56
- rescue JSON::ParserError
57
- Optimist.die "Invalid or malformed config file (#{config_path})"
58
- end
59
- else
49
+ unless File.exist?(config_path)
60
50
  Optimist.die "Unable to find config file (#{config_path})"
61
51
  end
62
52
 
53
+ begin
54
+ file_contents = File.read(config_path)
55
+ Optimist.die "Config file is empty (#{config_path})" if file_contents.empty?
56
+
57
+ config = JSON.parse(file_contents, symbolize_names: true)
58
+ rescue JSON::ParserError
59
+ Optimist.die "Invalid or malformed config file (#{config_path})"
60
+ end
61
+
63
62
  config[:source] = source_path
64
63
 
65
64
  if options[:destination]
@@ -3,6 +3,10 @@
3
3
  module Dimples
4
4
  # Default configuration options for a site.
5
5
  module Configuration
6
+ def self.prepare(config)
7
+ Hashie::Mash.new(defaults).deep_merge(config)
8
+ end
9
+
6
10
  def self.defaults
7
11
  {
8
12
  source: Dir.pwd,
@@ -23,6 +27,7 @@ module Dimples
23
27
  archives: 'archives',
24
28
  paginated_posts: 'posts',
25
29
  posts: 'archives/%Y/%m/%d',
30
+ drafts: 'archives/drafts/%Y/%m/%d',
26
31
  categories: 'archives/categories'
27
32
  }
28
33
  end
data/lib/dimples/post.rb CHANGED
@@ -15,6 +15,12 @@ module Dimples
15
15
  @metadata[:date] = Date.new(parts[1].to_i, parts[2].to_i, parts[3].to_i)
16
16
  @metadata[:slug] = parts[4]
17
17
  @metadata[:categories] ||= []
18
+ @metadata[:draft] ||= false
19
+ end
20
+
21
+ def url
22
+ path = date.strftime(draft ? @site.config.paths.drafts : @site.config.paths.posts)
23
+ "/#{path}/#{slug}/"
18
24
  end
19
25
 
20
26
  def year
@@ -12,7 +12,13 @@ module Dimples
12
12
  context[:site] ||= @site
13
13
  context[:pagination] ||= nil
14
14
 
15
- output = engine.render(scope, context) { body }.strip
15
+ begin
16
+ output = engine.render(scope, context) { body }.strip
17
+ rescue StandardError => e
18
+ raise RenderingError,
19
+ "Unable to render #{@source.path || 'dynamic file'} (#{e})"
20
+ end
21
+
16
22
  @source.metadata[:rendered_contents] = output
17
23
 
18
24
  if @source.metadata[:layout]
data/lib/dimples/site.rb CHANGED
@@ -14,11 +14,11 @@ module Dimples
14
14
  attr_reader :latest_post
15
15
 
16
16
  def initialize(config = {})
17
- @config = Hashie::Mash.new(Configuration.defaults).deep_merge(config)
17
+ @config = Configuration.prepare(config)
18
18
 
19
19
  @paths = {}.tap do |paths|
20
20
  paths[:source] = File.expand_path(@config.source)
21
- paths[:destination] = File.expand_path(@config.destination)
21
+ paths[:destination] = File.expand_path(Time.now.strftime(@config.destination))
22
22
 
23
23
  %w[pages posts static templates].each do |type|
24
24
  paths[type.to_sym] = File.join(paths[:source], type)
@@ -133,24 +133,21 @@ module Dimples
133
133
 
134
134
  def publish_posts
135
135
  @posts.each do |post|
136
- path = File.join(
137
- @paths[:destination],
138
- post.date.strftime(@config.paths.posts),
139
- post.slug
140
- )
141
-
136
+ path = File.join(@paths[:destination], post.url.split('/'))
142
137
  post.write(path)
143
138
  end
144
139
 
140
+ published_posts = @posts.select { |post| !post.draft }
141
+
145
142
  if @config.generation.main_feed
146
- publish_feeds(@posts, @paths[:destination])
143
+ publish_feeds(published_posts, @paths[:destination])
147
144
  end
148
145
 
149
146
  return unless @config.generation.paginated_posts
150
147
 
151
148
  Dimples::Pager.paginate(
152
149
  self,
153
- @posts,
150
+ published_posts,
154
151
  File.join(@paths[:destination], @config.paths.paginated_posts),
155
152
  @config.layouts.paginated_post
156
153
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- VERSION = '6.5.0'
4
+ VERSION = '6.6.0'
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.5.0
4
+ version: 6.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bogan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-14 00:00:00.000000000 Z
11
+ date: 2021-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.5'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 3.5.7
19
+ version: '4.1'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '3.5'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 3.5.7
26
+ version: '4.1'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: optimist
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -62,9 +56,6 @@ dependencies:
62
56
  name: codeclimate-test-reporter
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: 1.0.0
68
59
  - - "~>"
69
60
  - !ruby/object:Gem::Version
70
61
  version: '1.0'
@@ -72,9 +63,6 @@ dependencies:
72
63
  prerelease: false
73
64
  version_requirements: !ruby/object:Gem::Requirement
74
65
  requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: 1.0.0
78
66
  - - "~>"
79
67
  - !ruby/object:Gem::Version
80
68
  version: '1.0'
@@ -98,76 +86,56 @@ dependencies:
98
86
  requirements:
99
87
  - - "~>"
100
88
  - !ruby/object:Gem::Version
101
- version: '10.0'
89
+ version: 12.3.3
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
93
  requirements:
106
94
  - - "~>"
107
95
  - !ruby/object:Gem::Version
108
- version: '10.0'
96
+ version: 12.3.3
109
97
  - !ruby/object:Gem::Dependency
110
98
  name: redcarpet
111
99
  requirement: !ruby/object:Gem::Requirement
112
100
  requirements:
113
101
  - - "~>"
114
102
  - !ruby/object:Gem::Version
115
- version: '3.3'
103
+ version: '3.5'
116
104
  type: :development
117
105
  prerelease: false
118
106
  version_requirements: !ruby/object:Gem::Requirement
119
107
  requirements:
120
108
  - - "~>"
121
109
  - !ruby/object:Gem::Version
122
- version: '3.3'
110
+ version: '3.5'
123
111
  - !ruby/object:Gem::Dependency
124
112
  name: rspec
125
113
  requirement: !ruby/object:Gem::Requirement
126
114
  requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- version: 3.7.0
130
115
  - - "~>"
131
116
  - !ruby/object:Gem::Version
132
- version: '3.7'
117
+ version: '3.10'
133
118
  type: :development
134
119
  prerelease: false
135
120
  version_requirements: !ruby/object:Gem::Requirement
136
121
  requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- version: 3.7.0
140
122
  - - "~>"
141
123
  - !ruby/object:Gem::Version
142
- version: '3.7'
124
+ version: '3.10'
143
125
  - !ruby/object:Gem::Dependency
144
126
  name: simplecov
145
127
  requirement: !ruby/object:Gem::Requirement
146
128
  requirements:
147
129
  - - "~>"
148
130
  - !ruby/object:Gem::Version
149
- version: '0.14'
150
- type: :development
151
- prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- requirements:
154
- - - "~>"
155
- - !ruby/object:Gem::Version
156
- version: '0.14'
157
- - !ruby/object:Gem::Dependency
158
- name: timecop
159
- requirement: !ruby/object:Gem::Requirement
160
- requirements:
161
- - - "~>"
162
- - !ruby/object:Gem::Version
163
- version: 0.9.1
131
+ version: '0.21'
164
132
  type: :development
165
133
  prerelease: false
166
134
  version_requirements: !ruby/object:Gem::Requirement
167
135
  requirements:
168
136
  - - "~>"
169
137
  - !ruby/object:Gem::Version
170
- version: 0.9.1
138
+ version: '0.21'
171
139
  description: A simple tool for building static websites.
172
140
  email:
173
141
  - d+dimples@waferbaby.com
@@ -203,14 +171,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
203
171
  requirements:
204
172
  - - "~>"
205
173
  - !ruby/object:Gem::Version
206
- version: '2.4'
174
+ version: '2.7'
207
175
  required_rubygems_version: !ruby/object:Gem::Requirement
208
176
  requirements:
209
177
  - - ">="
210
178
  - !ruby/object:Gem::Version
211
179
  version: '0'
212
180
  requirements: []
213
- rubygems_version: 3.0.3
181
+ rubygems_version: 3.1.4
214
182
  signing_key:
215
183
  specification_version: 4
216
184
  summary: A basic static site generator