jekyll-compose 0.5.0 → 0.6.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: 3ec3f6f135a6ca3612a807ecbccde9010cc75be4
4
- data.tar.gz: 7447bb8d544454e5fe58c8aae94f52519b243913
3
+ metadata.gz: f6626f1690b5584b65e7d569272b59eb416414a5
4
+ data.tar.gz: 7d57720c9bdefd1f9bebb577829fde1371ff4150
5
5
  SHA512:
6
- metadata.gz: cc359f888d1593a05b749054487a0bef79fbfba21baa3d123f305df2a6b3e198804d822799dab2848346ea9a923e08c136c5e7718d619a51fbb5131b267911a6
7
- data.tar.gz: 4515efc64935e0393b1b301854b52da673880e7aa4c301f4cd86ad6e3752ca153b975111deac466a3586729163feca733c4062fdf62e2a740c661da262740f15
6
+ metadata.gz: 19cca9b6e9f8b0e2d743c05daa6463ed574663994e7cd3dc495f04a04870df5624758a890f12f730bfdbb22de8276424d53329f6d1c9ce7b69e91679221ce560
7
+ data.tar.gz: 37130e32cfa032e7690da8685a7e257e9037a91e4273539fa01ee355c4196d3fe0b4820adf0e3af0dc1be2d7d9b8ba0900ecf531ea1cde737f96f6fbb395bcdc
@@ -7,12 +7,12 @@ require "jekyll-compose/file_info"
7
7
 
8
8
  module Jekyll
9
9
  module Compose
10
- DEFAULT_TYPE = "md"
11
- DEFAULT_LAYOUT = "post"
12
- DEFAULT_LAYOUT_PAGE = "page"
10
+ DEFAULT_TYPE = "md".freeze
11
+ DEFAULT_LAYOUT = "post".freeze
12
+ DEFAULT_LAYOUT_PAGE = "page".freeze
13
13
  end
14
14
  end
15
15
 
16
16
  %w{draft post publish unpublish page}.each do |file|
17
- require File.expand_path("jekyll/commands/#{file}.rb", File.dirname(__FILE__))
17
+ require File.expand_path("jekyll/commands/#{file}.rb", __dir__)
18
18
  end
@@ -7,7 +7,7 @@ class Jekyll::Compose::ArgParser
7
7
  end
8
8
 
9
9
  def validate!
10
- raise ArgumentError.new('You must specify a name.') if args.empty?
10
+ raise ArgumentError, "You must specify a name." if args.empty?
11
11
  end
12
12
 
13
13
  def type
@@ -19,7 +19,7 @@ class Jekyll::Compose::ArgParser
19
19
  end
20
20
 
21
21
  def title
22
- args.join ' '
22
+ args.join " "
23
23
  end
24
24
 
25
25
  def force?
@@ -27,6 +27,6 @@ class Jekyll::Compose::ArgParser
27
27
  end
28
28
 
29
29
  def source
30
- config['source'].gsub(/^#{Regexp.quote(Dir.pwd)}/, '')
30
+ config["source"].gsub(%r!^#{Regexp.quote(Dir.pwd)}!, "")
31
31
  end
32
32
  end
@@ -17,7 +17,7 @@ module Jekyll
17
17
  private
18
18
 
19
19
  def validate_should_write!
20
- raise ArgumentError.new("A #{file.resource_type} already exists at #{file_path}") if File.exist?(file_path) and !force
20
+ raise ArgumentError, "A #{file.resource_type} already exists at #{file_path}" if File.exist?(file_path) && !force
21
21
  end
22
22
 
23
23
  def ensure_directory_exists
@@ -34,7 +34,7 @@ module Jekyll
34
34
  end
35
35
 
36
36
  def file_path
37
- return file.path if root.nil? or root.empty?
37
+ return file.path if root.nil? || root.empty?
38
38
  return File.join(root, file.path)
39
39
  end
40
40
  end
@@ -9,11 +9,11 @@ class Jekyll::Compose::FileInfo
9
9
  "#{name}.#{params.type}"
10
10
  end
11
11
 
12
- def content
12
+ def content(custom_front_matter = {})
13
13
  front_matter = YAML.dump({
14
- 'layout' => params.layout,
15
- 'title' => params.title,
16
- })
14
+ "layout" => params.layout,
15
+ "title" => params.title,
16
+ }.merge(custom_front_matter))
17
17
 
18
18
  front_matter + "---\n"
19
19
  end
@@ -8,7 +8,7 @@ module Jekyll
8
8
  end
9
9
 
10
10
  def resource_type
11
- 'file'
11
+ "file"
12
12
  end
13
13
 
14
14
  def move
@@ -18,7 +18,7 @@ module Jekyll
18
18
  end
19
19
 
20
20
  def validate_source
21
- raise ArgumentError.new("There was no #{resource_type} found at '#{from}'.") unless File.exist? from
21
+ raise ArgumentError, "There was no #{resource_type} found at '#{from}'." unless File.exist? from
22
22
  end
23
23
 
24
24
  def ensure_directory_exists
@@ -41,7 +41,7 @@ module Jekyll
41
41
  end
42
42
 
43
43
  def file_path(path)
44
- return path if root.nil? or root.empty?
44
+ return path if root.nil? || root.empty?
45
45
  return File.join(root, path)
46
46
  end
47
47
  end
@@ -9,15 +9,15 @@ module Jekyll
9
9
  end
10
10
 
11
11
  def validate!
12
- raise ArgumentError.new("You must specify a #{resource_type} path.") if args.empty?
12
+ raise ArgumentError, "You must specify a #{resource_type} path." if args.empty?
13
13
  end
14
14
 
15
15
  def path
16
- args.join ' '
16
+ args.join " "
17
17
  end
18
18
 
19
19
  def source
20
- source = config['source'].gsub(/^#{Regexp.quote(Dir.pwd)}/, '')
20
+ source = config["source"].gsub(%r!^#{Regexp.quote(Dir.pwd)}!, "")
21
21
  end
22
22
  end
23
23
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Compose
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0".freeze
4
4
  end
5
5
  end
@@ -3,10 +3,10 @@ module Jekyll
3
3
  class Draft < Command
4
4
  def self.init_with_program(prog)
5
5
  prog.command(:draft) do |c|
6
- c.syntax 'draft NAME'
7
- c.description 'Creates a new draft post with the given NAME'
6
+ c.syntax "draft NAME"
7
+ c.description "Creates a new draft post with the given NAME"
8
8
 
9
- options.each {|opt| c.option *opt }
9
+ options.each { |opt| c.option *opt }
10
10
 
11
11
  c.action { |args, options| process args, options }
12
12
  end
@@ -14,15 +14,14 @@ module Jekyll
14
14
 
15
15
  def self.options
16
16
  [
17
- ['extension', '-x EXTENSION', '--extension EXTENSION', 'Specify the file extension'],
18
- ['layout', '-l LAYOUT', '--layout LAYOUT', "Specify the draft layout"],
19
- ['force', '-f', '--force', 'Overwrite a draft if it already exists'],
20
- ['config', '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'],
21
- ['source', '-s', '--source SOURCE', 'Custom source directory'],
17
+ ["extension", "-x EXTENSION", "--extension EXTENSION", "Specify the file extension"],
18
+ ["layout", "-l LAYOUT", "--layout LAYOUT", "Specify the draft layout"],
19
+ ["force", "-f", "--force", "Overwrite a draft if it already exists"],
20
+ ["config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, "Custom configuration file"],
21
+ ["source", "-s", "--source SOURCE", "Custom source directory"],
22
22
  ]
23
23
  end
24
24
 
25
-
26
25
  def self.process(args = [], options = {})
27
26
  params = Compose::ArgParser.new args, options
28
27
  params.validate!
@@ -34,7 +33,7 @@ module Jekyll
34
33
 
35
34
  class DraftFileInfo < Compose::FileInfo
36
35
  def resource_type
37
- 'draft'
36
+ "draft"
38
37
  end
39
38
 
40
39
  def path
@@ -3,10 +3,10 @@ module Jekyll
3
3
  class Page < Command
4
4
  def self.init_with_program(prog)
5
5
  prog.command(:page) do |c|
6
- c.syntax 'page NAME'
7
- c.description 'Creates a new page with the given NAME'
6
+ c.syntax "page NAME"
7
+ c.description "Creates a new page with the given NAME"
8
8
 
9
- options.each {|opt| c.option *opt }
9
+ options.each { |opt| c.option *opt }
10
10
 
11
11
  c.action { |args, options| process args, options }
12
12
  end
@@ -14,11 +14,11 @@ module Jekyll
14
14
 
15
15
  def self.options
16
16
  [
17
- ['extension', '-x EXTENSION', '--extension EXTENSION', 'Specify the file extension'],
18
- ['layout', '-l LAYOUT', '--layout LAYOUT', "Specify the page layout"],
19
- ['force', '-f', '--force', 'Overwrite a page if it already exists'],
20
- ['config', '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'],
21
- ['source', '-s', '--source SOURCE', 'Custom source directory'],
17
+ ["extension", "-x EXTENSION", "--extension EXTENSION", "Specify the file extension"],
18
+ ["layout", "-l LAYOUT", "--layout LAYOUT", "Specify the page layout"],
19
+ ["force", "-f", "--force", "Overwrite a page if it already exists"],
20
+ ["config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, "Custom configuration file"],
21
+ ["source", "-s", "--source SOURCE", "Custom source directory"],
22
22
  ]
23
23
  end
24
24
 
@@ -39,11 +39,10 @@ module Jekyll
39
39
 
40
40
  class PageFileInfo < Compose::FileInfo
41
41
  def resource_type
42
- 'page'
42
+ "page"
43
43
  end
44
44
 
45
45
  alias_method :path, :file_name
46
-
47
46
  end
48
47
  end
49
48
  end
@@ -3,10 +3,10 @@ module Jekyll
3
3
  class Post < Command
4
4
  def self.init_with_program(prog)
5
5
  prog.command(:post) do |c|
6
- c.syntax 'post NAME'
7
- c.description 'Creates a new post with the given NAME'
6
+ c.syntax "post NAME"
7
+ c.description "Creates a new post with the given NAME"
8
8
 
9
- options.each {|opt| c.option *opt }
9
+ options.each { |opt| c.option *opt }
10
10
 
11
11
  c.action { |args, options| process args, options }
12
12
  end
@@ -14,12 +14,12 @@ module Jekyll
14
14
 
15
15
  def self.options
16
16
  [
17
- ['extension', '-x EXTENSION', '--extension EXTENSION', 'Specify the file extension'],
18
- ['layout', '-l LAYOUT', '--layout LAYOUT', "Specify the post layout"],
19
- ['force', '-f', '--force', 'Overwrite a post if it already exists'],
20
- ['date', '-d DATE', '--date DATE', 'Specify the post date'],
21
- ['config', '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'],
22
- ['source', '-s', '--source SOURCE', 'Custom source directory'],
17
+ ["extension", "-x EXTENSION", "--extension EXTENSION", "Specify the file extension"],
18
+ ["layout", "-l LAYOUT", "--layout LAYOUT", "Specify the post layout"],
19
+ ["force", "-f", "--force", "Overwrite a post if it already exists"],
20
+ ["date", "-d DATE", "--date DATE", "Specify the post date"],
21
+ ["config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, "Custom configuration file"],
22
+ ["source", "-s", "--source SOURCE", "Custom source directory"],
23
23
  ]
24
24
  end
25
25
 
@@ -32,7 +32,6 @@ module Jekyll
32
32
  Compose::FileCreator.new(post, params.force?, params.source).create!
33
33
  end
34
34
 
35
-
36
35
  class PostArgParser < Compose::ArgParser
37
36
  def date
38
37
  options["date"].nil? ? Time.now : DateTime.parse(options["date"])
@@ -41,7 +40,7 @@ module Jekyll
41
40
 
42
41
  class PostFileInfo < Compose::FileInfo
43
42
  def resource_type
44
- 'post'
43
+ "post"
45
44
  end
46
45
 
47
46
  def path
@@ -53,7 +52,15 @@ module Jekyll
53
52
  end
54
53
 
55
54
  def _date_stamp
56
- @params.date.strftime '%Y-%m-%d'
55
+ @params.date.strftime "%Y-%m-%d"
56
+ end
57
+
58
+ def _time_stamp
59
+ @params.date.strftime("%Y-%m-%d %H:%M %z")
60
+ end
61
+
62
+ def content(custom_front_matter = {})
63
+ super({ "date" => _time_stamp }.merge(custom_front_matter))
57
64
  end
58
65
  end
59
66
  end
@@ -3,12 +3,12 @@ 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 DRAFT_PATH'
7
- c.description 'Moves a draft into the _posts directory and sets the date'
6
+ c.syntax "publish DRAFT_PATH"
7
+ c.description "Moves a draft into the _posts directory and sets the date"
8
8
 
9
- c.option 'date', '-d DATE', '--date DATE', 'Specify the post date'
10
- c.option 'config', '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'
11
- c.option 'source', '-s', '--source SOURCE', 'Custom source directory'
9
+ c.option "date", "-d DATE", "--date DATE", "Specify the post date"
10
+ c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, "Custom configuration file"
11
+ c.option "source", "-s", "--source SOURCE", "Custom source directory"
12
12
 
13
13
  c.action do |args, options|
14
14
  Jekyll::Commands::Publish.process(args, options)
@@ -25,7 +25,6 @@ module Jekyll
25
25
  mover = DraftMover.new movement, params.source
26
26
  mover.move
27
27
  end
28
-
29
28
  end
30
29
 
31
30
  class PublishArgParser < Compose::MovementArgParser
@@ -53,14 +52,14 @@ module Jekyll
53
52
  end
54
53
 
55
54
  def to
56
- date_stamp = params.date.strftime '%Y-%m-%d'
55
+ date_stamp = params.date.strftime "%Y-%m-%d"
57
56
  "_posts/#{date_stamp}-#{params.name}"
58
57
  end
59
58
  end
60
59
 
61
60
  class DraftMover < Compose::FileMover
62
61
  def resource_type
63
- 'draft'
62
+ "draft"
64
63
  end
65
64
  end
66
65
  end
@@ -3,11 +3,11 @@ module Jekyll
3
3
  class Unpublish < Command
4
4
  def self.init_with_program(prog)
5
5
  prog.command(:unpublish) do |c|
6
- c.syntax 'unpublish POST_PATH'
7
- c.description 'Moves a post back into the _drafts directory'
6
+ c.syntax "unpublish POST_PATH"
7
+ c.description "Moves a post back into the _drafts directory"
8
8
 
9
- c.option 'config', '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'
10
- c.option 'source', '-s', '--source SOURCE', 'Custom source directory'
9
+ c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, "Custom configuration file"
10
+ c.option "source", "-s", "--source SOURCE", "Custom source directory"
11
11
 
12
12
  c.action do |args, options|
13
13
  process(args, options)
@@ -24,16 +24,15 @@ module Jekyll
24
24
  mover = PostMover.new movement, params.source
25
25
  mover.move
26
26
  end
27
-
28
27
  end
29
28
 
30
29
  class UnpublishArgParser < Compose::MovementArgParser
31
30
  def resource_type
32
- 'post'
31
+ "post"
33
32
  end
34
33
 
35
34
  def name
36
- File.basename(path).sub /\d{4}-\d{2}-\d{2}-/, ''
35
+ File.basename(path).sub %r!\d{4}-\d{2}-\d{2}-!, ""
37
36
  end
38
37
  end
39
38
 
@@ -54,7 +53,7 @@ module Jekyll
54
53
 
55
54
  class PostMover < Compose::FileMover
56
55
  def resource_type
57
- 'post'
56
+ "post"
58
57
  end
59
58
  end
60
59
  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.5.0
4
+ version: 0.6.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: 2016-10-11 00:00:00.000000000 Z
11
+ date: 2017-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  requirements: []
107
107
  rubyforge_project:
108
- rubygems_version: 2.5.1
108
+ rubygems_version: 2.6.13
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Streamline your writing in Jekyll with these commands.