mkmatter 3.0.45 → 3.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +2 -2
- data/lib/minitest/xs_and_os_plugin.rb +39 -39
- data/lib/mkmatter.rb +18 -0
- data/lib/mkmatter/answers.rb +5 -5
- data/lib/mkmatter/cli/app.rb +6 -6
- data/lib/mkmatter/cli/descriptions.rb +17 -25
- data/lib/mkmatter/cli/subs/new.rb +22 -24
- data/lib/mkmatter/cli/subs/tags.rb +7 -10
- data/lib/mkmatter/common.rb +16 -12
- data/lib/mkmatter/questions.rb +13 -11
- data/lib/mkmatter/version.rb +1 -1
- data/mkmatter.gemspec +1 -0
- metadata +17 -4
- data/Gemfile.lock +0 -76
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ee0e5f931dc430239fbe47d840508ff4efa2b3341003126283180ac6dffac7df
|
4
|
+
data.tar.gz: 2a0bcef90d6d9430ccc125b3e9779dd65e8e2b9c7d290a34e69cfa29dd8da20e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db663f58eb5df4ad445cec55c47a0a129e15f436aa7fa9d2a09c7c7b304e490408eec5dfe2f8e2dfd2800ce52790b9306f5041c60f904c09100a4c04c3181b8e
|
7
|
+
data.tar.gz: 033ad62cd7f42342c7216bbf885ff83a90700ae2e495864651c5ca79ee5bb39325f3470aa846ab2c6ec5ce4c4aacfbf06c6010311e14023da36c094d245151a7
|
data/.travis.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
language: ruby
|
2
2
|
script: echo "Running tests against $(ruby -v) ..."
|
3
|
-
bundler_args: --jobs=6 --retry=3 --standalone
|
3
|
+
bundler_args: --jobs=6 --retry=3 --standalone
|
4
4
|
notifications:
|
5
5
|
irc:
|
6
6
|
channels:
|
@@ -50,4 +50,4 @@ jobs:
|
|
50
50
|
repo: IotaSpencer/mkmatter
|
51
51
|
branch: master
|
52
52
|
allow_failures:
|
53
|
-
- rvm: ruby-head
|
53
|
+
- rvm: ruby-head
|
@@ -5,9 +5,9 @@ module Minitest
|
|
5
5
|
def plugin_xs_and_os_init
|
6
6
|
Minitest.reporter.reporters.clear
|
7
7
|
Minitest.reporter << TravisReporter.new(options[:io], options)
|
8
|
-
|
8
|
+
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
class TravisReporter < Minitest::Reporters::BaseReporter
|
12
12
|
@@color_for_result_code = {
|
13
13
|
'.' => :green,
|
@@ -27,13 +27,13 @@ module Minitest
|
|
27
27
|
yellow: 33,
|
28
28
|
blue: 34
|
29
29
|
}
|
30
|
-
|
30
|
+
|
31
31
|
def initialize(*)
|
32
32
|
super
|
33
33
|
@color_enabled = io.respond_to?(:tty?) && io.tty?
|
34
|
-
|
34
|
+
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def record(result)
|
38
38
|
super
|
39
39
|
puts
|
@@ -44,46 +44,46 @@ module Minitest
|
|
44
44
|
print_result_code(result.result_code)
|
45
45
|
print ']'
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def start
|
49
49
|
super
|
50
50
|
io.print "Run options: #{options[:args]} / "
|
51
51
|
io.print 'Running:'
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
def report
|
55
55
|
super
|
56
56
|
io.sync = true
|
57
|
-
|
57
|
+
|
58
58
|
failing_results = results.reject(&:skipped?)
|
59
59
|
skipped_results = results.select(&:skipped?)
|
60
|
-
|
60
|
+
|
61
61
|
color = :green
|
62
62
|
color = :yellow if skipped_results.any?
|
63
63
|
color = :red if failing_results.any?
|
64
|
-
|
64
|
+
|
65
65
|
if failing_results.any? || skipped_results.any?
|
66
66
|
failing_results.each.with_index(1) { |result, index| display_failing(result, index) }
|
67
67
|
skipped_results.each.with_index(failing_results.size + 1) { |result, index| display_skipped(result, index) }
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
io.print "\n\n"
|
71
71
|
io.puts statistics
|
72
72
|
io.puts color(summary, color)
|
73
|
-
|
73
|
+
|
74
74
|
if failing_results.any?
|
75
75
|
io.puts "\nFailed Tests:\n"
|
76
76
|
failing_results.each { |result| display_replay_command(result) }
|
77
77
|
io.puts "\n\n"
|
78
78
|
end
|
79
79
|
end
|
80
|
-
|
81
|
-
|
80
|
+
|
81
|
+
|
82
82
|
def statistics
|
83
83
|
'Finished in %.6fs, %.4f runs/s, %.4f assertions/s.' %
|
84
84
|
[total_time, count / total_time, assertions / total_time]
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
def summary # :nodoc:
|
88
88
|
[
|
89
89
|
pluralize('run', count),
|
@@ -93,23 +93,23 @@ module Minitest
|
|
93
93
|
pluralize('skip', skips)
|
94
94
|
].join(', ')
|
95
95
|
end
|
96
|
-
|
96
|
+
|
97
97
|
def indent(text)
|
98
98
|
text.gsub(/^/, ' ')
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
def display_failing(result, index)
|
102
102
|
backtrace = backtrace(result.failure.backtrace)
|
103
103
|
message = result.failure.message
|
104
104
|
message = message.lines.tap(&:pop).join.chomp if result.error?
|
105
|
-
|
105
|
+
|
106
106
|
str = "\n\n"
|
107
107
|
str << color('%4d) %s' % [index, result_name(result.name)])
|
108
108
|
str << "\n" << color(indent(message), :red)
|
109
109
|
str << "\n" << color(backtrace, :blue)
|
110
110
|
io.print str
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
def display_skipped(result, index)
|
114
114
|
location = location(result.failure.location)
|
115
115
|
str = "\n\n"
|
@@ -117,55 +117,55 @@ module Minitest
|
|
117
117
|
str << "\n" << indent(color(location, :yellow))
|
118
118
|
io.print str
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
def display_replay_command(result)
|
122
122
|
location, line = find_test_file(result)
|
123
123
|
return if location.empty?
|
124
|
-
|
124
|
+
|
125
125
|
command = if defined?(Rails) && Rails.version >= '5.0.0'
|
126
126
|
%[bin/rails test #{location}:#{line}]
|
127
|
-
else
|
128
127
|
%[rake TEST=#{location} TESTOPTS="--name=#{result.name}"]
|
128
|
+
else
|
129
129
|
end
|
130
|
-
|
130
|
+
|
131
131
|
str = "\n"
|
132
132
|
str << color(command, :red)
|
133
|
-
|
133
|
+
|
134
134
|
io.print str
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
def find_test_file(result)
|
138
|
-
location, line = result.
|
138
|
+
location, line = result.source_location
|
139
139
|
location = location.gsub(%r[^.*?/((?:test|spec)/.*?)$], "\\1")
|
140
|
-
|
140
|
+
|
141
141
|
[location, line]
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
def backtrace(backtrace)
|
145
145
|
backtrace = filter_backtrace(backtrace).map { |line| location(line, true) }
|
146
146
|
return if backtrace.empty?
|
147
147
|
indent(backtrace.join("\n")).gsub(/^(\s+)/, "\\1# ")
|
148
148
|
end
|
149
|
-
|
149
|
+
|
150
150
|
def location(location, include_line_number = false)
|
151
151
|
regex = include_line_number ? /^([^:]+:\d+)/ : /^([^:]+)/
|
152
152
|
location = File.expand_path(location[regex, 1])
|
153
|
-
|
153
|
+
|
154
154
|
return location unless location.start_with?(Dir.pwd)
|
155
|
-
|
155
|
+
|
156
156
|
location.gsub(%r[^#{Regexp.escape(Dir.pwd)}/], '')
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
def filter_backtrace(backtrace)
|
160
160
|
Minitest.backtrace_filter.filter(backtrace)
|
161
161
|
end
|
162
|
-
|
162
|
+
|
163
163
|
def result_name(name)
|
164
164
|
name
|
165
165
|
.gsub(/^test(_\d+)?_/, '')
|
166
166
|
.gsub(/_/, ' ')
|
167
167
|
end
|
168
|
-
|
168
|
+
|
169
169
|
def print_result_code(result_code)
|
170
170
|
result = @@result_code_to_unicode[result_code]
|
171
171
|
colors = {
|
@@ -174,9 +174,9 @@ module Minitest
|
|
174
174
|
"\u{203C}" => :red,
|
175
175
|
"\u{26A1}" => :yellow
|
176
176
|
}
|
177
|
-
io.print color(
|
177
|
+
io.print color(result, colors[result])
|
178
178
|
end
|
179
|
-
|
179
|
+
|
180
180
|
def color(string, color = :default)
|
181
181
|
if color_enabled?
|
182
182
|
color = @@color.fetch(color, 0)
|
@@ -185,11 +185,11 @@ module Minitest
|
|
185
185
|
string
|
186
186
|
end
|
187
187
|
end
|
188
|
-
|
188
|
+
|
189
189
|
def color_enabled?
|
190
190
|
@color_enabled
|
191
191
|
end
|
192
|
-
|
192
|
+
|
193
193
|
def pluralize(word, count)
|
194
194
|
case count
|
195
195
|
when 0
|
@@ -203,4 +203,4 @@ module Minitest
|
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
206
|
-
end
|
206
|
+
end
|
data/lib/mkmatter.rb
CHANGED
@@ -6,7 +6,25 @@ require 'mkmatter/version'
|
|
6
6
|
|
7
7
|
require 'json'
|
8
8
|
require 'yaml'
|
9
|
+
require 'active_support/all'
|
9
10
|
# Main Module Declaration
|
10
11
|
module Mkmatter
|
11
12
|
|
12
13
|
end
|
14
|
+
class Thor
|
15
|
+
module Shell
|
16
|
+
class Basic
|
17
|
+
def print_wrapped(message, options = {})
|
18
|
+
message.lstrip!
|
19
|
+
message.gsub!(/\n\s+/, "\n")
|
20
|
+
message = message.split("\n")
|
21
|
+
message.each do |line|
|
22
|
+
line.gsub!(/^------/, ' ') if line[0..5] == '------'
|
23
|
+
line.gsub!(/^----/, ' ') if line[0..3] == '----'
|
24
|
+
line.gsub!(/^--/, ' ') if line[0..1] == '--'
|
25
|
+
stdout.puts line
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/mkmatter/answers.rb
CHANGED
@@ -8,7 +8,7 @@ module Mkmatter
|
|
8
8
|
attr_accessor :slug_date, :answer_hash
|
9
9
|
attr_accessor :published, :file_format
|
10
10
|
attr_reader :matter
|
11
|
-
|
11
|
+
|
12
12
|
def initialize(question_hash, publish)
|
13
13
|
@title = question_hash[:title]
|
14
14
|
@tags = question_hash[:tags]
|
@@ -20,7 +20,7 @@ module Mkmatter
|
|
20
20
|
@published = publish
|
21
21
|
@file_format = question_hash[:file_format]
|
22
22
|
@matter = {
|
23
|
-
layout:
|
23
|
+
layout: question_hash[:layout],
|
24
24
|
title: @title,
|
25
25
|
categories: @categories,
|
26
26
|
tags: @tags,
|
@@ -28,18 +28,18 @@ module Mkmatter
|
|
28
28
|
}
|
29
29
|
@matter[:published] = @published if publish
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
# @return [Hash] returns attribute `.matter`
|
33
33
|
def to_h
|
34
34
|
@matter
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
# @param [Hash] hash other hash
|
38
38
|
# @return [nil] merges hash into attribute `.matter`
|
39
39
|
def to_h=(hash)
|
40
40
|
@matter.merge!(hash)
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
alias_method :inspect, :to_h
|
44
44
|
#
|
45
45
|
# Dumps all file applicable metadata to a provided output.
|
data/lib/mkmatter/cli/app.rb
CHANGED
@@ -31,15 +31,15 @@ module Mkmatter
|
|
31
31
|
def __debug
|
32
32
|
report = YAML.safe_load(OS.report)
|
33
33
|
rows = {
|
34
|
-
|
35
|
-
|
34
|
+
:mkmatter_version => Mkmatter::VERSION,
|
35
|
+
:ruby_version => RbConfig::CONFIG['RUBY_PROGRAM_VERSION'],
|
36
36
|
}
|
37
37
|
rows.merge! report
|
38
38
|
rows.merge!({
|
39
|
-
'
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
'ruby bin' => OS.ruby_bin,
|
40
|
+
:windows => OS.windows?,
|
41
|
+
:posix => OS.posix?,
|
42
|
+
:mac => OS.mac?,
|
43
43
|
'under windows' => OS::Underlying.windows?,
|
44
44
|
'under bsd' => OS::Underlying.bsd?,
|
45
45
|
})
|
@@ -1,38 +1,30 @@
|
|
1
1
|
require 'highline'
|
2
|
+
require 'paint'
|
2
3
|
HighLine.colorize_strings
|
3
4
|
|
4
5
|
module Mkmatter
|
5
6
|
module App
|
6
7
|
module Descriptions
|
7
8
|
module New
|
8
|
-
PAGE = ERB.new(<<-
|
9
|
-
|
9
|
+
PAGE = ERB.new(<<-PAGE
|
10
|
+
--`mkmatter new page` will run you through making a jekyll page.
|
11
|
+
--Given the above options/flags you can modify how the script
|
12
|
+
--outputs your front matter, or whether to mark it as published.
|
13
|
+
--<%= Paint['OPTIONS', 'green', :bold] %>:
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
outputs your front matter, or whether to mark it as published.
|
14
|
-
|
15
|
-
PAGEDOC
|
15
|
+
PAGE
|
16
16
|
).result
|
17
17
|
|
18
|
-
POST = ERB.new(<<-POSTDOC
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
By default Jekyll will publish a post if `published` is omitted in
|
31
|
-
|
32
|
-
the front matter. So if you omit `--publish` you will publish,
|
33
|
-
|
34
|
-
so you have to explicitly use --no-publish to set `<%= HighLine.color('published', :yellow) %>:
|
35
|
-
<%= HighLine.color('false', :yellow, :bold) %>`
|
18
|
+
POST = ERB.new(<<-POSTDOC
|
19
|
+
--`mkmatter new post` will run you through making a jekyll post.
|
20
|
+
--Given the above options/flags you can modify how the script
|
21
|
+
--outputs your front matter, and whether to mark it as published,
|
22
|
+
--or as a draft and move it into `_drafts`.
|
23
|
+
--<%= Paint['NOTES', 'green', :bold] %>:
|
24
|
+
----By default Jekyll will publish a post if `published` is omitted in
|
25
|
+
----the front matter. So if you omit `--publish` you will publish,
|
26
|
+
----so you have to explicitly use --no-publish to set
|
27
|
+
----`<%= HighLine.color('published', :yellow) %>: <%= HighLine.color('false', :yellow, :bold) %>`
|
36
28
|
|
37
29
|
POSTDOC
|
38
30
|
).result
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'highline'
|
2
2
|
require 'thor'
|
3
|
-
|
4
3
|
require 'mkmatter/cli/descriptions'
|
5
4
|
require 'mkmatter/cli/methods'
|
6
5
|
require 'mkmatter/questions'
|
@@ -13,10 +12,11 @@ module Mkmatter
|
|
13
12
|
include Thor::Actions
|
14
13
|
HILINE = HighLine.new($stdin, $stderr, 40)
|
15
14
|
option :publish, :type => :boolean
|
16
|
-
option :file, :type => :boolean
|
15
|
+
option :file, :type => :boolean, :default => nil
|
16
|
+
method_options %w( template -t ) => :boolean
|
17
17
|
desc 'page [options]', 'make front matter (and possibly content) for a jekyll page'
|
18
18
|
long_desc Mkmatter::App::Descriptions::New::PAGE
|
19
|
-
|
19
|
+
|
20
20
|
def page
|
21
21
|
if options[:file]
|
22
22
|
if Mkmatter::Methods.check_if_jekyll
|
@@ -37,19 +37,19 @@ module Mkmatter
|
|
37
37
|
begin
|
38
38
|
FileUtils.mkdir_p(File.join(Mkmatter::Methods.get_jekyll_root, folder))
|
39
39
|
rescue Errno::EEXIST
|
40
|
-
HILINE.say("<%=
|
40
|
+
HILINE.say("<%= Paint['Error', 'red', :bold] %>: Insufficient Permissions")
|
41
41
|
exit 1
|
42
42
|
end
|
43
43
|
path = Pathname(folder).realdirpath.join(filename)
|
44
44
|
end
|
45
45
|
File.open(path.to_path, 'a') do |fd|
|
46
|
-
answers.to_h = {
|
46
|
+
answers.to_h = {:layout => 'page'}
|
47
47
|
fd.puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
|
48
48
|
fd.puts '---'
|
49
49
|
end
|
50
50
|
Mkmatter::Methods.launch_editor(options[:editor], path)
|
51
51
|
else
|
52
|
-
puts "Not in a Jekyll directory. (no '_config.yml' in any parent directory)"
|
52
|
+
$stderr.puts "Not in a Jekyll directory. (no '_config.yml' in any parent directory)"
|
53
53
|
exit 1
|
54
54
|
end
|
55
55
|
else
|
@@ -60,29 +60,27 @@ module Mkmatter
|
|
60
60
|
puts '---'
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
64
|
-
|
63
|
+
|
64
|
+
|
65
65
|
option :publish, :type => :boolean
|
66
|
-
option :file, :type => :boolean
|
67
|
-
option :draft, :type => :boolean
|
66
|
+
option :file, :type => :boolean, :default => nil
|
67
|
+
option :draft, :type => :boolean, :default => nil
|
68
68
|
desc 'post [options]', 'make front matter (and possibly content) for a jekyll post'
|
69
69
|
long_desc Mkmatter::App::Descriptions::New::POST
|
70
|
-
|
70
|
+
|
71
71
|
def post
|
72
|
-
|
73
72
|
if options[:draft] and options[:file]
|
74
|
-
|
75
73
|
if Mkmatter::Methods.check_if_jekyll
|
76
74
|
@questions = Mkmatter::Questions::Post.new(HILINE).ask
|
77
75
|
answers = Mkmatter::Answers.new(@questions, options[:publish])
|
78
76
|
file_folder = '_drafts'
|
79
77
|
filename = [].concat([answers.slug_date, '-', answers.title.to_slug, '.', answers.file_format.downcase]).join
|
80
|
-
|
78
|
+
|
81
79
|
path = Pathname("./#{file_folder}/#{filename}").realdirpath
|
82
80
|
if HILINE.agree('Would you like to put this page into a subdirectory?', true)
|
83
81
|
HILINE.say("What path? (directories will be created if they don't exist)")
|
84
82
|
HILINE.say("Don't use a path starting with a slash, just put a relative path.")
|
85
|
-
HILINE.say(
|
83
|
+
HILINE.say("<% Paint['Good', 'green', :bold] %>: path/to/dir ‖ <%= color('Bad', 'red', :bold) %>: /root/paths/are/bad/mmkay")
|
86
84
|
folder = HILINE.ask('? ') do |q|
|
87
85
|
q.confirm = true
|
88
86
|
q.default = '.'
|
@@ -92,13 +90,13 @@ module Mkmatter
|
|
92
90
|
begin
|
93
91
|
FileUtils.mkdir_p(File.join(Mkmatter::Methods.get_jekyll_root, folder))
|
94
92
|
rescue Errno::EEXIST
|
95
|
-
HILINE.say("
|
93
|
+
HILINE.say("<% Paint['Error', 'red', :bold] %>:Insufficient Permissions")
|
96
94
|
exit 1
|
97
95
|
end
|
98
96
|
path = Pathname(folder).realdirpath.join(filename)
|
99
97
|
end
|
100
98
|
File.open(path.to_path, 'a') do |fd|
|
101
|
-
answers.to_h = {
|
99
|
+
answers.to_h = {:layout => 'post'}
|
102
100
|
fd.puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
|
103
101
|
fd.puts '---'
|
104
102
|
end
|
@@ -108,7 +106,7 @@ module Mkmatter
|
|
108
106
|
exit 1
|
109
107
|
end
|
110
108
|
elsif options[:file] and options[:draft].nil? or options[:draft] == false
|
111
|
-
|
109
|
+
|
112
110
|
if Mkmatter::Methods.check_if_jekyll
|
113
111
|
@questions = Mkmatter::Questions::Post.new(HILINE).ask
|
114
112
|
answers = Mkmatter::Answers.new(@questions, options[:publish])
|
@@ -120,7 +118,7 @@ module Mkmatter
|
|
120
118
|
HILINE.say('----------------')
|
121
119
|
HILINE.say("Don't use a path starting with a slash, just put a relative path.")
|
122
120
|
HILINE.say("If you enter a path you don't like, you will have manually remove it if you confirm it.")
|
123
|
-
HILINE.say(
|
121
|
+
HILINE.say("<% Paint['Good', 'green', :bold] %>: path/to/dir ‖ <% Paint['Bad', :red, :bold] %>: /root/paths/are/bad/mmkay")
|
124
122
|
folder = HILINE.ask('? ') do |q|
|
125
123
|
q.confirm = true
|
126
124
|
q.default = '.'
|
@@ -130,17 +128,17 @@ module Mkmatter
|
|
130
128
|
begin
|
131
129
|
FileUtils.mkdir_p(File.join(Mkmatter::Methods.get_jekyll_root, folder))
|
132
130
|
rescue Errno::EEXIST
|
133
|
-
HILINE.say("
|
131
|
+
HILINE.say("<% Paint['Error', 'red', :bold] %>:Insufficient Permissions")
|
134
132
|
exit 1
|
135
133
|
end
|
136
134
|
path = Pathname(folder).realdirpath.join(filename)
|
137
135
|
end
|
138
136
|
File.open(path.to_path, 'a') do |fd|
|
139
|
-
answers.to_h = {
|
137
|
+
answers.to_h = {:layout => 'post'}
|
140
138
|
fd.puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
|
141
139
|
fd.puts '---'
|
142
140
|
end
|
143
|
-
|
141
|
+
|
144
142
|
Mkmatter::Methods.launch_editor(options[:editor], path)
|
145
143
|
else
|
146
144
|
puts "Not in a Jekyll directory. (no '_config.yml' in any parent directory)"
|
@@ -152,10 +150,10 @@ module Mkmatter
|
|
152
150
|
puts ''
|
153
151
|
puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
|
154
152
|
puts '---'
|
155
|
-
|
153
|
+
|
156
154
|
end
|
157
155
|
end
|
158
156
|
end
|
159
157
|
end
|
160
158
|
end
|
161
|
-
end
|
159
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require '
|
2
|
+
require 'paint'
|
3
3
|
require 'mkmatter/cli/methods'
|
4
4
|
require 'mkmatter/cli/tags'
|
5
5
|
module Mkmatter
|
@@ -7,16 +7,14 @@ module Mkmatter
|
|
7
7
|
module Classes
|
8
8
|
class Tags < Thor
|
9
9
|
include Thor::Actions
|
10
|
-
HILINE = HighLine.new($stdin, $stderr, 80)
|
11
|
-
|
12
10
|
desc 'find [options] TYPE', 'find content of type TYPE'
|
13
11
|
# @param [String] type Type of content
|
14
12
|
def find(type)
|
15
13
|
if Mkmatter::Methods.check_if_jekyll
|
16
14
|
table = Terminal::Table.new
|
17
|
-
table.title =
|
15
|
+
table.title = type.capitalize
|
18
16
|
table.style.all_separators = true
|
19
|
-
table.headings = ["#{
|
17
|
+
table.headings = ["#{Paint['Path from Jekyll Root', 'white', :bold]}", "#{Paint['Tags', 'white', :bold]}"]
|
20
18
|
|
21
19
|
front_matter = Mkmatter::Methods.find_front_matter(type, 'tags')
|
22
20
|
front_matter.each do |path, tags|
|
@@ -26,7 +24,7 @@ module Mkmatter
|
|
26
24
|
table.align_column(1, :right)
|
27
25
|
puts table
|
28
26
|
else
|
29
|
-
$stderr.puts "#{
|
27
|
+
$stderr.puts "#{Paint['Error', :red, :bold]}: Not a Jekyll source directory (no '_config.yml' found in any parent directory)"
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
@@ -36,7 +34,7 @@ module Mkmatter
|
|
36
34
|
if Mkmatter::Methods.check_if_jekyll
|
37
35
|
|
38
36
|
else
|
39
|
-
$stderr.puts "#{
|
37
|
+
$stderr.puts "#{Paint['Error', :red, :bold]}: Not a Jekyll source directory (no '_config.yml' found in any parent directory)"
|
40
38
|
end
|
41
39
|
end
|
42
40
|
|
@@ -55,7 +53,7 @@ module Mkmatter
|
|
55
53
|
all_tags = tags.flatten.sort.uniq
|
56
54
|
Mkmatter::Tags.dry_gen all_tags
|
57
55
|
else
|
58
|
-
|
56
|
+
$stderr.puts "#{Paint['Error', :red, :bold]}: No tag folder"
|
59
57
|
end
|
60
58
|
else
|
61
59
|
if Mkmatter::Tags.has_tag_folder?
|
@@ -67,10 +65,9 @@ module Mkmatter
|
|
67
65
|
all_tags = tags.flatten.sort.uniq
|
68
66
|
Mkmatter::Tags.gen_post_tags all_tags
|
69
67
|
else
|
70
|
-
$stderr.puts "#{
|
68
|
+
$stderr.puts "#{Paint['Error', :red, :bold]}: Not a Jekyll source directory (no '_config.yml' found in any parent directory)"
|
71
69
|
end
|
72
70
|
end
|
73
|
-
|
74
71
|
end
|
75
72
|
end
|
76
73
|
end
|
data/lib/mkmatter/common.rb
CHANGED
@@ -6,7 +6,7 @@ module Mkmatter
|
|
6
6
|
attr_accessor :time_zone
|
7
7
|
# @param [HighLine] hl A highline context
|
8
8
|
# @return [String]
|
9
|
-
def
|
9
|
+
def get_001_title(hl)
|
10
10
|
title = hl.ask 'Title: '
|
11
11
|
if hl.agree("Would you like it 'titleized' (Title instead of title)? ", true)
|
12
12
|
title.titleize
|
@@ -14,22 +14,22 @@ module Mkmatter
|
|
14
14
|
title
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
# @param [HighLine] hl A highline context
|
19
19
|
# @return [String]
|
20
|
-
def
|
20
|
+
def get_002_tags(hl)
|
21
21
|
hl.ask 'Tags? (this would be a comma separated list.) ', -> (str) {str.split(',')}
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
# @param [HighLine] hl A highline context
|
25
25
|
# @return [String]
|
26
|
-
def
|
26
|
+
def get_003_categories(hl)
|
27
27
|
hl.ask 'Categories? (space separated list) ', -> (str) {str.split(' ')}
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
# @param [HighLine] hl A highline context
|
31
31
|
# @return [String]
|
32
|
-
def
|
32
|
+
def get_004_time_zone(hl)
|
33
33
|
custom = nil
|
34
34
|
timezone = hl.choose do |m|
|
35
35
|
m.header = 'Time Zone? (select by number)'
|
@@ -59,14 +59,18 @@ module Mkmatter
|
|
59
59
|
custom
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
# @param [HighLine] hl A highline context
|
64
64
|
# @return [String]
|
65
|
-
def
|
65
|
+
def get_005_file_format(hl)
|
66
66
|
hl.choose do |menu|
|
67
|
-
menu.header = 'Choose whether you want HTML or Markdown
|
68
|
-
menu.choice 'html'
|
69
|
-
|
67
|
+
menu.header = 'Choose whether you want HTML or Markdown'
|
68
|
+
menu.choice 'html' do
|
69
|
+
return 'html'
|
70
|
+
end
|
71
|
+
menu.choice 'md' do
|
72
|
+
return 'md'
|
73
|
+
end
|
70
74
|
menu.prompt = '? '
|
71
75
|
end
|
72
76
|
end
|
data/lib/mkmatter/questions.rb
CHANGED
@@ -9,21 +9,22 @@ module Mkmatter
|
|
9
9
|
|
10
10
|
attr :answers
|
11
11
|
attr :highline_context
|
12
|
-
|
12
|
+
|
13
13
|
# @!visibility private
|
14
14
|
# @param [HighLine] highline_context a highline context
|
15
15
|
def initialize(highline_context)
|
16
16
|
@highline_context = highline_context
|
17
17
|
@answers = OpenStruct.new
|
18
|
-
|
19
|
-
|
18
|
+
|
19
|
+
|
20
20
|
end
|
21
21
|
|
22
22
|
# @return [OpenStruct]
|
23
23
|
def ask
|
24
|
-
known_questions = self.methods.delete_if { |m| m.to_s !~ /^get_.*$/ }
|
24
|
+
known_questions = self.methods.sort.delete_if { |m| m.to_s !~ /^get_.*$/ }
|
25
25
|
known_questions.each do |m|
|
26
|
-
@answers[
|
26
|
+
@answers[:layout] = 'post'
|
27
|
+
@answers[m.to_s.gsub(/^get_[0-9]{3}_/, '')] = self.method(m).call(@highline_context)
|
27
28
|
end
|
28
29
|
@answers
|
29
30
|
end
|
@@ -33,20 +34,21 @@ module Mkmatter
|
|
33
34
|
include Mkmatter::Common
|
34
35
|
attr :answers
|
35
36
|
attr :highline_context
|
36
|
-
|
37
|
-
|
37
|
+
|
38
|
+
|
38
39
|
# @!visibility private
|
39
40
|
def initialize(highline_context)
|
40
41
|
@answers = OpenStruct.new
|
41
|
-
|
42
|
+
|
42
43
|
@highline_context = highline_context
|
43
44
|
end
|
44
|
-
|
45
|
+
|
45
46
|
# @return [OpenStruct]
|
46
47
|
def ask
|
47
|
-
known_questions = self.methods.delete_if { |m| m.to_s !~ /^get_.*$/ }
|
48
|
+
known_questions = self.methods.sort.delete_if { |m| m.to_s !~ /^get_.*$/ }
|
48
49
|
known_questions.each do |m|
|
49
|
-
@answers[
|
50
|
+
@answers[:layout] = 'page'
|
51
|
+
@answers[m.to_s.gsub(/^get_[0-9]{3}_/, '')] = self.method(m).call(@highline_context)
|
50
52
|
end
|
51
53
|
@answers
|
52
54
|
end
|
data/lib/mkmatter/version.rb
CHANGED
data/mkmatter.gemspec
CHANGED
@@ -43,6 +43,7 @@ Gem::Specification.new do |spec|
|
|
43
43
|
spec.add_runtime_dependency 'thor', '~> 0.20'
|
44
44
|
spec.add_runtime_dependency 'terminal-table', '~> 1.8'
|
45
45
|
spec.add_runtime_dependency 'os', '~> 1.0'
|
46
|
+
spec.add_runtime_dependency 'paint', '~> 2.0'
|
46
47
|
spec.add_runtime_dependency 'front_matter_parser', '~> 0.1'
|
47
48
|
spec.add_runtime_dependency 'rake', '~> 10.0'
|
48
49
|
spec.add_runtime_dependency 'micro_install', '~> 0.1.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mkmatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Spencer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: paint
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '2.0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: front_matter_parser
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,7 +218,6 @@ files:
|
|
204
218
|
- ".gitlab-ci.yml"
|
205
219
|
- ".travis.yml"
|
206
220
|
- Gemfile
|
207
|
-
- Gemfile.lock
|
208
221
|
- LICENSE
|
209
222
|
- LICENSE.txt
|
210
223
|
- README.md
|
@@ -259,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
272
|
version: '0'
|
260
273
|
requirements: []
|
261
274
|
rubyforge_project:
|
262
|
-
rubygems_version: 2.
|
275
|
+
rubygems_version: 2.7.6
|
263
276
|
signing_key:
|
264
277
|
specification_version: 4
|
265
278
|
summary: Script facilitating easy content creation and generation for Jekyll Sites
|
data/Gemfile.lock
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
mkmatter (3.0.44)
|
5
|
-
activesupport (~> 5.1)
|
6
|
-
front_matter_parser (~> 0.1)
|
7
|
-
git (~> 1.3)
|
8
|
-
highline (~> 1.7)
|
9
|
-
micro_install (~> 0.1.0)
|
10
|
-
os (~> 1.0)
|
11
|
-
rake (~> 10.0)
|
12
|
-
slugity (~> 1.1)
|
13
|
-
terminal-table (~> 1.8)
|
14
|
-
thor (~> 0.20)
|
15
|
-
|
16
|
-
GEM
|
17
|
-
remote: https://rubygems.org/
|
18
|
-
specs:
|
19
|
-
activesupport (5.1.5)
|
20
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
21
|
-
i18n (~> 0.7)
|
22
|
-
minitest (~> 5.1)
|
23
|
-
tzinfo (~> 1.1)
|
24
|
-
addressable (2.3.8)
|
25
|
-
ansi (1.5.0)
|
26
|
-
builder (3.2.3)
|
27
|
-
concurrent-ruby (1.0.5)
|
28
|
-
front_matter_parser (0.1.1)
|
29
|
-
git (1.3.0)
|
30
|
-
highline (1.7.10)
|
31
|
-
i18n (0.9.5)
|
32
|
-
concurrent-ruby (~> 1.0)
|
33
|
-
json (1.8.6)
|
34
|
-
micro_install (0.1.0)
|
35
|
-
highline (~> 1.7)
|
36
|
-
os (~> 1.0)
|
37
|
-
paint (~> 2.0.1)
|
38
|
-
thor (~> 0.20)
|
39
|
-
unirest (~> 1.1)
|
40
|
-
mime-types (1.25.1)
|
41
|
-
minitest (5.11.3)
|
42
|
-
minitest-reporters (1.1.19)
|
43
|
-
ansi
|
44
|
-
builder
|
45
|
-
minitest (>= 5.0)
|
46
|
-
ruby-progressbar
|
47
|
-
os (1.0.0)
|
48
|
-
paint (2.0.1)
|
49
|
-
rake (10.5.0)
|
50
|
-
rest-client (1.6.9)
|
51
|
-
mime-types (~> 1.16)
|
52
|
-
ruby-progressbar (1.9.0)
|
53
|
-
slugity (1.1.0)
|
54
|
-
terminal-table (1.8.0)
|
55
|
-
unicode-display_width (~> 1.1, >= 1.1.1)
|
56
|
-
thor (0.20.0)
|
57
|
-
thread_safe (0.3.6)
|
58
|
-
tzinfo (1.2.5)
|
59
|
-
thread_safe (~> 0.1)
|
60
|
-
unicode-display_width (1.3.0)
|
61
|
-
unirest (1.1.2)
|
62
|
-
addressable (~> 2.3.5)
|
63
|
-
json (~> 1.8.1)
|
64
|
-
rest-client (~> 1.6.7)
|
65
|
-
|
66
|
-
PLATFORMS
|
67
|
-
ruby
|
68
|
-
|
69
|
-
DEPENDENCIES
|
70
|
-
bundler (~> 1.16)
|
71
|
-
minitest (~> 5)
|
72
|
-
minitest-reporters (~> 1.1)
|
73
|
-
mkmatter!
|
74
|
-
|
75
|
-
BUNDLED WITH
|
76
|
-
1.16.1
|