dsm-portfolio-plugin 0.0.11 → 0.0.12
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 +4 -4
- data/lib/dsm-portfolio-plugin.rb +20 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eafde4a2f118b26398572cadac2f944f0f851ab
|
4
|
+
data.tar.gz: fdb2554721f76dcb0e7c4fb91fe2711497cf09cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ffd41eac2478f772fff50d5d48f5b21665cfe690eab1e06ccb6f9a64dbd0b36bb629feab394607a21fb8e67a35fc0b480117ea6ad17c476e07eb708bb86f56b
|
7
|
+
data.tar.gz: 4cf9cd6b8de07d16fa648fbbf377a2b182be44eaf7ac6a6421af6bbce8637166f7d49409191792d0a792a031a96d9f6a9e659442322ac487ef034885d58ee8b5
|
data/lib/dsm-portfolio-plugin.rb
CHANGED
@@ -5,12 +5,15 @@ module Jekyll
|
|
5
5
|
class NewProject < Command
|
6
6
|
def self.init_with_program(prog)
|
7
7
|
prog.command(:project) do |c|
|
8
|
+
# Define documentation.
|
8
9
|
c.syntax 'project NAME'
|
9
10
|
c.description 'Creates a new project with the given NAME'
|
10
11
|
|
12
|
+
# Define options.
|
11
13
|
c.option 'date', '-d DATE', '--date DATE', 'Specify the post date'
|
12
14
|
c.option 'force', '-f', '--force', 'Overwrite a post if it already exists'
|
13
15
|
|
16
|
+
# Process.
|
14
17
|
c.action do |args, options|
|
15
18
|
Jekyll::Commands::NewProject.process(args, options)
|
16
19
|
end
|
@@ -18,37 +21,39 @@ module Jekyll
|
|
18
21
|
end
|
19
22
|
|
20
23
|
def self.process(args, options = {})
|
24
|
+
# Null check required fields.
|
21
25
|
raise ArgumentError.new('You must specify a project name.') if args.empty?
|
22
|
-
|
23
|
-
# layout = options["layout"].nil? ? "post" : options["layout"]
|
24
26
|
|
25
|
-
# Create options for each post type.
|
27
|
+
# Create default options for each post type.
|
26
28
|
ext = "md"
|
27
29
|
date = options["date"].nil? ? Time.now : DateTime.parse(options["date"])
|
28
30
|
|
29
31
|
title = args.shift
|
30
32
|
name = title.gsub(' ', '-').downcase
|
31
33
|
|
32
|
-
#
|
33
|
-
|
34
|
-
|
35
|
-
post_types.
|
36
|
-
post_types.push('summary')
|
37
|
-
|
38
|
-
# raise ArgumentError.new("A post already exists at ./#{post_path}") if File.exist?(post_path) and !options["force"]
|
39
|
-
|
40
|
-
# Make subdirectory.
|
41
|
-
FileUtils.mkdir_p directory_name(name, date)
|
34
|
+
# Fill task from data file.
|
35
|
+
post_types_data_file = "post-types"
|
36
|
+
|
37
|
+
post_types = site.data[post_types_data_file]
|
42
38
|
|
39
|
+
if post_types.size > 0
|
40
|
+
# Make subdirectory.
|
41
|
+
FileUtils.mkdir_p directory_name(name, date)
|
42
|
+
else
|
43
|
+
raise RangeError.new("There are no post types defined in #{post_types_data_file}.")
|
44
|
+
end
|
45
|
+
|
43
46
|
# For every post-type in subfolder...
|
44
47
|
post_types.each do |post_type|
|
45
48
|
# Format file path.
|
46
|
-
post_path = file_name(name, post_type, ext, date)
|
49
|
+
post_path = file_name(name, post_type.post_type, ext, date)
|
50
|
+
|
51
|
+
raise ArgumentError.new("A post already exists at ./#{post_path}") if File.exist?(post_path) and !options["force"]
|
47
52
|
|
48
53
|
# Create file.
|
49
54
|
File.open(post_path, "w") do |f|
|
50
55
|
# Fill it with appropriate front-matter.
|
51
|
-
f.puts(front_matter(post_type, title))
|
56
|
+
f.puts(front_matter(post_type.post_type, title))
|
52
57
|
end
|
53
58
|
end
|
54
59
|
|