jekyll-compose 0.6.0 → 0.7.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 +5 -5
- data/lib/jekyll-compose.rb +3 -1
- data/lib/jekyll-compose/arg_parser.rb +2 -0
- data/lib/jekyll-compose/file_creator.rb +4 -2
- data/lib/jekyll-compose/file_info.rb +2 -0
- data/lib/jekyll-compose/file_mover.rb +17 -5
- data/lib/jekyll-compose/movement_arg_parser.rb +3 -11
- data/lib/jekyll-compose/version.rb +3 -1
- data/lib/jekyll/commands/draft.rb +2 -0
- data/lib/jekyll/commands/page.rb +3 -1
- data/lib/jekyll/commands/post.rb +3 -1
- data/lib/jekyll/commands/publish.rb +8 -2
- data/lib/jekyll/commands/unpublish.rb +8 -2
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d49ea59f89aedfd68afd1fcecb02231d342058f4dbdbcd00b5d3474c2cf8a986
|
4
|
+
data.tar.gz: 3a618debf77511ef6858b0bde412dc1a7fa37701b4be12de0a1d2f0ffcc4a012
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37a8c477f69c8d073fb5491946c0420298a71b2f2a228fa84066ad3eea87344d30e6f9c911c88a5f4081a182e5759367def2dd19fdbd92d5486222d264919da6
|
7
|
+
data.tar.gz: 4e7951b4ffa4bde211cd877d5c9ad6a8b56194e414c534668aebf39dd11bd19ee7e2c1cd6f4f1c01d248b6cbc081139252c79e0e43048a3a84588227f2ba597f
|
data/lib/jekyll-compose.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "jekyll-compose/version"
|
2
4
|
require "jekyll-compose/arg_parser"
|
3
5
|
require "jekyll-compose/movement_arg_parser"
|
@@ -13,6 +15,6 @@ module Jekyll
|
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
|
-
%w
|
18
|
+
%w(draft post publish unpublish page).each do |file|
|
17
19
|
require File.expand_path("jekyll/commands/#{file}.rb", __dir__)
|
18
20
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Jekyll
|
2
4
|
module Compose
|
3
5
|
class FileCreator
|
4
6
|
attr_reader :file, :force, :root
|
5
|
-
def initialize(
|
6
|
-
@file =
|
7
|
+
def initialize(file_info, force = false, root = nil)
|
8
|
+
@file = file_info
|
7
9
|
@force = force
|
8
10
|
@root = root
|
9
11
|
end
|
@@ -1,24 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Jekyll
|
2
4
|
module Compose
|
3
5
|
class FileMover
|
4
|
-
attr_reader :movement, :root
|
5
|
-
def initialize(movement, root = nil)
|
6
|
+
attr_reader :force, :movement, :root
|
7
|
+
def initialize(movement, force = false, root = nil)
|
6
8
|
@movement = movement
|
9
|
+
@force = force
|
7
10
|
@root = root
|
8
11
|
end
|
9
12
|
|
10
|
-
def
|
13
|
+
def resource_type_from
|
14
|
+
"file"
|
15
|
+
end
|
16
|
+
|
17
|
+
def resource_type_to
|
11
18
|
"file"
|
12
19
|
end
|
13
20
|
|
14
21
|
def move
|
15
22
|
validate_source
|
23
|
+
validate_should_write!
|
16
24
|
ensure_directory_exists
|
17
25
|
move_file
|
18
26
|
end
|
19
27
|
|
20
28
|
def validate_source
|
21
|
-
raise ArgumentError, "There was no #{
|
29
|
+
raise ArgumentError, "There was no #{resource_type_from} found at '#{from}'." unless File.exist? from
|
22
30
|
end
|
23
31
|
|
24
32
|
def ensure_directory_exists
|
@@ -26,9 +34,13 @@ module Jekyll
|
|
26
34
|
Dir.mkdir(dir) unless Dir.exist?(dir)
|
27
35
|
end
|
28
36
|
|
37
|
+
def validate_should_write!
|
38
|
+
raise ArgumentError, "A #{resource_type_to} already exists at #{to}" if File.exist?(to) && !force
|
39
|
+
end
|
40
|
+
|
29
41
|
def move_file
|
30
42
|
FileUtils.mv(from, to)
|
31
|
-
puts "#{
|
43
|
+
puts "#{resource_type_from.capitalize} #{from} was moved to #{to}"
|
32
44
|
end
|
33
45
|
|
34
46
|
private
|
@@ -1,12 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Jekyll
|
2
4
|
module Compose
|
3
|
-
class MovementArgParser
|
4
|
-
attr_reader :args, :options, :config
|
5
|
-
def initialize(args, options)
|
6
|
-
@args = args
|
7
|
-
@options = options
|
8
|
-
@config = Jekyll.configuration(options)
|
9
|
-
end
|
5
|
+
class MovementArgParser < ArgParser
|
10
6
|
|
11
7
|
def validate!
|
12
8
|
raise ArgumentError, "You must specify a #{resource_type} path." if args.empty?
|
@@ -15,10 +11,6 @@ module Jekyll
|
|
15
11
|
def path
|
16
12
|
args.join " "
|
17
13
|
end
|
18
|
-
|
19
|
-
def source
|
20
|
-
source = config["source"].gsub(%r!^#{Regexp.quote(Dir.pwd)}!, "")
|
21
|
-
end
|
22
14
|
end
|
23
15
|
end
|
24
16
|
end
|
data/lib/jekyll/commands/page.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Jekyll
|
2
4
|
module Commands
|
3
5
|
class Page < Command
|
@@ -33,7 +35,7 @@ module Jekyll
|
|
33
35
|
|
34
36
|
class PageArgParser < Compose::ArgParser
|
35
37
|
def layout
|
36
|
-
|
38
|
+
options["layout"] || Jekyll::Compose::DEFAULT_LAYOUT_PAGE
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
data/lib/jekyll/commands/post.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Jekyll
|
2
4
|
module Commands
|
3
5
|
class Post < Command
|
@@ -34,7 +36,7 @@ module Jekyll
|
|
34
36
|
|
35
37
|
class PostArgParser < Compose::ArgParser
|
36
38
|
def date
|
37
|
-
options["date"].nil? ? Time.now :
|
39
|
+
options["date"].nil? ? Time.now : Date.parse(options["date"])
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Jekyll
|
2
4
|
module Commands
|
3
5
|
class Publish < Command
|
@@ -8,6 +10,7 @@ module Jekyll
|
|
8
10
|
|
9
11
|
c.option "date", "-d DATE", "--date DATE", "Specify the post date"
|
10
12
|
c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, "Custom configuration file"
|
13
|
+
c.option "force", "-f", "--force", "Overwrite a post if it already exists"
|
11
14
|
c.option "source", "-s", "--source SOURCE", "Custom source directory"
|
12
15
|
|
13
16
|
c.action do |args, options|
|
@@ -22,7 +25,7 @@ module Jekyll
|
|
22
25
|
|
23
26
|
movement = DraftMovementInfo.new params
|
24
27
|
|
25
|
-
mover = DraftMover.new movement, params.source
|
28
|
+
mover = DraftMover.new movement, params.force?, params.source
|
26
29
|
mover.move
|
27
30
|
end
|
28
31
|
end
|
@@ -58,9 +61,12 @@ module Jekyll
|
|
58
61
|
end
|
59
62
|
|
60
63
|
class DraftMover < Compose::FileMover
|
61
|
-
def
|
64
|
+
def resource_type_from
|
62
65
|
"draft"
|
63
66
|
end
|
67
|
+
def resource_type_to
|
68
|
+
"post"
|
69
|
+
end
|
64
70
|
end
|
65
71
|
end
|
66
72
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Jekyll
|
2
4
|
module Commands
|
3
5
|
class Unpublish < Command
|
@@ -7,6 +9,7 @@ module Jekyll
|
|
7
9
|
c.description "Moves a post back into the _drafts directory"
|
8
10
|
|
9
11
|
c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, "Custom configuration file"
|
12
|
+
c.option "force", "-f", "--force", "Overwrite a draft if it already exists"
|
10
13
|
c.option "source", "-s", "--source SOURCE", "Custom source directory"
|
11
14
|
|
12
15
|
c.action do |args, options|
|
@@ -21,7 +24,7 @@ module Jekyll
|
|
21
24
|
|
22
25
|
movement = PostMovementInfo.new params
|
23
26
|
|
24
|
-
mover = PostMover.new movement, params.source
|
27
|
+
mover = PostMover.new movement, params.force?, params.source
|
25
28
|
mover.move
|
26
29
|
end
|
27
30
|
end
|
@@ -52,9 +55,12 @@ module Jekyll
|
|
52
55
|
end
|
53
56
|
|
54
57
|
class PostMover < Compose::FileMover
|
55
|
-
def
|
58
|
+
def resource_type_from
|
56
59
|
"post"
|
57
60
|
end
|
61
|
+
def resource_type_to
|
62
|
+
"draft"
|
63
|
+
end
|
58
64
|
end
|
59
65
|
end
|
60
66
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-compose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.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:
|
11
|
+
date: 2018-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.0
|
19
|
+
version: '3.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.0
|
26
|
+
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.51'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.51'
|
69
83
|
description: Streamline your writing in Jekyll with these commands.
|
70
84
|
email:
|
71
85
|
- parkrmoore@gmail.com
|
@@ -105,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
119
|
version: '0'
|
106
120
|
requirements: []
|
107
121
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.7.5
|
109
123
|
signing_key:
|
110
124
|
specification_version: 4
|
111
125
|
summary: Streamline your writing in Jekyll with these commands.
|