jekyll-compose 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1a7e1e8ddabb24a170461b367ff5ad49f1c69ba
4
- data.tar.gz: 43936ac4575ca3e17d7d12911f3464c6354e57c0
3
+ metadata.gz: e03c15157254e0feae330dd9cb474290f59264b7
4
+ data.tar.gz: 932af0b45c76a9f3a14dc58bfe240df4af47ae55
5
5
  SHA512:
6
- metadata.gz: 1d6ba84f64e43a5014a36a2ffa0e446471e012817e8db0ca3ab19c11cb6d31b5a725b1f878fc159e48801d23724c293f6ac10cb9415b3a7b4f8a0da59d8fd0ee
7
- data.tar.gz: 7fb63991827471be533c0546d68d56bfa7e01e0fb29ad75322a357cffedae645b154d32aba6ec99d83e19765a41f622ec1339b472a4bbefd9b56f785ac50602c
6
+ metadata.gz: 88782ba853339b97e59489f88bd615f4b862a879b08475518984ff1459d3760b31a84fdec8ab71e472920038ca468f97e0b57f9b8bb556d064d445756c49b922
7
+ data.tar.gz: dd0601beaea3745d4ea703c9393ca40c360b4fb1c79350df26d45a64f9097687c6c634ad17223f55cf91144f759d168989d9435114ed57e0caa9764aea53b7c8
@@ -0,0 +1,12 @@
1
+ require "jekyll-compose/version"
2
+
3
+ module Jekyll
4
+ module Compose
5
+ DEFAULT_TYPE = "md"
6
+ DEFAULT_LAYOUT = "post"
7
+ end
8
+ end
9
+
10
+ %w{draft post publish}.each do |file|
11
+ require File.expand_path("jekyll/commands/#{file}.rb", File.dirname(__FILE__))
12
+ end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Compose
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -16,11 +16,11 @@ module Jekyll
16
16
  end
17
17
  end
18
18
 
19
- def self.process(args, options = {})
19
+ def self.process(args = [], options = {})
20
20
  raise ArgumentError.new('You must specify a name.') if args.empty?
21
-
22
- type = options["type"].nil? ? "markdown" : options["type"]
23
- layout = options["layout"].nil? ? "post" : options["layout"]
21
+
22
+ type = options["type"] || Jekyll::Compose::DEFAULT_TYPE
23
+ layout = options["layout"] || Jekyll::Compose::DEFAULT_LAYOUT
24
24
 
25
25
  title = args.shift
26
26
  name = title.gsub(' ', '-').downcase
@@ -34,19 +34,19 @@ module Jekyll
34
34
  end
35
35
 
36
36
  puts "New draft created at ./#{draft_path}.\n"
37
- end
37
+ end
38
38
  # Internal: Gets the filename of the draft to be created
39
39
  #
40
40
  # Returns the filename of the draft, as a String
41
- def self.draft_name(name, ext='markdown')
41
+ def self.draft_name(name, ext=Jekyll::Compose::DEFAULT_TYPE)
42
42
  "_drafts/#{name}.#{ext}"
43
43
  end
44
44
 
45
45
  def self.front_matter(layout, title)
46
- "---
47
- layout: #{layout}
48
- title: #{title}
49
- ---"
46
+ {
47
+ "layout" => layout,
48
+ "title" => title,
49
+ }.to_yaml + "\n---\n"
50
50
  end
51
51
  end
52
52
  end
@@ -17,11 +17,11 @@ module Jekyll
17
17
  end
18
18
  end
19
19
 
20
- def self.process(args, options = {})
20
+ def self.process(args = [], options = {})
21
21
  raise ArgumentError.new('You must specify a name.') if args.empty?
22
-
23
- type = options["type"].nil? ? "markdown" : options["type"]
24
- layout = options["layout"].nil? ? "post" : options["layout"]
22
+
23
+ type = options["type"] || Jekyll::Compose::DEFAULT_TYPE
24
+ layout = options["layout"] || Jekyll::Compose::DEFAULT_LAYOUT
25
25
 
26
26
  date = options["date"].nil? ? Time.now : DateTime.parse(options["date"])
27
27
 
@@ -37,7 +37,7 @@ module Jekyll
37
37
  end
38
38
 
39
39
  puts "New post created at ./#{post_path}.\n"
40
- end
40
+ end
41
41
  # Internal: Gets the filename of the draft to be created
42
42
  #
43
43
  # Returns the filename of the draft, as a String
@@ -3,7 +3,7 @@ module Jekyll
3
3
  class Publish < Command
4
4
  def self.init_with_program(prog)
5
5
  prog.command(:publish) do |c|
6
- c.syntax 'publish NAME'
6
+ c.syntax 'publish DRAFT_PATH'
7
7
  c.description 'Moves a draft into the _posts directory and sets the date'
8
8
 
9
9
  c.option 'date', '-d DATE', '--date DATE', 'Specify the post date'
@@ -14,17 +14,19 @@ module Jekyll
14
14
  end
15
15
  end
16
16
 
17
- def self.process(args, options = {})
18
- raise ArgumentError.new('You must specify a name.') if args.empty?
19
-
17
+ def self.process(args = [], options = {})
18
+ raise ArgumentError.new('You must specify a draft path.') if args.empty?
19
+
20
20
  date = options["date"].nil? ? Date.today : Date.parse(options["date"])
21
- file = args.shift
21
+ draft_path = args.shift
22
+
23
+ raise ArgumentError.new("There was no draft found at '#{draft_path}'.") unless File.exist? draft_path
22
24
 
23
- post_path = post_name(date, file)
24
- FileUtils.mv(draft_name(file), post_path)
25
+ post_path = post_name(date, draft_name(draft_path))
26
+ FileUtils.mv(draft_path, post_path)
25
27
 
26
- puts "Draft #{file} was published to ./#{post_path}"
27
- end
28
+ puts "Draft #{draft_path} was published to ./#{post_path}"
29
+ end
28
30
 
29
31
  # Internal: Gets the filename of the post to be created
30
32
  #
@@ -33,8 +35,8 @@ module Jekyll
33
35
  "_posts/#{date.strftime('%Y-%m-%d')}-#{name}"
34
36
  end
35
37
 
36
- def self.draft_name(name)
37
- "_drafts/#{name}"
38
+ def self.draft_name(path)
39
+ File.basename(path)
38
40
  end
39
41
 
40
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-compose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parker Moore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-30 00:00:00.000000000 Z
11
+ date: 2015-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,19 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: shoulda
56
+ name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '3.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '3.0'
69
69
  description: Streamline your writing in Jekyll with these commands.
70
70
  email:
71
71
  - parkrmoore@gmail.com
@@ -73,11 +73,11 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - lib/jekyll-compose.rb
77
+ - lib/jekyll-compose/version.rb
76
78
  - lib/jekyll/commands/draft.rb
77
79
  - lib/jekyll/commands/post.rb
78
80
  - lib/jekyll/commands/publish.rb
79
- - lib/jekyll/compose.rb
80
- - lib/jekyll/compose/version.rb
81
81
  homepage: https://github.com/jekyll/jekyll-compose
82
82
  licenses:
83
83
  - MIT
@@ -1,10 +0,0 @@
1
- require "jekyll/compose/version"
2
-
3
- module Jekyll
4
- module Compose
5
- end
6
- end
7
-
8
- require "jekyll/commands/draft"
9
- require "jekyll/commands/post"
10
- require "jekyll/commands/publish"