dimples 5.5.1 → 6.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
  SHA1:
3
- metadata.gz: 523ca9490b506eb7f2c4da685e85809ec650f4a1
4
- data.tar.gz: 5b40db0b29c2e846c1ed45f1a7bf9d0685244543
3
+ metadata.gz: 77e8de957e6642626aa3d9650f8320409f94d559
4
+ data.tar.gz: 95f90263a6d7c1d830d3ce349cf867514cd2bc4e
5
5
  SHA512:
6
- metadata.gz: 644e0fcdfe86e59cb76175297ffc29fbc7655f94ae112c27338d84b971634cfff0ec6816a69d14a5e766fa7b33df954492700f1ce419b152469e1c1e82e8f620
7
- data.tar.gz: 71625d1493f0b6731e56160e3b06ff6f65bb598aa1baf2e40db8b60b19888fe2d7974596e57e9264ca460dd5a60edbe175d37cd5dfae989540b356bce1d43f43
6
+ metadata.gz: 902856fce02764c766327d3f080851460899949d0485987234ca20b0d4ba69929d54a5311878823fa81a5dd464bf2518f298b2d450d134eb579175cd7b5f8bbe
7
+ data.tar.gz: fb94b4111e0060d671d0b81640123b08b1dd4f56bf140faa57464d0f3c99a4bda9d67972afc6b4b8e6950cca999c1275b1848e34b49799ca2a6bfd6df995cba2
@@ -26,7 +26,8 @@ dimples <#{valid_commands.join('|')}> [options]
26
26
  Options:
27
27
  BANNER
28
28
  opt :config, 'Config file path', type: :string
29
- opt :output, 'Destination directory', type: :string
29
+ opt :source, 'Source directory', type: :string
30
+ opt :destination, 'Destination directory', type: :string
30
31
  opt :verbose, 'Verbose mode', default: false
31
32
  end
32
33
 
@@ -37,8 +38,14 @@ unless valid_commands.include?(command)
37
38
  Trollop.die "Command must be '#{valid_commands.join('\', \'')}'"
38
39
  end
39
40
 
40
- plugins_path = File.join(Dir.pwd, 'plugins')
41
- config_path = options[:config] || File.join(Dir.pwd, 'config.json')
41
+ source_path = if options[:source]
42
+ File.expand_path(options[:source])
43
+ else
44
+ Dir.pwd
45
+ end
46
+
47
+ plugins_path = File.join(source_path, 'plugins')
48
+ config_path = options[:config] || File.join(source_path, 'config.json')
42
49
 
43
50
  if File.exist?(config_path)
44
51
  begin
@@ -59,7 +66,11 @@ if Dir.exist?(plugins_path)
59
66
  end
60
67
  end
61
68
 
62
- config[:paths][:output] = options[:output] if options[:output]
69
+ config[:source] = source_path
70
+
71
+ if options[:destination]
72
+ config[:destination] = File.expand_path(options[:destination])
73
+ end
63
74
 
64
75
  site = Dimples::Site.new(config)
65
76
 
@@ -70,7 +81,7 @@ when :build
70
81
  site.generate
71
82
 
72
83
  if site.errors.empty?
73
- puts "Done! Your site has been built (#{site.paths[:output]})."
84
+ puts "Done! Your site has been built in #{site.paths[:destination]}."
74
85
  else
75
86
  puts 'Generation failed:'
76
87
  site.errors.each { |error| puts error }
@@ -5,6 +5,8 @@ module Dimples
5
5
  module Configuration
6
6
  def self.defaults
7
7
  {
8
+ source: Dir.pwd,
9
+ destination: File.join(Dir.pwd, 'public'),
8
10
  paths: default_paths,
9
11
  generation: default_generation,
10
12
  layouts: default_layouts,
@@ -18,7 +20,6 @@ module Dimples
18
20
 
19
21
  def self.default_paths
20
22
  {
21
- output: './public',
22
23
  archives: 'archives',
23
24
  paginated_posts: 'posts',
24
25
  posts: 'archives/%Y/%m/%d',
@@ -17,13 +17,11 @@ module Dimples
17
17
  @config = Hashie::Mash.new(Configuration.defaults).deep_merge(config)
18
18
 
19
19
  @paths = {}.tap do |paths|
20
- paths[:base] = Dir.pwd
21
- paths[:output] = File.expand_path(@config.paths.output)
20
+ paths[:source] = File.expand_path(@config.source)
21
+ paths[:destination] = File.expand_path(@config.destination)
22
22
 
23
- paths[:sources] = {}.tap do |sources|
24
- %w[pages posts static templates].each do |type|
25
- sources[type.to_sym] = File.join(paths[:base], type)
26
- end
23
+ %w[pages posts static templates].each do |type|
24
+ paths[type.to_sym] = File.join(paths[:source], type)
27
25
  end
28
26
  end
29
27
 
@@ -40,27 +38,6 @@ module Dimples
40
38
  @errors << error
41
39
  end
42
40
 
43
- def scan_sources
44
- trigger_event(:before_file_scanning)
45
-
46
- read_templates
47
- read_posts
48
- read_pages
49
-
50
- trigger_event(:after_file_scanning)
51
- end
52
-
53
- def publish_files
54
- trigger_event(:before_publishing)
55
-
56
- publish_posts
57
- publish_pages
58
- publish_archives if @config.generation.year_archives
59
- publish_categories if @config.generation.categories
60
-
61
- trigger_event(:after_publishing)
62
- end
63
-
64
41
  def inspect
65
42
  "#<#{self.class} @paths=#{paths}>"
66
43
  end
@@ -80,15 +57,25 @@ module Dimples
80
57
  @latest_post = nil
81
58
  end
82
59
 
60
+ def scan_sources
61
+ trigger_event(:before_file_scanning)
62
+
63
+ read_templates
64
+ read_posts
65
+ read_pages
66
+
67
+ trigger_event(:after_file_scanning)
68
+ end
69
+
83
70
  def read_templates
84
71
  @templates = {}
85
- template_glob = File.join(@paths[:sources][:templates], '**', '*.*')
72
+ template_glob = File.join(@paths[:templates], '**', '*.*')
86
73
 
87
74
  Dir.glob(template_glob).each do |path|
88
75
  basename = File.basename(path, File.extname(path))
89
76
  dir_name = File.dirname(path)
90
77
 
91
- unless dir_name == @paths[:sources][:templates]
78
+ unless dir_name == @paths[:templates]
92
79
  basename = dir_name.split(File::SEPARATOR)[-1] + '.' + basename
93
80
  end
94
81
 
@@ -97,7 +84,7 @@ module Dimples
97
84
  end
98
85
 
99
86
  def read_posts
100
- post_glob = File.join(@paths[:sources][:posts], '**', '*.*')
87
+ post_glob = File.join(@paths[:posts], '**', '*.*')
101
88
 
102
89
  @posts = Dir.glob(post_glob).sort.map do |path|
103
90
  Post.new(self, path).tap do |post|
@@ -110,7 +97,7 @@ module Dimples
110
97
  end
111
98
 
112
99
  def read_pages
113
- page_glob = File.join(@paths[:sources][:pages], '**', '*.*')
100
+ page_glob = File.join(@paths[:pages], '**', '*.*')
114
101
  @pages = Dir.glob(page_glob).sort.map { |path| Page.new(self, path) }
115
102
  end
116
103
 
@@ -130,26 +117,40 @@ module Dimples
130
117
  end
131
118
 
132
119
  def create_output_directory
133
- FileUtils.remove_dir(@paths[:output]) if Dir.exist?(@paths[:output])
134
- Dir.mkdir(@paths[:output])
120
+ if Dir.exist?(@paths[:destination])
121
+ FileUtils.remove_dir(@paths[:destination])
122
+ end
123
+
124
+ Dir.mkdir(@paths[:destination])
135
125
  rescue StandardError => e
136
126
  message = "Couldn't prepare the output directory (#{e.message})"
137
127
  raise GenerationError, message
138
128
  end
139
129
 
140
130
  def copy_static_assets
141
- return unless Dir.exist?(@paths[:sources][:static])
142
- FileUtils.cp_r(File.join(@paths[:sources][:static], '.'), @paths[:output])
131
+ return unless Dir.exist?(@paths[:static])
132
+ FileUtils.cp_r(File.join(@paths[:static], '.'), @paths[:destination])
143
133
  rescue StandardError => e
144
134
  raise GenerationError, "Failed to copy site assets (#{e.message})"
145
135
  end
146
136
 
137
+ def publish_files
138
+ trigger_event(:before_publishing)
139
+
140
+ publish_posts
141
+ publish_pages
142
+ publish_archives if @config.generation.year_archives
143
+ publish_categories if @config.generation.categories
144
+
145
+ trigger_event(:after_publishing)
146
+ end
147
+
147
148
  def publish_posts
148
149
  @posts.each do |post|
149
150
  trigger_event(:before_post_write, post)
150
151
 
151
152
  path = File.join(
152
- @paths[:output],
153
+ @paths[:destination],
153
154
  post.date.strftime(@config.paths.posts),
154
155
  post.slug
155
156
  )
@@ -159,13 +160,15 @@ module Dimples
159
160
  trigger_event(:after_post_write, post)
160
161
  end
161
162
 
162
- publish_feeds(@posts, @paths[:output]) if @config.generation.main_feed
163
+ if @config.generation.main_feed
164
+ publish_feeds(@posts, @paths[:destination])
165
+ end
163
166
 
164
167
  return unless @config.generation.paginated_posts
165
168
 
166
169
  paginate_posts(
167
170
  @posts,
168
- File.join(@paths[:output], @config.paths.paginated_posts),
171
+ File.join(@paths[:destination], @config.paths.paginated_posts),
169
172
  @config.layouts.paginated_post
170
173
  )
171
174
  end
@@ -176,11 +179,11 @@ module Dimples
176
179
 
177
180
  path = if page.path
178
181
  File.dirname(page.path).sub(
179
- @paths[:sources][:pages],
180
- @paths[:output]
182
+ @paths[:pages],
183
+ @paths[:destination]
181
184
  )
182
185
  else
183
- @paths[:output]
186
+ @paths[:destination]
184
187
  end
185
188
 
186
189
  page.write(path)
@@ -215,7 +218,7 @@ module Dimples
215
218
  end
216
219
 
217
220
  date_parts = [year, month, day].compact
218
- path = File.join(@paths[:output], @config.paths.archives, date_parts)
221
+ path = File.join(@paths[:destination], @config.paths.archives, date_parts)
219
222
 
220
223
  posts = archive(year, month, day)[:posts]
221
224
 
@@ -234,7 +237,7 @@ module Dimples
234
237
  def publish_categories
235
238
  @categories.each_value do |category|
236
239
  path = File.join(
237
- @paths[:output],
240
+ @paths[:destination],
238
241
  @config.paths.categories,
239
242
  category.slug
240
243
  )
@@ -255,7 +258,7 @@ module Dimples
255
258
 
256
259
  def paginate_posts(posts, path, layout, context = {})
257
260
  pager = Pager.new(
258
- path.sub(@paths[:output], '') + '/',
261
+ path.sub(@paths[:destination], '') + '/',
259
262
  posts,
260
263
  @config.pagination
261
264
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dimples
4
- VERSION = '5.5.1'
4
+ VERSION = '6.0.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: 5.5.1
4
+ version: 6.0.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: 2018-05-09 00:00:00.000000000 Z
11
+ date: 2018-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie