jekyll-compose 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-compose/arg_parser.rb +8 -3
- data/lib/jekyll-compose/file_creator.rb +12 -6
- data/lib/jekyll-compose/file_info.rb +6 -6
- data/lib/jekyll-compose/file_mover.rb +21 -6
- data/lib/jekyll-compose/movement_arg_parser.rb +6 -1
- data/lib/jekyll-compose/version.rb +1 -1
- data/lib/jekyll/commands/draft.rb +4 -2
- data/lib/jekyll/commands/page.rb +4 -2
- data/lib/jekyll/commands/post.rb +4 -2
- data/lib/jekyll/commands/publish.rb +3 -1
- data/lib/jekyll/commands/unpublish.rb +4 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ec3f6f135a6ca3612a807ecbccde9010cc75be4
|
4
|
+
data.tar.gz: 7447bb8d544454e5fe58c8aae94f52519b243913
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc359f888d1593a05b749054487a0bef79fbfba21baa3d123f305df2a6b3e198804d822799dab2848346ea9a923e08c136c5e7718d619a51fbb5131b267911a6
|
7
|
+
data.tar.gz: 4515efc64935e0393b1b301854b52da673880e7aa4c301f4cd86ad6e3752ca153b975111deac466a3586729163feca733c4062fdf62e2a740c661da262740f15
|
@@ -1,8 +1,9 @@
|
|
1
1
|
class Jekyll::Compose::ArgParser
|
2
|
-
attr_reader :args, :options
|
2
|
+
attr_reader :args, :options, :config
|
3
3
|
def initialize(args, options)
|
4
4
|
@args = args
|
5
5
|
@options = options
|
6
|
+
@config = Jekyll.configuration(options)
|
6
7
|
end
|
7
8
|
|
8
9
|
def validate!
|
@@ -10,11 +11,11 @@ class Jekyll::Compose::ArgParser
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def type
|
13
|
-
|
14
|
+
options["extension"] || Jekyll::Compose::DEFAULT_TYPE
|
14
15
|
end
|
15
16
|
|
16
17
|
def layout
|
17
|
-
|
18
|
+
options["layout"] || Jekyll::Compose::DEFAULT_LAYOUT
|
18
19
|
end
|
19
20
|
|
20
21
|
def title
|
@@ -24,4 +25,8 @@ class Jekyll::Compose::ArgParser
|
|
24
25
|
def force?
|
25
26
|
!!options["force"]
|
26
27
|
end
|
28
|
+
|
29
|
+
def source
|
30
|
+
config['source'].gsub(/^#{Regexp.quote(Dir.pwd)}/, '')
|
31
|
+
end
|
27
32
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module Jekyll
|
2
2
|
module Compose
|
3
3
|
class FileCreator
|
4
|
-
attr_reader :file, :force
|
5
|
-
def initialize(fileInfo, force = false)
|
4
|
+
attr_reader :file, :force, :root
|
5
|
+
def initialize(fileInfo, force = false, root = nil)
|
6
6
|
@file = fileInfo
|
7
7
|
@force = force
|
8
|
+
@root = root
|
8
9
|
end
|
9
10
|
|
10
11
|
def create!
|
@@ -16,20 +17,25 @@ module Jekyll
|
|
16
17
|
private
|
17
18
|
|
18
19
|
def validate_should_write!
|
19
|
-
raise ArgumentError.new("A #{file.resource_type} already exists at #{
|
20
|
+
raise ArgumentError.new("A #{file.resource_type} already exists at #{file_path}") if File.exist?(file_path) and !force
|
20
21
|
end
|
21
22
|
|
22
23
|
def ensure_directory_exists
|
23
|
-
dir = File.dirname
|
24
|
+
dir = File.dirname file_path
|
24
25
|
Dir.mkdir(dir) unless Dir.exist?(dir)
|
25
26
|
end
|
26
27
|
|
27
28
|
def write_file
|
28
|
-
File.open(
|
29
|
+
File.open(file_path, "w") do |f|
|
29
30
|
f.puts(file.content)
|
30
31
|
end
|
31
32
|
|
32
|
-
puts "New #{file.resource_type} created at #{
|
33
|
+
puts "New #{file.resource_type} created at #{file_path}."
|
34
|
+
end
|
35
|
+
|
36
|
+
def file_path
|
37
|
+
return file.path if root.nil? or root.empty?
|
38
|
+
return File.join(root, file.path)
|
33
39
|
end
|
34
40
|
end
|
35
41
|
end
|
@@ -10,11 +10,11 @@ class Jekyll::Compose::FileInfo
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def content
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
front_matter = YAML.dump({
|
14
|
+
'layout' => params.layout,
|
15
|
+
'title' => params.title,
|
16
|
+
})
|
17
|
+
|
18
|
+
front_matter + "---\n"
|
19
19
|
end
|
20
20
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Jekyll
|
2
2
|
module Compose
|
3
3
|
class FileMover
|
4
|
-
attr_reader :movement
|
5
|
-
def initialize(movement)
|
4
|
+
attr_reader :movement, :root
|
5
|
+
def initialize(movement, root = nil)
|
6
6
|
@movement = movement
|
7
|
+
@root = root
|
7
8
|
end
|
8
9
|
|
9
10
|
def resource_type
|
@@ -17,17 +18,31 @@ module Jekyll
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def validate_source
|
20
|
-
raise ArgumentError.new("There was no #{resource_type} found at '#{
|
21
|
+
raise ArgumentError.new("There was no #{resource_type} found at '#{from}'.") unless File.exist? from
|
21
22
|
end
|
22
23
|
|
23
24
|
def ensure_directory_exists
|
24
|
-
dir = File.dirname
|
25
|
+
dir = File.dirname to
|
25
26
|
Dir.mkdir(dir) unless Dir.exist?(dir)
|
26
27
|
end
|
27
28
|
|
28
29
|
def move_file
|
29
|
-
FileUtils.mv(
|
30
|
-
puts "#{resource_type.capitalize} #{
|
30
|
+
FileUtils.mv(from, to)
|
31
|
+
puts "#{resource_type.capitalize} #{from} was moved to #{to}"
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def from
|
36
|
+
movement.from
|
37
|
+
end
|
38
|
+
|
39
|
+
def to
|
40
|
+
file_path(movement.to)
|
41
|
+
end
|
42
|
+
|
43
|
+
def file_path(path)
|
44
|
+
return path if root.nil? or root.empty?
|
45
|
+
return File.join(root, path)
|
31
46
|
end
|
32
47
|
end
|
33
48
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module Jekyll
|
2
2
|
module Compose
|
3
3
|
class MovementArgParser
|
4
|
-
attr_reader :args, :options
|
4
|
+
attr_reader :args, :options, :config
|
5
5
|
def initialize(args, options)
|
6
6
|
@args = args
|
7
7
|
@options = options
|
8
|
+
@config = Jekyll.configuration(options)
|
8
9
|
end
|
9
10
|
|
10
11
|
def validate!
|
@@ -14,6 +15,10 @@ module Jekyll
|
|
14
15
|
def path
|
15
16
|
args.join ' '
|
16
17
|
end
|
18
|
+
|
19
|
+
def source
|
20
|
+
source = config['source'].gsub(/^#{Regexp.quote(Dir.pwd)}/, '')
|
21
|
+
end
|
17
22
|
end
|
18
23
|
end
|
19
24
|
end
|
@@ -16,7 +16,9 @@ module Jekyll
|
|
16
16
|
[
|
17
17
|
['extension', '-x EXTENSION', '--extension EXTENSION', 'Specify the file extension'],
|
18
18
|
['layout', '-l LAYOUT', '--layout LAYOUT', "Specify the draft layout"],
|
19
|
-
['force', '-f', '--force', 'Overwrite a draft if it already exists']
|
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'],
|
20
22
|
]
|
21
23
|
end
|
22
24
|
|
@@ -27,7 +29,7 @@ module Jekyll
|
|
27
29
|
|
28
30
|
draft = DraftFileInfo.new params
|
29
31
|
|
30
|
-
Compose::FileCreator.new(draft, params.force
|
32
|
+
Compose::FileCreator.new(draft, params.force?, params.source).create!
|
31
33
|
end
|
32
34
|
|
33
35
|
class DraftFileInfo < Compose::FileInfo
|
data/lib/jekyll/commands/page.rb
CHANGED
@@ -16,7 +16,9 @@ module Jekyll
|
|
16
16
|
[
|
17
17
|
['extension', '-x EXTENSION', '--extension EXTENSION', 'Specify the file extension'],
|
18
18
|
['layout', '-l LAYOUT', '--layout LAYOUT', "Specify the page layout"],
|
19
|
-
['force', '-f', '--force', 'Overwrite a page if it already exists']
|
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'],
|
20
22
|
]
|
21
23
|
end
|
22
24
|
|
@@ -26,7 +28,7 @@ module Jekyll
|
|
26
28
|
|
27
29
|
page = PageFileInfo.new params
|
28
30
|
|
29
|
-
Compose::FileCreator.new(page, params.force
|
31
|
+
Compose::FileCreator.new(page, params.force?, params.source).create!
|
30
32
|
end
|
31
33
|
|
32
34
|
class PageArgParser < Compose::ArgParser
|
data/lib/jekyll/commands/post.rb
CHANGED
@@ -17,7 +17,9 @@ module Jekyll
|
|
17
17
|
['extension', '-x EXTENSION', '--extension EXTENSION', 'Specify the file extension'],
|
18
18
|
['layout', '-l LAYOUT', '--layout LAYOUT', "Specify the post layout"],
|
19
19
|
['force', '-f', '--force', 'Overwrite a post if it already exists'],
|
20
|
-
['date', '-d DATE', '--date DATE', 'Specify the post date']
|
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'],
|
21
23
|
]
|
22
24
|
end
|
23
25
|
|
@@ -27,7 +29,7 @@ module Jekyll
|
|
27
29
|
|
28
30
|
post = PostFileInfo.new params
|
29
31
|
|
30
|
-
Compose::FileCreator.new(post, params.force
|
32
|
+
Compose::FileCreator.new(post, params.force?, params.source).create!
|
31
33
|
end
|
32
34
|
|
33
35
|
|
@@ -7,6 +7,8 @@ module Jekyll
|
|
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'
|
10
|
+
c.option 'config', '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'
|
11
|
+
c.option 'source', '-s', '--source SOURCE', 'Custom source directory'
|
10
12
|
|
11
13
|
c.action do |args, options|
|
12
14
|
Jekyll::Commands::Publish.process(args, options)
|
@@ -20,7 +22,7 @@ module Jekyll
|
|
20
22
|
|
21
23
|
movement = DraftMovementInfo.new params
|
22
24
|
|
23
|
-
mover = DraftMover.new movement
|
25
|
+
mover = DraftMover.new movement, params.source
|
24
26
|
mover.move
|
25
27
|
end
|
26
28
|
|
@@ -6,6 +6,9 @@ module Jekyll
|
|
6
6
|
c.syntax 'unpublish POST_PATH'
|
7
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'
|
11
|
+
|
9
12
|
c.action do |args, options|
|
10
13
|
process(args, options)
|
11
14
|
end
|
@@ -18,7 +21,7 @@ module Jekyll
|
|
18
21
|
|
19
22
|
movement = PostMovementInfo.new params
|
20
23
|
|
21
|
-
mover = PostMover.new movement
|
24
|
+
mover = PostMover.new movement, params.source
|
22
25
|
mover.move
|
23
26
|
end
|
24
27
|
|
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.
|
4
|
+
version: 0.5.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: 2016-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.0.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:
|
26
|
+
version: 3.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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.
|
108
|
+
rubygems_version: 2.5.1
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Streamline your writing in Jekyll with these commands.
|