mkmatter 3.1.6 → 3.1.8
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 +4 -4
- data/.rspec +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +1 -0
- data/Rakefile +9 -5
- data/features/support/env.rb +1 -0
- data/lib/mkmatter/answers.rb +1 -1
- data/lib/mkmatter/cli/app.rb +2 -2
- data/lib/mkmatter/cli/subs/new.rb +4 -4
- data/lib/mkmatter/cli.rb +2 -1
- data/lib/mkmatter/common.rb +1 -68
- data/lib/mkmatter/questions.rb +212 -26
- data/lib/mkmatter/version.rb +1 -1
- data/mkmatter.gemspec +5 -0
- data/sig/mkmatter/questions/page.rbs +8 -0
- data/sig/mkmatter/questions/post.rbs +9 -0
- data/spec/class_option_spec.rb +29 -0
- data/spec/descriptions_spec.rb +18 -0
- data/spec/questions_spec.rb +72 -0
- data/spec/spec_helper.rb +36 -0
- metadata +84 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 741fb652dc3a0d6b4b34cb7470396346361940b0e4c9be88f6ada29d947340e9
|
4
|
+
data.tar.gz: f71a708219df1d247f4722f121fc20813efcb7a5a6764dab2522034dce5e39d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '099fc8f0effd004d3c6ed4aaf3d48997805111cfac0fcdd053588db136f2f9ab0fc634432b11487ebbd97925e5fd56df7687cd6f5939bb911777cbf663af6e8e'
|
7
|
+
data.tar.gz: a0c643a676c9f259017f2e61bd279f4245cc3cb613b30d87877d7d8089287d53229c936930a41f967ba767dd5d0f8acadc6287d99a4ea2832b58d838256ce0ec
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
-fd -b
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.1.7
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rake/testtask'
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
RSpec::Core::RakeTask.new(:test)
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
|
7
|
+
# Rake::TestTask.new do |t|
|
8
|
+
# t.test_files = FileList['test/**/*_test.rb']
|
9
|
+
# t.libs = ['../lib/mkmatter.rb']
|
10
|
+
# t.warning = false
|
11
|
+
# end
|
8
12
|
|
9
13
|
desc 'Run tests'
|
10
14
|
task default: :test
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'aruba/cucumber'
|
data/lib/mkmatter/answers.rb
CHANGED
@@ -50,7 +50,7 @@ module Mkmatter
|
|
50
50
|
# Custom matter
|
51
51
|
if hl.agree('Do you want to add custom fields? (usable as {{LAYOUT_TYPE.FIELD}} in templates) ', true)
|
52
52
|
hl.say('Your fields should be inputted as FIELD=>TEXT HERE')
|
53
|
-
hl.say("
|
53
|
+
hl.say("Type 'EOL' on a new line then press Enter when you are done.")
|
54
54
|
hl.say("<% HighLine.color('NOTE', :bold, :red) %>: Input is <% HighLine.color('NOT', :bold, :red) %> evaluated!")
|
55
55
|
custom_fields = hl.ask('Fields?') do |q|
|
56
56
|
q.gather = /^EOL$/
|
data/lib/mkmatter/cli/app.rb
CHANGED
@@ -42,7 +42,7 @@ module Mkmatter
|
|
42
42
|
'under windows' => OS::Underlying.windows?,
|
43
43
|
'under bsd' => OS::Underlying.bsd?,
|
44
44
|
})
|
45
|
-
table = Terminal::Table.new
|
45
|
+
table = ::Terminal::Table.new
|
46
46
|
table.title = 'mkmatter Debug Info'
|
47
47
|
table.rows = rows.to_a
|
48
48
|
table.align_column(0, :left)
|
@@ -65,7 +65,7 @@ module Mkmatter
|
|
65
65
|
}
|
66
66
|
case format
|
67
67
|
when 'table'
|
68
|
-
table = Terminal::Table.new
|
68
|
+
table = ::Terminal::Table.new
|
69
69
|
table.style.alignment = :center
|
70
70
|
table.title = 'mkmatter Info'
|
71
71
|
table.rows = rows.to_a
|
@@ -12,7 +12,7 @@ module Mkmatter
|
|
12
12
|
include Thor::Actions
|
13
13
|
HILINE = HighLine.new($stdin, $stderr, 40)
|
14
14
|
option :publish, :type => :boolean
|
15
|
-
option :file, :type => :boolean, :default =>
|
15
|
+
option :file, :type => :boolean, :default => true
|
16
16
|
option :index, :type => :boolean, :default => nil
|
17
17
|
method_options %w( template -t ) => :boolean
|
18
18
|
desc 'page [options]', 'make front matter (and possibly content) for a jekyll page'
|
@@ -33,7 +33,7 @@ module Mkmatter
|
|
33
33
|
if HILINE.agree('Would you like to put this page into a subdirectory?', true)
|
34
34
|
HILINE.say("What path? (directories will be created if they don't exist) ")
|
35
35
|
HILINE.say("Don't use a path starting with a slash, just put a relative path.")
|
36
|
-
HILINE.say('good => path/to/dir ‖ bad => /
|
36
|
+
HILINE.say('good => path/to/dir ‖ bad => /absolute/paths/are/bad/mmkay')
|
37
37
|
folder = HILINE.ask('? ') do |q|
|
38
38
|
q.confirm = true
|
39
39
|
q.default = '.'
|
@@ -69,7 +69,7 @@ module Mkmatter
|
|
69
69
|
|
70
70
|
|
71
71
|
option :publish, :type => :boolean
|
72
|
-
option :file, :type => :boolean, :default =>
|
72
|
+
option :file, :type => :boolean, :default => true
|
73
73
|
option :draft, :type => :boolean, :default => nil
|
74
74
|
desc 'post [options]', 'make front matter (and possibly content) for a jekyll post'
|
75
75
|
long_desc Mkmatter::App::Descriptions::New::POST
|
@@ -86,7 +86,7 @@ module Mkmatter
|
|
86
86
|
if HILINE.agree('Would you like to put this page into a subdirectory?', true)
|
87
87
|
HILINE.say("What path? (directories will be created if they don't exist)")
|
88
88
|
HILINE.say("Don't use a path starting with a slash, just put a relative path.")
|
89
|
-
HILINE.say("<% Paint['Good', 'green', :bold] %>: path/to/dir ‖ <%= color('Bad', 'red', :bold) %>: /
|
89
|
+
HILINE.say("<% Paint['Good', 'green', :bold] %>: path/to/dir ‖ <%= color('Bad', 'red', :bold) %>: /absolute/paths/are/bad/mmkay")
|
90
90
|
folder = HILINE.ask('? ') do |q|
|
91
91
|
q.confirm = true
|
92
92
|
q.default = '.'
|
data/lib/mkmatter/cli.rb
CHANGED
data/lib/mkmatter/common.rb
CHANGED
@@ -1,78 +1,11 @@
|
|
1
1
|
require 'highline'
|
2
2
|
require 'active_support/all'
|
3
|
+
require 'mkmatter/questions'
|
3
4
|
|
4
5
|
module Mkmatter
|
5
6
|
module Common
|
6
|
-
attr_accessor :time_zone
|
7
7
|
# @param [HighLine] hl A highline context
|
8
8
|
# @return [String]
|
9
|
-
def get_001_title(hl)
|
10
|
-
title = hl.ask 'Title: '
|
11
|
-
if hl.agree("Would you like it 'titleized' (Title instead of title)? ", true)
|
12
|
-
title.titleize
|
13
|
-
else
|
14
|
-
title
|
15
|
-
end
|
16
|
-
end
|
17
9
|
|
18
|
-
# @param [HighLine] hl A highline context
|
19
|
-
# @return [String]
|
20
|
-
def get_002_tags(hl)
|
21
|
-
hl.ask 'Tags? (this would be a comma separated list.) ', -> (str) {str.split(',')}
|
22
|
-
end
|
23
|
-
|
24
|
-
# @param [HighLine] hl A highline context
|
25
|
-
# @return [String]
|
26
|
-
def get_003_categories(hl)
|
27
|
-
hl.ask 'Categories? (space separated list) ', -> (str) {str.split(' ')}
|
28
|
-
end
|
29
|
-
|
30
|
-
# @param [HighLine] hl A highline context
|
31
|
-
# @return [String]
|
32
|
-
def get_004_time_zone(hl)
|
33
|
-
custom = nil
|
34
|
-
timezone = hl.choose do |m|
|
35
|
-
m.header = 'Time Zone? (select by number)'
|
36
|
-
m.choice('Eastern Time (US & Canada)') do
|
37
|
-
return 'Eastern Time (US & Canada)'
|
38
|
-
end
|
39
|
-
m.choice('Central Time (US & Canada)') do
|
40
|
-
return 'Central Time (US & Canada)'
|
41
|
-
end
|
42
|
-
m.choice :neither
|
43
|
-
m.prompt = '? '
|
44
|
-
end
|
45
|
-
case
|
46
|
-
when timezone == :neither
|
47
|
-
custom = hl.ask('Other Time Zone: ', String)
|
48
|
-
end
|
49
|
-
if custom
|
50
|
-
hl.say('Checking TimeZone Validity')
|
51
|
-
print '.'
|
52
|
-
sleep(0.05)
|
53
|
-
5.times do
|
54
|
-
print '.'
|
55
|
-
sleep(0.05)
|
56
|
-
puts ''
|
57
|
-
TimeZone.find_tzinfo custom
|
58
|
-
end
|
59
|
-
custom
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
# @param [HighLine] hl A highline context
|
64
|
-
# @return [String]
|
65
|
-
def get_005_file_format(hl)
|
66
|
-
hl.choose do |menu|
|
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
|
74
|
-
menu.prompt = '? '
|
75
|
-
end
|
76
|
-
end
|
77
10
|
end
|
78
11
|
end
|
data/lib/mkmatter/questions.rb
CHANGED
@@ -1,57 +1,243 @@
|
|
1
1
|
require 'highline'
|
2
|
-
require 'mkmatter/common'
|
3
2
|
require 'ostruct'
|
4
3
|
module Mkmatter
|
5
4
|
module Questions
|
5
|
+
def self.ask(cls)
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
known_questions = const_get(cls).methods.sort.delete_if { |m| m.to_s !~ /^get_.*$/ }
|
8
|
+
known_questions.each do |m|
|
9
|
+
@answers[:layout] = cls.to_s.lower
|
10
|
+
@answers[m.to_s.gsub(/^get_[0-9]{3}_/, '')] = method(m).call
|
11
|
+
end
|
12
|
+
@answers
|
13
|
+
end
|
9
14
|
|
15
|
+
class Post
|
10
16
|
attr :answers
|
11
|
-
|
17
|
+
|
18
|
+
@hl = HighLine.new
|
19
|
+
|
20
|
+
def ask
|
21
|
+
known_questions = methods.sort.delete_if { |m| m.to_s !~ /^get_.*$/ }
|
22
|
+
known_questions.each do |m|
|
23
|
+
@answers[:layout] = 'post'
|
24
|
+
@answers[m.to_s.gsub(/^get_[0-9]{3}_/, '')] = method(m).call
|
25
|
+
end
|
26
|
+
@answers
|
27
|
+
end
|
12
28
|
|
13
29
|
# @!visibility private
|
14
|
-
|
15
|
-
def initialize(highline_context)
|
16
|
-
@highline_context = highline_context
|
30
|
+
def initialize
|
17
31
|
@answers = OpenStruct.new
|
32
|
+
@hl = HighLine.new
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_001_title
|
36
|
+
hl = @hl
|
37
|
+
title = hl.ask 'Title: '
|
38
|
+
if hl.agree("Would you like it 'titleized' (Title instead of title)? ")
|
39
|
+
title.titleize
|
40
|
+
else
|
41
|
+
title
|
42
|
+
end
|
43
|
+
end
|
18
44
|
|
45
|
+
# @return [Array]
|
46
|
+
def get_002_tags
|
47
|
+
hl = @hl
|
48
|
+
hl.ask("Tags? (write one on each line, then type '.') ") do |q|
|
49
|
+
q.gather = '.'
|
50
|
+
end
|
51
|
+
end
|
19
52
|
|
53
|
+
# @return [Array]
|
54
|
+
def get_003_categories
|
55
|
+
hl = @hl
|
56
|
+
hl.ask("Categories? (write one on each line, then type '.') ") do |q|
|
57
|
+
q.gather = '.'
|
58
|
+
end
|
20
59
|
end
|
21
60
|
|
22
|
-
# @return [
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
61
|
+
# @return [String]
|
62
|
+
def get_004_time_zone
|
63
|
+
hl = @hl
|
64
|
+
custom = nil
|
65
|
+
timezone = hl.choose do |m|
|
66
|
+
m.header = 'Time Zone? (select by number)'
|
67
|
+
m.choice('Eastern Time (US & Canada)') do
|
68
|
+
return 'Eastern Time (US & Canada)'
|
69
|
+
end
|
70
|
+
m.choice('Central Time (US & Canada)') do
|
71
|
+
return 'Central Time (US & Canada)'
|
72
|
+
end
|
73
|
+
m.choice :neither
|
74
|
+
m.prompt = '? '
|
28
75
|
end
|
29
|
-
|
76
|
+
custom = hl.ask('Other Time Zone: ', String) if timezone == :neither
|
77
|
+
return unless custom
|
78
|
+
|
79
|
+
hl.say('Checking TimeZone Validity')
|
80
|
+
print '.'
|
81
|
+
sleep(0.05)
|
82
|
+
5.times do
|
83
|
+
print '.'
|
84
|
+
sleep(0.05)
|
85
|
+
puts ''
|
86
|
+
TimeZone.find_tzinfo custom
|
87
|
+
end
|
88
|
+
custom
|
89
|
+
end
|
90
|
+
|
91
|
+
# @return [String]
|
92
|
+
def get_005_file_format
|
93
|
+
hl = @hl
|
94
|
+
hl.choose do |menu|
|
95
|
+
menu.header = 'Choose whether you want HTML or Markdown'
|
96
|
+
menu.choice 'html' do
|
97
|
+
return 'html'
|
98
|
+
end
|
99
|
+
menu.choice 'md' do
|
100
|
+
return 'md'
|
101
|
+
end
|
102
|
+
menu.prompt = '? '
|
103
|
+
end
|
104
|
+
end
|
105
|
+
# @return [String]
|
106
|
+
def get_006_extra_fields
|
107
|
+
hl = @hl
|
108
|
+
custom_fields = nil
|
109
|
+
if hl.agree('Do you want to add custom fields? (usable as {{LAYOUT_TYPE.FIELD}} in templates) ', true)
|
110
|
+
hl.say('Your fields should be inputted as FIELD=>TEXT HERE')
|
111
|
+
hl.say("Type 'EOL' on a new line then press Enter when you are done.")
|
112
|
+
hl.say("<% HighLine.color('NOTE', :bold, :red) %>: Input is <% HighLine.color('NOT', :bold, :red) %> evaluated!")
|
113
|
+
custom_fields = hl.ask('Fields?') do |q|
|
114
|
+
q.gather = /^EOL$/
|
115
|
+
end
|
116
|
+
end
|
117
|
+
if custom_fields
|
118
|
+
fields = Hash.new
|
119
|
+
custom_fields.each do |field|
|
120
|
+
field = field.split(/=>/)
|
121
|
+
fields.store(field[0].to_s, field[1])
|
122
|
+
end
|
123
|
+
self.to_h = fields
|
124
|
+
elsif custom_fields.nil?
|
125
|
+
hl.say('No extra fields were added.')
|
126
|
+
return
|
127
|
+
else
|
128
|
+
end
|
129
|
+
custom_fields
|
30
130
|
end
|
131
|
+
# @return [OpenStruct]
|
31
132
|
end
|
32
133
|
|
33
134
|
class Page
|
34
|
-
include Mkmatter::Common
|
35
135
|
attr :answers
|
36
|
-
|
37
|
-
|
136
|
+
@hl = HighLine.new
|
38
137
|
|
39
138
|
# @!visibility private
|
40
|
-
def initialize
|
139
|
+
def initialize
|
41
140
|
@answers = OpenStruct.new
|
42
141
|
|
43
|
-
@highline_context = highline_context
|
44
142
|
end
|
45
143
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
144
|
+
def get_001_title
|
145
|
+
hl = @hl
|
146
|
+
title = hl.ask 'Title: '
|
147
|
+
if hl.agree("Would you like it 'titleized' (Title instead of title)? ")
|
148
|
+
title.titleize
|
149
|
+
else
|
150
|
+
title
|
52
151
|
end
|
53
|
-
@answers
|
54
152
|
end
|
153
|
+
|
154
|
+
# @return [Array]
|
155
|
+
def get_002_tags
|
156
|
+
hl = @hl
|
157
|
+
hl.ask("Tags? (write one on each line, then type '.') ") do |q|
|
158
|
+
q.gather = '.'
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# @return [Array]
|
163
|
+
def get_003_categories
|
164
|
+
hl = @hl
|
165
|
+
hl.ask("Categories? (write one on each line, then type '.') ") do |q|
|
166
|
+
q.gather = '.'
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
# @return [String]
|
171
|
+
def get_004_time_zone
|
172
|
+
hl = @hl
|
173
|
+
custom = nil
|
174
|
+
timezone = hl.choose do |m|
|
175
|
+
m.header = 'Time Zone? (select by number)'
|
176
|
+
m.choice('Eastern Time (US & Canada)') do
|
177
|
+
return 'Eastern Time (US & Canada)'
|
178
|
+
end
|
179
|
+
m.choice('Central Time (US & Canada)') do
|
180
|
+
return 'Central Time (US & Canada)'
|
181
|
+
end
|
182
|
+
m.choice :neither
|
183
|
+
m.prompt = '? '
|
184
|
+
end
|
185
|
+
custom = hl.ask('Other Time Zone: ', String) if timezone == :neither
|
186
|
+
return unless custom
|
187
|
+
|
188
|
+
hl.say('Checking TimeZone Validity')
|
189
|
+
print '.'
|
190
|
+
sleep(0.05)
|
191
|
+
5.times do
|
192
|
+
print '.'
|
193
|
+
sleep(0.05)
|
194
|
+
puts ''
|
195
|
+
TimeZone.find_tzinfo custom
|
196
|
+
end
|
197
|
+
custom
|
198
|
+
end
|
199
|
+
|
200
|
+
# @return [String]
|
201
|
+
def get_005_file_format
|
202
|
+
hl = @hl
|
203
|
+
hl.choose do |menu|
|
204
|
+
menu.header = 'Choose whether you want HTML or Markdown'
|
205
|
+
menu.choice 'html' do
|
206
|
+
return 'html'
|
207
|
+
end
|
208
|
+
menu.choice 'md' do
|
209
|
+
return 'md'
|
210
|
+
end
|
211
|
+
menu.prompt = '? '
|
212
|
+
end
|
213
|
+
end
|
214
|
+
# @return [Array[Hash]]
|
215
|
+
def get_006_extra_fields
|
216
|
+
hl = @hl
|
217
|
+
custom_fields = nil
|
218
|
+
if hl.agree('Do you want to add custom fields? (usable as {{LAYOUT_TYPE.FIELD}} in templates) ', true)
|
219
|
+
hl.say('Your fields should be inputted as FIELD=>TEXT HERE')
|
220
|
+
hl.say("Type 'EOL' on a new line then press Enter when you are done.")
|
221
|
+
hl.say("<% HighLine.color('NOTE', :bold, :red) %>: Input is <% HighLine.color('NOT', :bold, :red) %> evaluated!")
|
222
|
+
custom_fields = hl.ask('Fields?') do |q|
|
223
|
+
q.gather = /^EOL$/
|
224
|
+
end
|
225
|
+
end
|
226
|
+
if custom_fields
|
227
|
+
fields = Hash.new
|
228
|
+
custom_fields.each do |field|
|
229
|
+
field = field.split(/=>/)
|
230
|
+
fields.store(field[0].to_s, field[1])
|
231
|
+
end
|
232
|
+
self.to_h = fields
|
233
|
+
elsif custom_fields.nil?
|
234
|
+
hl.say('No extra fields were added.')
|
235
|
+
return
|
236
|
+
else
|
237
|
+
end
|
238
|
+
custom_fields
|
239
|
+
end
|
240
|
+
# @return [OpenStruct]
|
55
241
|
end
|
56
242
|
end
|
57
243
|
end
|
data/lib/mkmatter/version.rb
CHANGED
data/mkmatter.gemspec
CHANGED
@@ -48,7 +48,12 @@ Gem::Specification.new do |spec|
|
|
48
48
|
spec.add_runtime_dependency 'micro_install', '~> 0.4.0'
|
49
49
|
spec.add_development_dependency 'bundler', '~> 2.3.5'
|
50
50
|
spec.add_development_dependency 'minitest', '~> 5'
|
51
|
+
spec.add_development_dependency 'rspec-core', '~> 3.13'
|
52
|
+
spec.add_development_dependency 'rspec-expectations', '~> 3.13'
|
53
|
+
spec.add_development_dependency 'rspec-mocks', '~> 3.13'
|
51
54
|
spec.add_development_dependency 'minitest-reporters', '~> 1.6.1'
|
55
|
+
spec.add_development_dependency 'aruba', '~> 2.2.0'
|
56
|
+
spec.add_development_dependency 'highline-test', '~> 0.0.1'
|
52
57
|
spec.post_install_message = [
|
53
58
|
"Thanks for installing 'mkmatter', It means a lot to me.",
|
54
59
|
"If you'd like to install 'micro', a text editor bundled with 'mkmatter'.",
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative './spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe "Test basic 'mkmatter' commands" do
|
4
|
+
before(:all) do
|
5
|
+
@app = Mkmatter::App::CLI
|
6
|
+
end
|
7
|
+
it "outputs commands for 'mkmatter help'" do
|
8
|
+
expect { @app.start(%w(help)) }.to output(/Commands:/).to_stdout_from_any_process
|
9
|
+
end
|
10
|
+
it "outputs commands for 'mkmatter help new'" do
|
11
|
+
expect { @app.start(%w(help new)) }.to output(/Commands:/).to_stdout_from_any_process
|
12
|
+
end
|
13
|
+
it "outputs the 'mkmatter' version" do
|
14
|
+
expect { @app.start(%w(--version)) }.to output(/#{Mkmatter::VERSION}/).to_stdout_from_any_process
|
15
|
+
expect { @app.start(%w(-v)) }.to output(/#{Mkmatter::VERSION}/).to_stdout_from_any_process
|
16
|
+
end
|
17
|
+
it "outputs 'mkmatter' debug information" do
|
18
|
+
expect { @app.start(%w(--debug)) }.to output(/mkmatter Debug Info/).to_stdout_from_any_process
|
19
|
+
end
|
20
|
+
it "outputs 'mkmatter' contact info" do
|
21
|
+
expect { @app.start(%w(--info)) }.to output(/mkmatter Info/).to_stdout_from_any_process
|
22
|
+
end
|
23
|
+
it "outputs 'mkmatter' contact info in a certain format" do
|
24
|
+
expect { @app.start(%w(--info --info-format=yaml)) }.to output(/^---/).to_stdout_from_any_process
|
25
|
+
end
|
26
|
+
it "outputs an error when a nonexistent command is chosen" do
|
27
|
+
expect { @app.start(%w(nope this doesnt exist)) }.to output(/Could not find command ".*"\./).to_stderr_from_any_process
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative './spec_helper'
|
2
|
+
require_relative '../lib/mkmatter'
|
3
|
+
RSpec.describe "DescriptionsSpec" do
|
4
|
+
before do
|
5
|
+
@app = Mkmatter::App::CLI
|
6
|
+
@descriptions = Mkmatter::App::Descriptions
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
# Teardown something
|
11
|
+
end
|
12
|
+
it "outputs help for new post" do
|
13
|
+
expect { @app.start(%w(new help post)) }.to output(/mkmatter new post/).to_stdout
|
14
|
+
end
|
15
|
+
it 'outputs help for new page' do
|
16
|
+
expect { @app.start(%w(new help page)) }.to output(/mkmatter new page/).to_stdout
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
require_relative '../lib/mkmatter/cli/runner'
|
3
|
+
require 'rspec/expectations'
|
4
|
+
require 'io/console'
|
5
|
+
require 'highline'
|
6
|
+
require 'highline/test'
|
7
|
+
require 'yaml'
|
8
|
+
|
9
|
+
RSpec.configure do |c|
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
RSpec.describe 'PostQuestionsTest' do
|
14
|
+
before(:example) do
|
15
|
+
@questions = Mkmatter::Questions
|
16
|
+
|
17
|
+
# Before running a test, create a HighLine::Test::Client
|
18
|
+
@client = HighLine::Test::Client.new
|
19
|
+
|
20
|
+
# The application itself is started in a block passed to the #run method
|
21
|
+
@client.run do |driver|
|
22
|
+
# This block is run in a child process
|
23
|
+
|
24
|
+
# The HighLine instance used by the application *must* be the one supplied by
|
25
|
+
# the client.
|
26
|
+
expect(Mkmatter::Questions::Post).to receive(:instance_variable_get) do |args|
|
27
|
+
expect(args[0]).to eq(:@hl)
|
28
|
+
end.and_return(driver.high_line)
|
29
|
+
# Do any other setup (e.g. stubbing) here
|
30
|
+
# Start the application under test
|
31
|
+
# If this block ever completes, the child process will be killed by
|
32
|
+
# HighLine::Test
|
33
|
+
end
|
34
|
+
|
35
|
+
@front_matter_regex = <<~HEREDOC
|
36
|
+
---\n
|
37
|
+
layout\:\s(?<layout_>post|page)\n
|
38
|
+
title\:\s(?<title_>[[:print:]]{1,})\n
|
39
|
+
categories\:\n
|
40
|
+
(?<categories>(?:(?>-\s[[:print:]]{1,})\n){1,})
|
41
|
+
tags\:\n
|
42
|
+
(?<tags>(?:(?>-\s[[:print:]]{1,})\n){1,})
|
43
|
+
date\:\s\'(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})\s
|
44
|
+
(?<hour>\d{2})\:(?<minute>\d{2})\:(?<second>\d{2})\s
|
45
|
+
[+-]{1}(?<timezone_offset_hour>\d{2})(?<timezone_offset_minute>\d{2})\'\n
|
46
|
+
---
|
47
|
+
HEREDOC
|
48
|
+
end
|
49
|
+
after :example do
|
50
|
+
@client.cleanup
|
51
|
+
end
|
52
|
+
it 'outputs no file, and is not a draft' do
|
53
|
+
@qs = @questions::Post.new
|
54
|
+
expect { @qs.ask }.to output('Title: ').to_stdout_from_any_process
|
55
|
+
expect { @client.type('some title') }.to output("Would you like it 'titleized' (Title instead of title)? ").to_stdout_from_any_process
|
56
|
+
expect { @client.type 'y' }.to output("Tags? (write one on each line, then type '.') ").to_stdout_from_any_process
|
57
|
+
expect { @client.type "some tags\nwould\ngo\nhere" }.to output("Categories? (write one on each line, then type '. ') ").to_stdout_from_any_process
|
58
|
+
expect { @client.type "Some Category\nHere\nUpdates" }.to output("Time Zone? (select by number):\n1. Eastern Time (US & Canada)\n2. Central Time (US & Canada)\n3. neither\n? ").to_stdout_from_any_process
|
59
|
+
expect { @client.type '1' }.to output("Choose whether you want HTML or\nMarkdown:\n1. html\n2. md\n? ").to_stdout_from_any_process
|
60
|
+
regex = Regexp.new(Regexp.quote(@front_matter_regex), Regexp::EXTENDED)
|
61
|
+
expect { @client.type '2' }.to output(regex).to_stdout_from_any_process
|
62
|
+
|
63
|
+
end
|
64
|
+
# def test_that_page_questions_no_file_and_no_draft_works
|
65
|
+
# #"some title\ny\nmd\nsome,tags,here,multi word too\nsome categories here\n1\nmd\n"
|
66
|
+
# #@input.rewind
|
67
|
+
# #HighLine::Simulate.with "some title\ny\nmd\nsome,tags,here,multi word too\nsome categories here\n1\nmd\n" do
|
68
|
+
# # @questions::Page.new(@terminal).ask
|
69
|
+
# #end
|
70
|
+
# #@input = IO.new
|
71
|
+
# end
|
72
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#require 'minitest/reporters'
|
2
|
+
require 'rspec/core'
|
3
|
+
require 'rspec/expectations'
|
4
|
+
require 'rspec/mocks'
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.expect_with :rspec do |expectations|
|
7
|
+
expectations.syntax = [:expect]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
#require_relative '../lib/minitest/xs_and_os_plugin'
|
11
|
+
# module Minitest
|
12
|
+
# # copied from minitest
|
13
|
+
# def self.init_plugins(options)
|
14
|
+
# extensions.each do |name|
|
15
|
+
# msg = "plugin_#{name}_init"
|
16
|
+
# send msg, options if respond_to?(msg)
|
17
|
+
# end
|
18
|
+
# fix_reporters
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# def self.fix_reporters
|
22
|
+
# dr = reporter.reporters.find { |r| r.is_a? Minitest::Reporters::DelegateReporter }
|
23
|
+
#
|
24
|
+
# # getting rid of default reporters
|
25
|
+
# drr = dr.instance_variable_get(:@reporters)
|
26
|
+
# drr.delete_if { |r| r.is_a?(Minitest::SummaryReporter) || r.is_a?(Minitest::ProgressReporter) }
|
27
|
+
#
|
28
|
+
# # getting rid of rails reporters
|
29
|
+
# if defined?(Rails)
|
30
|
+
# reporter.reporters.delete_if { |r| r.is_a?(Minitest::SuppressedSummaryReporter) || r.is_a?(::Rails::TestUnitReporter) }
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
# Minitest::Reporters.use!
|
36
|
+
# Minitest::Reporters.use! Minitest::Reporters::TravisReporter.new
|
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.1.
|
4
|
+
version: 3.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Spencer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -192,6 +192,48 @@ dependencies:
|
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '5'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: rspec-core
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '3.13'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '3.13'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: rspec-expectations
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '3.13'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '3.13'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: rspec-mocks
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - "~>"
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '3.13'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - "~>"
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '3.13'
|
195
237
|
- !ruby/object:Gem::Dependency
|
196
238
|
name: minitest-reporters
|
197
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,6 +248,34 @@ dependencies:
|
|
206
248
|
- - "~>"
|
207
249
|
- !ruby/object:Gem::Version
|
208
250
|
version: 1.6.1
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: aruba
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - "~>"
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: 2.2.0
|
258
|
+
type: :development
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - "~>"
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: 2.2.0
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: highline-test
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - "~>"
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: 0.0.1
|
272
|
+
type: :development
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - "~>"
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: 0.0.1
|
209
279
|
description: A gem that helps a user maintain a jekyll site source directory.
|
210
280
|
email: me@iotaspencer.me
|
211
281
|
executables:
|
@@ -217,6 +287,8 @@ files:
|
|
217
287
|
- ".github/issue_template.md"
|
218
288
|
- ".gitignore"
|
219
289
|
- ".gitlab-ci.yml"
|
290
|
+
- ".rspec"
|
291
|
+
- ".ruby-version"
|
220
292
|
- ".travis.yml"
|
221
293
|
- Gemfile
|
222
294
|
- LICENSE
|
@@ -226,6 +298,7 @@ files:
|
|
226
298
|
- bin/console
|
227
299
|
- bin/mkmatter
|
228
300
|
- bin/setup
|
301
|
+
- features/support/env.rb
|
229
302
|
- lib/minitest/xs_and_os_plugin.rb
|
230
303
|
- lib/mkmatter.rb
|
231
304
|
- lib/mkmatter/answers.rb
|
@@ -242,6 +315,12 @@ files:
|
|
242
315
|
- lib/mkmatter/questions.rb
|
243
316
|
- lib/mkmatter/version.rb
|
244
317
|
- mkmatter.gemspec
|
318
|
+
- sig/mkmatter/questions/page.rbs
|
319
|
+
- sig/mkmatter/questions/post.rbs
|
320
|
+
- spec/class_option_spec.rb
|
321
|
+
- spec/descriptions_spec.rb
|
322
|
+
- spec/questions_spec.rb
|
323
|
+
- spec/spec_helper.rb
|
245
324
|
homepage: https://iotaspencer.me/projects/mkmatter
|
246
325
|
licenses:
|
247
326
|
- MIT
|
@@ -270,8 +349,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
349
|
- !ruby/object:Gem::Version
|
271
350
|
version: '0'
|
272
351
|
requirements: []
|
273
|
-
rubygems_version: 3.3.
|
274
|
-
signing_key:
|
352
|
+
rubygems_version: 3.3.27
|
353
|
+
signing_key:
|
275
354
|
specification_version: 4
|
276
355
|
summary: Script facilitating easy content creation and generation for Jekyll Sites
|
277
356
|
test_files: []
|