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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dsm-portfolio-plugin.rb +20 -15
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efbb7f050296e5ac1ac1bf49ff6077bdb3239511
4
- data.tar.gz: d016d4353b2258186c905a9f5a6f1e0dfa2ff470
3
+ metadata.gz: 5eafde4a2f118b26398572cadac2f944f0f851ab
4
+ data.tar.gz: fdb2554721f76dcb0e7c4fb91fe2711497cf09cc
5
5
  SHA512:
6
- metadata.gz: 11bf016eb4fdc2b91c185746cb31e512e06ac37ef097a8767f3f8cc9a7ae55b357d1cb9ea2b6e38dc76e0ce0a4796461be4c93856d650900693fd1443546ff48
7
- data.tar.gz: d08ff2bff08ee72c9a269d20ef1ea7ae3a4b79858b5fbcf7704573f33c3627ceb2f0631d57a5359dafaccc61428594df2c1cb03989031f32dddbe774e8f153f6
6
+ metadata.gz: 0ffd41eac2478f772fff50d5d48f5b21665cfe690eab1e06ccb6f9a64dbd0b36bb629feab394607a21fb8e67a35fc0b480117ea6ad17c476e07eb708bb86f56b
7
+ data.tar.gz: 4cf9cd6b8de07d16fa648fbbf377a2b182be44eaf7ac6a6421af6bbce8637166f7d49409191792d0a792a031a96d9f6a9e659442322ac487ef034885d58ee8b5
@@ -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
- # TODO: Replace this with smart filling from data file and template file.
33
- post_types = []
34
-
35
- post_types.push('vignette')
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsm-portfolio-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Hills