dsm-portfolio-plugin 0.0.4 → 0.0.5

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 +54 -43
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e94ebe84ffdf613bb5e753091ed217d408eb02f8
4
- data.tar.gz: ab8fa778248ae5b3f190b051431ef844e1fc37f3
3
+ metadata.gz: 5b5c5dcc29c6688b0661db0c9b424a68230f4223
4
+ data.tar.gz: b64b2d16991bb02b4712eacae3e9972ce4974abe
5
5
  SHA512:
6
- metadata.gz: cdcc6ac90783706f9d3b7e62eab8eb3b0086a9e88287d65480b973cbf2e39093a9a93347670700c46138d82799e406244259dfd59a28c7571a1cb43f76cb1d2b
7
- data.tar.gz: 68a61a6f882559f2a8dfcf3736f4652a505df1fbca63f773e9594ceb3a896227a2f54900c7035bf71a76a651966092fe2ee2e2ea6ae3f6e7c9b833a9df038b05
6
+ metadata.gz: 503121bcd0d20e7fa767244ef52df5d4a31e9b7d678c186be5c1af9595e17955aad1f25e6e7e0ae20db957c9c56639459e663924ba8eb9c54588bbc1650a2871
7
+ data.tar.gz: a3d44fe301025e0c9553911afecb848a90bf6efbc9f5a2b6daf5c87514349152a6334556459227b1d4a8a970b64bd64e420aa2b975bd0f8999783652312fc9e0
@@ -2,58 +2,69 @@
2
2
  module Jekyll
3
3
  # Define custom commands.
4
4
  module Commands
5
- class Post < Command
5
+ class NewProject < Command
6
6
  def self.init_with_program(prog)
7
- prog.command(:post) do |c|
8
- c.syntax 'post NAME'
9
- c.description 'Creates a new post with the given NAME'
10
-
11
- c.option 'type', '-t TYPE', '--type TYPE', 'Specify the content type'
12
- c.option 'layout', '-t LAYOUT', '--layout LAYOUT', 'Specify the post layout'
13
- c.option 'date', '-d DATE', '--date DATE', 'Specify the post date'
14
- c.option 'force', '-f', '--force', 'Overwrite a post if it already exists'
15
-
16
- c.action do |args, options|
17
- Jekyll::Commands::Post.process(args, options)
7
+ prog.command(:project) do |c|
8
+ c.syntax 'project NAME'
9
+ c.description 'Creates a new project with the given NAME'
10
+
11
+ c.option 'date', '-d DATE', '--date DATE', 'Specify the post date'
12
+ c.option 'force', '-f', '--force', 'Overwrite a post if it already exists'
13
+
14
+ c.action do |args, options|
15
+ Jekyll::Commands::Project.process(args, options)
16
+ end
18
17
  end
19
- end
20
18
  end
21
-
19
+
22
20
  def self.process(args, options = {})
23
- raise ArgumentError.new('You must specify a name.') if args.empty?
24
-
25
- type = options["type"].nil? ? "markdown" : options["type"]
26
- layout = options["layout"].nil? ? "post" : options["layout"]
27
-
28
- date = options["date"].nil? ? Time.now : DateTime.parse(options["date"])
29
-
30
- title = args.shift
31
- name = title.gsub(' ', '-').downcase
32
-
33
- post_path = file_name(name, type, date)
34
-
35
- raise ArgumentError.new("A post already exists at ./#{post_path}") if File.exist?(post_path) and !options["force"]
36
-
37
- File.open(post_path, "w") do |f|
38
- f.puts(front_matter(layout, title))
39
- end
40
-
41
- puts "New post created at ./#{post_path}.\n"
21
+ raise ArgumentError.new('You must specify a project name.') if args.empty?
22
+
23
+ # layout = options["layout"].nil? ? "post" : options["layout"]
24
+
25
+ # Create options for each post type.
26
+ ext = "md"
27
+ date = options["date"].nil? ? Time.now : DateTime.parse(options["date"])
28
+
29
+ title = args.shift
30
+ name = title.gsub(' ', '-').downcase
31
+
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
+ # For every post-type in subfolder...
41
+ post_types.each do |file_type|
42
+ # Format file path.
43
+ post_path = file_name(name, post_type, ext, date)
44
+
45
+ # Create file.
46
+ File.open(post_path, "w") do |f|
47
+ # Fill it with appropriate front-matter.
48
+ f.puts(front_matter(post_type, title))
49
+ end
50
+ end
51
+
52
+ puts "New posts created at ./_posts/#{date.strftime('%Y-%m-%d')}-#{name}.\n"
42
53
  end
43
- # Internal: Gets the filename of the draft to be created
44
- #
54
+
45
55
  # Returns the filename of the draft, as a String
46
- def self.file_name(name, ext, date)
47
- "_posts/#{date.strftime('%Y-%m-%d')}-#{name}.#{ext}"
56
+ def self.file_name(name, post_type, ext, date)
57
+ "_posts/#{date.strftime('%Y-%m-%d')}-#{name}/#{post_type}.#{ext}"
48
58
  end
49
-
59
+
60
+ # TODO: Replace this with smart filling from data file and template file.
50
61
  def self.front_matter(layout, title)
51
- "---
52
- layout: #{layout}
53
- title: #{title}
54
- ---"
62
+ "---
63
+ layout: #{layout}
64
+ title: #{title}
65
+ ---"
55
66
  end
56
- end
67
+ end
57
68
  end
58
69
 
59
70
  class ProjectGenerator < Generator
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.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Hills