jekyll-page-boilerplate 4.4.1 → 5.0.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_page_boilerplate/msg/description.md +1 -1
- data/lib/jekyll_page_boilerplate/msg.rb +5 -1
- data/lib/jekyll_page_boilerplate/page.rb +12 -8
- data/lib/jekyll_page_boilerplate/tags.rb +1 -1
- data/lib/jekyll_page_boilerplate/version.rb +1 -1
- data/lib/jekyll_page_boilerplate.rb +2 -2
- data/lib/jekyll_page_boilerplate_cli.rb +50 -48
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a209c84ac5eea1c4cf34fd0f5918b29d7e946043b3293309d3d805a77a47d02
|
4
|
+
data.tar.gz: dfa1c7e2fd260b72d3cdbe9ca4f197239341ae3cc4eaaf6c8393a9ac01d507a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6615e6621fe7cdc7c240332b77a04aa26af0f2050df52e475f2dc655ca8501654d37f7c98cce3170656fcc20479bfa55e564d7f3bdb78539224abd4b0c926b7e
|
7
|
+
data.tar.gz: 4a1ec868cd8954916586c1d94460066f0d66d2c74b5ce0bfa3e86f001debb19a1a9d69cf7282b7c129fd2c1d3533a1d3eaf77b47374cdbc5a66df41902fe1264
|
@@ -14,7 +14,7 @@ A boilerplate is a markdown file you place under the `_boilerplates` folder to g
|
|
14
14
|
author: John Doe
|
15
15
|
|
16
16
|
|
17
|
-
`$ boilerplate post
|
17
|
+
`$ boilerplate post "Another one about pottery"` would create a new file `_posts/yyyy-mm-dd-another-one-about-pottery.markdown`
|
18
18
|
|
19
19
|
---
|
20
20
|
title: Another one about pottery
|
@@ -27,7 +27,11 @@ module JekyllPageBoilerplate::Msg
|
|
27
27
|
begin
|
28
28
|
self.info block.call
|
29
29
|
rescue => e
|
30
|
-
|
30
|
+
if e.kind_of?(JekyllPageBoilerplate::Error)
|
31
|
+
self.error fatal: e.message
|
32
|
+
else
|
33
|
+
self.error fatal: e.message, full: e.full_message
|
34
|
+
end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
@@ -14,13 +14,13 @@ class JekyllPageBoilerplate::Page
|
|
14
14
|
|
15
15
|
attr_reader :tags
|
16
16
|
|
17
|
-
def self.run boilerplate,
|
18
|
-
page = self.new(boilerplate,
|
17
|
+
def self.run boilerplate, custom_args, options
|
18
|
+
page = self.new(boilerplate, custom_args, options)
|
19
19
|
page.create
|
20
20
|
return "Created "+ File.join(page.tags['path'], page.tags['file'])
|
21
21
|
end
|
22
22
|
|
23
|
-
def initialize boilerplate,
|
23
|
+
def initialize boilerplate, custom_args, options
|
24
24
|
plate_path = get_boilerplate_path(boilerplate)
|
25
25
|
abort_unless_file_exists( plate_path )
|
26
26
|
|
@@ -32,8 +32,8 @@ class JekyllPageBoilerplate::Page
|
|
32
32
|
@tags = JekyllPageBoilerplate::Tags.new(
|
33
33
|
defaults(plate_path),
|
34
34
|
get_header_config(parsed_file['head']),
|
35
|
-
|
36
|
-
|
35
|
+
options,
|
36
|
+
parse_custom_args(custom_args)
|
37
37
|
)
|
38
38
|
@tags[:file] = '{{ date }}-{{ slug }}{{ suffix }}' if @tags.timestamp
|
39
39
|
@tags.fill(:slug, :file, safe: true)
|
@@ -87,6 +87,10 @@ class JekyllPageBoilerplate::Page
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
+
def parse_custom_args args
|
91
|
+
Hash[args.map {|x| x.match /(\w+)=['"]{0,1}([^"']+)['"]{0,1}/}.compact.map {|x| x.captures }]
|
92
|
+
end
|
93
|
+
|
90
94
|
def get_header_config head
|
91
95
|
return YAML.load(head.match(READ_CONFIG_REGEX).to_s)['_boilerplate']
|
92
96
|
end
|
@@ -96,18 +100,18 @@ class JekyllPageBoilerplate::Page
|
|
96
100
|
end
|
97
101
|
|
98
102
|
def get_boilerplate_path plate_name
|
99
|
-
return Dir.glob( "#{File.join(BOILERPLATES_PATH, plate_name)}*" ).first.to_s
|
103
|
+
return Dir.glob( "#{File.join(BOILERPLATES_PATH, plate_name.to_s)}*" ).first.to_s
|
100
104
|
end
|
101
105
|
|
102
106
|
def abort_if_file_exists(file_path)
|
103
107
|
if File.exist?(file_path)
|
104
|
-
raise "#{file_path} already exists!"
|
108
|
+
raise JekyllPageBoilerplate::Error.new, "#{file_path} already exists!"
|
105
109
|
end
|
106
110
|
end
|
107
111
|
|
108
112
|
def abort_unless_file_exists(file_path)
|
109
113
|
unless File.exist?(file_path)
|
110
|
-
raise "The file `#{file_path}` does not exist!"
|
114
|
+
raise JekyllPageBoilerplate::Error.new, "The file `#{file_path}` does not exist!"
|
111
115
|
end
|
112
116
|
end
|
113
117
|
|
@@ -25,9 +25,9 @@ module JekyllPageBoilerplate
|
|
25
25
|
Msg.file 'description.md'
|
26
26
|
end
|
27
27
|
|
28
|
-
def self.page boilerplate_name, options
|
28
|
+
def self.page boilerplate_name, args, options
|
29
29
|
Msg.try_and_report do
|
30
|
-
Page.run(boilerplate_name, options)
|
30
|
+
Page.run(boilerplate_name, args, options)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -1,62 +1,64 @@
|
|
1
|
-
require
|
1
|
+
require 'thor'
|
2
2
|
require 'jekyll_page_boilerplate'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
action do |plate, *custom, title: nil, slug: nil, path: nil, timestamp: nil, suffix: nil|
|
21
|
-
custom = Hash[custom.map {|v| v.split('=')}]
|
22
|
-
JekyllPageBoilerplate.page plate, custom.merge({
|
23
|
-
title: title, path: path, slug: slug,
|
24
|
-
suffix: suffix, timestamp: timestamp
|
25
|
-
})
|
4
|
+
|
5
|
+
|
6
|
+
class JekyllPageBoilerplate::Application < Thor
|
7
|
+
|
8
|
+
SHARED_OPTIONS = {
|
9
|
+
title: { type: :string, aliases: [:t], desc: "`path/<title>.md` `'Foo Bar' > foo-bar.md`" },
|
10
|
+
path: { type: :string, aliases: [:p], desc: "`<path>/title.md`" },
|
11
|
+
slug: { type: :string, aliases: [:u], desc: "`path/<slug-template>.md` `{{title}}-{{date}}`" },
|
12
|
+
timestamp: { type: :boolean, aliases: [:s], desc: "`path/<time.now>-title.md`" },
|
13
|
+
suffix: { type: :string, aliases: [:x], desc: "`path/title.<md, markdown, txt>`" }
|
14
|
+
# TODO: rename suffix to ext ^^^
|
15
|
+
}
|
16
|
+
|
17
|
+
desc "version", "Print the current version."
|
18
|
+
def version
|
19
|
+
puts JekyllPageBoilerplate::VERSION.to_s
|
26
20
|
end
|
27
21
|
|
28
|
-
|
29
|
-
|
22
|
+
desc "init", "Creates an example boilerplate."
|
23
|
+
def init
|
24
|
+
puts JekyllPageBoilerplate.init
|
25
|
+
end
|
30
26
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
action do
|
35
|
-
JekyllPageBoilerplate.init
|
36
|
-
end
|
27
|
+
desc "list", "List all the boilerplates."
|
28
|
+
def list
|
29
|
+
JekyllPageBoilerplate.list
|
37
30
|
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
31
|
+
|
32
|
+
desc "create BOILERPLATE TITLE [CUSTOM] (--options)", "Generates a new file from a boilerplate."
|
33
|
+
SHARED_OPTIONS.each do |name, opt_args|
|
34
|
+
option name, **opt_args
|
35
|
+
end
|
36
|
+
def create plate, title = nil, *args
|
37
|
+
_options = options.dup.transform_values(&:dup) || {}
|
38
|
+
_options[:title] ||= title if title
|
39
|
+
JekyllPageBoilerplate.page plate, args, _options
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "readme", "Print out the readme"
|
43
|
+
def readme
|
44
|
+
JekyllPageBoilerplate.readme
|
45
45
|
end
|
46
|
-
|
47
46
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
Dir['_boilerplates/*'].each do |file|
|
48
|
+
cmd = File.basename(file, '.*').to_sym
|
49
|
+
desc "#{cmd} TITLE [CUSTOM] (--options)", "Alias for `bplate create #{cmd} ...`"
|
50
|
+
SHARED_OPTIONS.each do |name, opt_args|
|
51
|
+
option name, **opt_args
|
52
|
+
end
|
53
|
+
define_method cmd do |title = nil, *args|
|
54
|
+
_options = options.dup.transform_values(&:dup) || {}
|
55
|
+
_options[:title] ||= title if title
|
56
|
+
JekyllPageBoilerplate.page cmd, args, _options
|
53
57
|
end
|
54
58
|
end
|
55
59
|
|
60
|
+
default_task :readme
|
56
61
|
end
|
57
62
|
|
58
|
-
JekyllPageBoilerplate::Application.
|
63
|
+
JekyllPageBoilerplate::Application.start(ARGV)
|
59
64
|
|
60
|
-
|
61
|
-
|
62
|
-
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-page-boilerplate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Ferney
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: thor
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '1.2'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.2.1
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
29
|
+
version: '1.2'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.2.1
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: stringex
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
108
|
- !ruby/object:Gem::Version
|
103
109
|
version: '0'
|
104
110
|
requirements: []
|
105
|
-
rubygems_version: 3.
|
111
|
+
rubygems_version: 3.4.1
|
106
112
|
signing_key:
|
107
113
|
specification_version: 4
|
108
114
|
summary: A jekyll plugin that allows you to create new pages or posts from a boilerplate
|