howzit 2.0.2 → 2.0.3
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/CHANGELOG.md +13 -0
- data/lib/howzit/buildnote.rb +16 -16
- data/lib/howzit/prompt.rb +11 -9
- data/lib/howzit/stringutils.rb +4 -0
- data/lib/howzit/topic.rb +46 -22
- data/lib/howzit/version.rb +2 -1
- data/spec/buildnote_spec.rb +69 -0
- data/spec/buildnotes.md.bak +22 -0
- data/spec/ruby_gem_spec.rb +2 -99
- data/spec/spec_helper.rb +45 -0
- data/spec/task_spec.rb +13 -0
- data/spec/topic_spec.rb +61 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: febb19742d97801e3dff8026e42e67997ee58e9de5c4e87cd5b9c6fc7ab20fef
|
4
|
+
data.tar.gz: 6de0abe65cd3860bf38ac516fbfdf566d2609f88d9c1d74cd51dba57ade056ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ad5108294d5fca6e1e12e316311c4082ba82694a876d0c0b6ef41eb082041ca300144cdf4782c235245a1c30db031438dcfb4be1d2569af63f4fbbb3e81be7b
|
7
|
+
data.tar.gz: 66f51a8da16d89972ea0dbb7ecd209153d3e680d956e8a80d98af9288f014cf1367f89d3a1b42adf4471aace0da8ae2d5d75b6f617c602b5cd272c1361e8c3e9
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
### 2.0.3
|
2
|
+
|
3
|
+
2022-08-04 05:31
|
4
|
+
|
5
|
+
#### IMPROVED
|
6
|
+
|
7
|
+
- General code cleanup
|
8
|
+
- Attempt at os agnostic @copy command, hopefully works on Windows and Linux systems
|
9
|
+
|
10
|
+
#### FIXED
|
11
|
+
|
12
|
+
- Not displaying action if title is missing
|
13
|
+
|
1
14
|
### 2.0.2
|
2
15
|
|
3
16
|
2022-08-03 18:26
|
data/lib/howzit/buildnote.rb
CHANGED
@@ -41,9 +41,9 @@ module Howzit
|
|
41
41
|
# Output a list of topic titles
|
42
42
|
def list
|
43
43
|
output = []
|
44
|
-
output.push(
|
44
|
+
output.push("{bg}Topics:{x}\n".c)
|
45
45
|
@topics.each do |topic|
|
46
|
-
output.push(
|
46
|
+
output.push("- {bw}#{topic.title}{x}".c)
|
47
47
|
end
|
48
48
|
output.join("\n")
|
49
49
|
end
|
@@ -66,7 +66,7 @@ module Howzit
|
|
66
66
|
|
67
67
|
def list_runnable
|
68
68
|
output = []
|
69
|
-
output.push(
|
69
|
+
output.push(%({bg}"Runnable" Topics:{x}\n).c)
|
70
70
|
@topics.each do |topic|
|
71
71
|
s_out = []
|
72
72
|
|
@@ -75,7 +75,7 @@ module Howzit
|
|
75
75
|
end
|
76
76
|
|
77
77
|
unless s_out.empty?
|
78
|
-
output.push(
|
78
|
+
output.push("- {bw}#{topic.title}{x}".c)
|
79
79
|
output.push(s_out.join("\n"))
|
80
80
|
end
|
81
81
|
end
|
@@ -95,9 +95,9 @@ module Howzit
|
|
95
95
|
default = !$stdout.isatty || Howzit.options[:default]
|
96
96
|
# First make sure there isn't already a buildnotes file
|
97
97
|
if note_file
|
98
|
-
fname =
|
98
|
+
fname = "{by}#{note_file}{bw}".c
|
99
99
|
unless default
|
100
|
-
res = Prompt.yn("#{fname} exists and appears to be a build note, continue anyway?", false)
|
100
|
+
res = Prompt.yn("#{fname} exists and appears to be a build note, continue anyway?", default: false)
|
101
101
|
unless res
|
102
102
|
puts 'Canceled'
|
103
103
|
Process.exit 0
|
@@ -109,20 +109,20 @@ module Howzit
|
|
109
109
|
if default
|
110
110
|
input = title
|
111
111
|
else
|
112
|
-
printf
|
112
|
+
printf "{bw}Project name {xg}[#{title}]{bw}: {x}".c
|
113
113
|
input = $stdin.gets.chomp
|
114
114
|
title = input unless input.empty?
|
115
115
|
end
|
116
116
|
summary = ''
|
117
117
|
unless default
|
118
|
-
printf
|
118
|
+
printf '{bw}Project summary: {x}'.c
|
119
119
|
input = $stdin.gets.chomp
|
120
120
|
summary = input unless input.empty?
|
121
121
|
end
|
122
122
|
|
123
123
|
fname = 'buildnotes.md'
|
124
124
|
unless default
|
125
|
-
printf
|
125
|
+
printf "{bw}Build notes filename (must begin with 'howzit' or 'build')\n{xg}[#{fname}]{bw}: {x}".c
|
126
126
|
input = $stdin.gets.chomp
|
127
127
|
fname = input unless input.empty?
|
128
128
|
end
|
@@ -153,8 +153,8 @@ module Howzit
|
|
153
153
|
EOBUILDNOTES
|
154
154
|
|
155
155
|
if File.exist?(fname) && !default
|
156
|
-
file =
|
157
|
-
res = Prompt.yn("Are you absolutely sure you want to overwrite #{file}", false)
|
156
|
+
file = "{by}#{fname}".c
|
157
|
+
res = Prompt.yn("Are you absolutely sure you want to overwrite #{file}", default: false)
|
158
158
|
|
159
159
|
unless res
|
160
160
|
puts 'Canceled'
|
@@ -164,7 +164,7 @@ module Howzit
|
|
164
164
|
|
165
165
|
File.open(fname, 'w') do |f|
|
166
166
|
f.puts note
|
167
|
-
puts
|
167
|
+
puts "{by}Build notes for #{title} written to #{fname}".c
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
@@ -259,8 +259,8 @@ module Howzit
|
|
259
259
|
required = t_meta['required'].strip.split(/\s*,\s*/)
|
260
260
|
required.each do |req|
|
261
261
|
unless @metadata.keys.include?(req.downcase)
|
262
|
-
warn
|
263
|
-
warn
|
262
|
+
warn %({xr}ERROR: Missing required metadata key from template '{bw}#{File.basename(template, '.md')}{xr}'{x}).c
|
263
|
+
warn %({xr}Please define {by}#{req.downcase}{xr} in build notes{x}).c
|
264
264
|
Process.exit 1
|
265
265
|
end
|
266
266
|
end
|
@@ -410,7 +410,7 @@ module Howzit
|
|
410
410
|
raise "Invalid editor (#{editor})" unless Util.valid_command?(editor)
|
411
411
|
|
412
412
|
if note_file.nil?
|
413
|
-
res = Prompt.yn('No build notes file found, create one?', true)
|
413
|
+
res = Prompt.yn('No build notes file found, create one?', default: true)
|
414
414
|
|
415
415
|
create_note if res
|
416
416
|
edit_note
|
@@ -500,7 +500,7 @@ module Howzit
|
|
500
500
|
matches = find_topic(s)
|
501
501
|
|
502
502
|
if matches.empty?
|
503
|
-
output.push(
|
503
|
+
output.push(%({bR}ERROR:{xr} No topic match found for {bw}#{s}{x}\n).c)
|
504
504
|
else
|
505
505
|
case Howzit.options[:multiple_matches]
|
506
506
|
when :first
|
data/lib/howzit/prompt.rb
CHANGED
@@ -4,16 +4,18 @@ module Howzit
|
|
4
4
|
# Command line prompt utils
|
5
5
|
module Prompt
|
6
6
|
class << self
|
7
|
-
def yn(prompt, default
|
8
|
-
return default
|
7
|
+
def yn(prompt, default: true)
|
8
|
+
return default unless $stdout.isatty
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
return default if Howzit.options[:default]
|
11
|
+
|
12
|
+
system 'stty cbreak'
|
13
|
+
yn = color_single_options(default ? %w[Y n] : %w[y N])
|
14
|
+
$stdout.syswrite "\e[1;37m#{prompt} #{yn}\e[1;37m? \e[0m"
|
15
|
+
res = $stdin.sysread 1
|
16
|
+
res.chomp!
|
17
|
+
puts
|
18
|
+
system 'stty cooked'
|
17
19
|
res.empty? ? default : res =~ /y/i
|
18
20
|
end
|
19
21
|
|
data/lib/howzit/stringutils.rb
CHANGED
data/lib/howzit/topic.rb
CHANGED
@@ -28,14 +28,14 @@ module Howzit
|
|
28
28
|
if @tasks.count.positive?
|
29
29
|
unless @prereqs.empty?
|
30
30
|
puts @prereqs.join("\n\n")
|
31
|
-
res = Prompt.yn('This task has prerequisites, have they been met?', true)
|
31
|
+
res = Prompt.yn('This task has prerequisites, have they been met?', default: true)
|
32
32
|
Process.exit 1 unless res
|
33
33
|
|
34
34
|
end
|
35
35
|
|
36
36
|
@tasks.each do |task|
|
37
37
|
if task.type == :block
|
38
|
-
warn
|
38
|
+
warn "{bg}Running block {bw}#{title}{x}".c if Howzit.options[:log_level] < 2
|
39
39
|
block = task.action
|
40
40
|
script = Tempfile.new('howzit_script')
|
41
41
|
begin
|
@@ -49,22 +49,23 @@ module Howzit
|
|
49
49
|
script.unlink
|
50
50
|
end
|
51
51
|
else
|
52
|
+
title = Howzit.options[:show_all_code] ? task.action : task.title
|
52
53
|
case task.type
|
53
54
|
when :include
|
54
55
|
matches = Howzit.buildnote.find_topic(task.action)
|
55
56
|
raise "Topic not found: #{task.action}" if matches.empty?
|
56
57
|
|
57
|
-
|
58
|
+
$stderr.puts "{by}Running tasks from {bw}#{matches[0].title}{x}".c if Howzit.options[:log_level] < 2
|
58
59
|
output.push(matches[0].run(nested: true))
|
59
|
-
|
60
|
+
$stderr.puts "{by}End include: #{matches[0].tasks.count} tasks".c if Howzit.options[:log_level] < 2
|
60
61
|
tasks += matches[0].tasks.count
|
61
62
|
when :run
|
62
|
-
|
63
|
+
$stderr.puts "{bg}Running {bw}#{title}{x}".c if Howzit.options[:log_level] < 2
|
63
64
|
system(task.action)
|
64
65
|
tasks += 1
|
65
66
|
when :copy
|
66
|
-
|
67
|
-
|
67
|
+
$stderr.puts "{bg}Copied {bw}#{title}{bg} to clipboard{x}".c if Howzit.options[:log_level] < 2
|
68
|
+
os_copy(task.action)
|
68
69
|
tasks += 1
|
69
70
|
when :open
|
70
71
|
os_open(task.action)
|
@@ -73,28 +74,52 @@ module Howzit
|
|
73
74
|
end
|
74
75
|
end
|
75
76
|
else
|
76
|
-
warn
|
77
|
+
warn "{r}--run: No {br}@directive{xr} found in {bw}#{key}{x}".c
|
77
78
|
end
|
78
|
-
output.push(
|
79
|
+
output.push("{bm}Ran #{tasks} #{tasks == 1 ? 'task' : 'tasks'}{x}".c) if Howzit.options[:log_level] < 2 && !nested
|
79
80
|
|
80
81
|
puts postreqs.join("\n\n") unless postreqs.empty?
|
81
82
|
|
82
83
|
output
|
83
84
|
end
|
84
85
|
|
86
|
+
def os_copy(string)
|
87
|
+
os = RbConfig::CONFIG['target_os']
|
88
|
+
out = "{bg}Copying {bw}#{string}".c
|
89
|
+
case os
|
90
|
+
when /darwin.*/i
|
91
|
+
warn "#{out} (macOS){x}".c if Howzit.options[:log_level] < 2
|
92
|
+
`echo #{Shellwords.escape(string)}'\\c'|pbcopy`
|
93
|
+
when /mingw|mswin/i
|
94
|
+
warn "#{out} (Windows){x}".c if Howzit.options[:log_level] < 2
|
95
|
+
`echo #{Shellwords.escape(string)} | clip`
|
96
|
+
else
|
97
|
+
if 'xsel'.available?
|
98
|
+
warn "#{out} (Linux, xsel){x}".c if Howzit.options[:log_level] < 2
|
99
|
+
`echo #{Shellwords.escape(string)}'\\c'|xsel -i`
|
100
|
+
elsif 'xclip'.available?
|
101
|
+
warn "#{out} (Linux, xclip){x}".c if Howzit.options[:log_level] < 2
|
102
|
+
`echo #{Shellwords.escape(string)}'\\c'|xclip -i`
|
103
|
+
else
|
104
|
+
warn out if Howzit.options[:log_level] < 2
|
105
|
+
warn 'Unable to determine executable for clipboard.'
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
85
110
|
def os_open(command)
|
86
111
|
os = RbConfig::CONFIG['target_os']
|
87
|
-
out =
|
112
|
+
out = "{bg}Opening {bw}#{command}".c
|
88
113
|
case os
|
89
114
|
when /darwin.*/i
|
90
|
-
warn
|
115
|
+
warn "#{out} (macOS){x}".c if Howzit.options[:log_level] < 2
|
91
116
|
`open #{Shellwords.escape(command)}`
|
92
117
|
when /mingw|mswin/i
|
93
|
-
warn
|
118
|
+
warn "#{out} (Windows){x}".c if Howzit.options[:log_level] < 2
|
94
119
|
`start #{Shellwords.escape(command)}`
|
95
120
|
else
|
96
121
|
if 'xdg-open'.available?
|
97
|
-
warn
|
122
|
+
warn "#{out} (Linux){x}".c if Howzit.options[:log_level] < 2
|
98
123
|
`xdg-open #{Shellwords.escape(command)}`
|
99
124
|
else
|
100
125
|
warn out if Howzit.options[:log_level] < 2
|
@@ -120,7 +145,6 @@ module Howzit
|
|
120
145
|
when /@(before|after|prereq|end)/
|
121
146
|
next
|
122
147
|
when /@include\((.*?)\)/
|
123
|
-
|
124
148
|
m = Regexp.last_match
|
125
149
|
matches = Howzit.buildnote.find_topic(m[1])
|
126
150
|
unless matches.empty?
|
@@ -157,7 +181,7 @@ module Howzit
|
|
157
181
|
m = Regexp.last_match
|
158
182
|
cmd = m[1]
|
159
183
|
obj = m[2]
|
160
|
-
title = m[3].
|
184
|
+
title = m[3].empty? ? obj : m[3]
|
161
185
|
icon = case cmd
|
162
186
|
when 'run'
|
163
187
|
"\u{25B6}"
|
@@ -167,21 +191,21 @@ module Howzit
|
|
167
191
|
"\u{279A}"
|
168
192
|
end
|
169
193
|
|
170
|
-
output.push(
|
194
|
+
output.push("{bmK}#{icon} {bwK}#{title.gsub(/\\n/, '\n')}{x}".c)
|
171
195
|
when /(`{3,})run *(.*?)$/i
|
172
196
|
m = Regexp.last_match
|
173
197
|
desc = m[2].length.positive? ? "Block: #{m[2]}" : 'Code Block'
|
174
|
-
output.push(
|
198
|
+
output.push("{bmK}\u{25B6} {bwK}#{desc}{x}\n```".c)
|
175
199
|
when /@@@run *(.*?)$/i
|
176
200
|
m = Regexp.last_match
|
177
201
|
desc = m[1].length.positive? ? "Block: #{m[1]}" : 'Code Block'
|
178
|
-
output.push(
|
202
|
+
output.push("{bmK}\u{25B6} {bwK}#{desc}{x}".c)
|
179
203
|
else
|
180
|
-
l.wrap!(Howzit.options[:wrap]) if
|
204
|
+
l.wrap!(Howzit.options[:wrap]) if Howzit.options[:wrap].positive?
|
181
205
|
output.push(l)
|
182
206
|
end
|
183
207
|
end
|
184
|
-
output.push('')
|
208
|
+
output.push('')
|
185
209
|
end
|
186
210
|
|
187
211
|
private
|
@@ -219,10 +243,10 @@ module Howzit
|
|
219
243
|
runnable << Howzit::Task.new(:include, title, obj)
|
220
244
|
when /run/i
|
221
245
|
title = c[3] || obj
|
222
|
-
# warn
|
246
|
+
# warn "{bg}Running {bw}#{obj}{x}".c if Howzit.options[:log_level] < 2
|
223
247
|
runnable << Howzit::Task.new(:run, title, obj)
|
224
248
|
when /copy/i
|
225
|
-
# warn
|
249
|
+
# warn "{bg}Copied {bw}#{obj}{bg} to clipboard{x}".c if Howzit.options[:log_level] < 2
|
226
250
|
runnable << Howzit::Task.new(:copy, title, Shellwords.escape(obj))
|
227
251
|
when /open|url/i
|
228
252
|
runnable << Howzit::Task.new(:open, title, obj)
|
data/lib/howzit/version.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Howzit::BuildNote do
|
6
|
+
subject(:how) { @hz }
|
7
|
+
|
8
|
+
describe ".note_file" do
|
9
|
+
it "locates a build note file" do
|
10
|
+
expect(how.note_file).not_to be_empty
|
11
|
+
expect(how.note_file).to match /builda.md$/
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".grep" do
|
16
|
+
it "finds topic containing 'bermuda'" do
|
17
|
+
expect(how.grep('bermuda').map { |topic| topic.title }).to include('Topic Tropic')
|
18
|
+
end
|
19
|
+
it "does not return non-matching topic" do
|
20
|
+
expect(how.grep('bermuda').map { |topic| topic.title }).not_to include('Topic Balogna')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".find_topic" do
|
25
|
+
it "finds the Topic Tropic topic" do
|
26
|
+
matches = how.find_topic('tropic')
|
27
|
+
expect(matches.count).to eq 1
|
28
|
+
expect(matches[0].title).to eq 'Topic Tropic'
|
29
|
+
end
|
30
|
+
it "fuzzy matches" do
|
31
|
+
Howzit.options[:matching] = 'fuzzy'
|
32
|
+
matches = how.find_topic('trpc')
|
33
|
+
expect(matches.count).to eq 1
|
34
|
+
expect(matches[0].title).to eq 'Topic Tropic'
|
35
|
+
end
|
36
|
+
it "succeeds with partial match" do
|
37
|
+
Howzit.options[:matching] = 'partial'
|
38
|
+
matches = how.find_topic('trop')
|
39
|
+
expect(matches.count).to eq 1
|
40
|
+
expect(matches[0].title).to eq 'Topic Tropic'
|
41
|
+
end
|
42
|
+
it "succeeds with beginswith match" do
|
43
|
+
Howzit.options[:matching] = 'beginswith'
|
44
|
+
matches = how.find_topic('topic')
|
45
|
+
expect(matches.count).to eq 3
|
46
|
+
expect(matches[0].title).to eq 'Topic Balogna'
|
47
|
+
end
|
48
|
+
it "succeeds with exact match" do
|
49
|
+
Howzit.options[:matching] = 'exact'
|
50
|
+
matches = how.find_topic('topic tropic')
|
51
|
+
expect(matches.count).to eq 1
|
52
|
+
expect(matches[0].title).to eq 'Topic Tropic'
|
53
|
+
end
|
54
|
+
it "fails with incomplete exact match" do
|
55
|
+
Howzit.options[:matching] = 'exact'
|
56
|
+
matches = how.find_topic('topic trop')
|
57
|
+
expect(matches.count).to eq 0
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe ".topics" do
|
62
|
+
it "contains 4 topics" do
|
63
|
+
expect(how.list_topics.count).to eq 3
|
64
|
+
end
|
65
|
+
it "outputs a newline-separated string for completion" do
|
66
|
+
expect(how.list_completions.scan(/\n/).count).to eq 2
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# spec
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
## File Structure
|
6
|
+
|
7
|
+
Where are the main editable files? Is there a dist/build folder that should be ignored?
|
8
|
+
|
9
|
+
## Build
|
10
|
+
|
11
|
+
What build system/parameters does this use?
|
12
|
+
|
13
|
+
@run(./build command)
|
14
|
+
|
15
|
+
## Deploy
|
16
|
+
|
17
|
+
What are the procedures/commands to deploy this project?
|
18
|
+
|
19
|
+
## Other
|
20
|
+
|
21
|
+
Version control notes, additional gulp/rake/make/etc tasks...
|
22
|
+
|
data/spec/ruby_gem_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Howzit::BuildNote do
|
@@ -9,102 +11,3 @@ describe Howzit::BuildNote do
|
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
12
|
-
|
13
|
-
describe Howzit::Task do
|
14
|
-
subject(:task) { Howzit::Task.new(:run, 'List Directory', 'ls') }
|
15
|
-
|
16
|
-
describe ".new" do
|
17
|
-
it "makes a new task instance" do
|
18
|
-
expect(task).to be_a Howzit::Task
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe Howzit::Topic do
|
24
|
-
title = 'Test Title'
|
25
|
-
content = 'Test Content'
|
26
|
-
subject(:topic) { Howzit::Topic.new(title, content) }
|
27
|
-
|
28
|
-
describe ".new" do
|
29
|
-
it "makes a new topic instance" do
|
30
|
-
expect(topic).to be_a Howzit::Topic
|
31
|
-
end
|
32
|
-
it "has the correct title" do
|
33
|
-
expect(topic.title).to eq title
|
34
|
-
end
|
35
|
-
it "has the correct content" do
|
36
|
-
expect(topic.content).to eq content
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe Howzit::BuildNote do
|
42
|
-
Dir.chdir('spec')
|
43
|
-
Howzit.options[:include_upstream] = false
|
44
|
-
Howzit.options[:default] = true
|
45
|
-
hz = Howzit.buildnote
|
46
|
-
hz.create_note
|
47
|
-
|
48
|
-
subject(:how) { hz }
|
49
|
-
|
50
|
-
describe ".note_file" do
|
51
|
-
it "locates a build note file" do
|
52
|
-
expect(how.note_file).not_to be_empty
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe ".grep" do
|
57
|
-
it "finds topic containing 'editable'" do
|
58
|
-
expect(how.grep('editable').map { |topic| topic.title }).to include('File Structure')
|
59
|
-
end
|
60
|
-
it "does not return non-matching topic" do
|
61
|
-
expect(how.grep('editable').map { |topic| topic.title }).not_to include('Build')
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe ".find_topic" do
|
66
|
-
it "finds the File Structure topic" do
|
67
|
-
matches = how.find_topic('file struct')
|
68
|
-
expect(matches.count).to eq 1
|
69
|
-
expect(matches[0].title).to eq 'File Structure'
|
70
|
-
end
|
71
|
-
it "fuzzy matches" do
|
72
|
-
Howzit.options[:matching] = 'fuzzy'
|
73
|
-
matches = how.find_topic('flestct')
|
74
|
-
expect(matches.count).to eq 1
|
75
|
-
expect(matches[0].title).to eq 'File Structure'
|
76
|
-
end
|
77
|
-
it "succeeds with partial match" do
|
78
|
-
Howzit.options[:matching] = 'partial'
|
79
|
-
matches = how.find_topic('structure')
|
80
|
-
expect(matches.count).to eq 1
|
81
|
-
expect(matches[0].title).to eq 'File Structure'
|
82
|
-
end
|
83
|
-
it "succeeds with beginswith match" do
|
84
|
-
Howzit.options[:matching] = 'beginswith'
|
85
|
-
matches = how.find_topic('file')
|
86
|
-
expect(matches.count).to eq 1
|
87
|
-
expect(matches[0].title).to eq 'File Structure'
|
88
|
-
end
|
89
|
-
it "succeeds with exact match" do
|
90
|
-
Howzit.options[:matching] = 'exact'
|
91
|
-
matches = how.find_topic('file structure')
|
92
|
-
expect(matches.count).to eq 1
|
93
|
-
expect(matches[0].title).to eq 'File Structure'
|
94
|
-
end
|
95
|
-
it "fails with incomplete exact match" do
|
96
|
-
Howzit.options[:matching] = 'exact'
|
97
|
-
matches = how.find_topic('file struct')
|
98
|
-
expect(matches.count).to eq 0
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe ".topics" do
|
103
|
-
it "contains 4 topics" do
|
104
|
-
expect(how.list_topics.count).to eq 4
|
105
|
-
end
|
106
|
-
it "outputs a newline-separated string for completion" do
|
107
|
-
expect(how.list_completions.scan(/\n/).count).to eq 3
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
data/spec/spec_helper.rb
CHANGED
@@ -13,7 +13,52 @@ require 'howzit'
|
|
13
13
|
|
14
14
|
RSpec.configure do |c|
|
15
15
|
c.expect_with(:rspec) { |e| e.syntax = :expect }
|
16
|
+
|
16
17
|
c.before(:each) do
|
17
18
|
allow(FileUtils).to receive(:remove_entry_secure).with(anything)
|
19
|
+
save_buildnote
|
20
|
+
Howzit.options[:include_upstream] = false
|
21
|
+
Howzit.options[:default] = true
|
22
|
+
@hz = Howzit.buildnote
|
23
|
+
end
|
24
|
+
|
25
|
+
c.after(:each) do
|
26
|
+
delete_buildnote
|
18
27
|
end
|
19
28
|
end
|
29
|
+
|
30
|
+
def save_buildnote
|
31
|
+
note = <<~EONOTE
|
32
|
+
# Howzit Test
|
33
|
+
|
34
|
+
## Topic Balogna
|
35
|
+
|
36
|
+
@before
|
37
|
+
This should be a prerequisite.
|
38
|
+
@end
|
39
|
+
|
40
|
+
@run(ls -1 &> /dev/null) Null Output
|
41
|
+
@include(Topic Tropic)
|
42
|
+
|
43
|
+
@after
|
44
|
+
This should be a postrequisite.
|
45
|
+
@end
|
46
|
+
|
47
|
+
## Topic Banana
|
48
|
+
|
49
|
+
This is just another topic.
|
50
|
+
|
51
|
+
- It has a list in it
|
52
|
+
- That's pretty fun, right?
|
53
|
+
|
54
|
+
## Topic Tropic
|
55
|
+
|
56
|
+
Bermuda, Bahama, something something wanna.
|
57
|
+
@copy(Balogna) Just some balogna
|
58
|
+
EONOTE
|
59
|
+
File.open('builda.md', 'w') { |f| f.puts note }
|
60
|
+
end
|
61
|
+
|
62
|
+
def delete_buildnote
|
63
|
+
FileUtils.rm('builda.md')
|
64
|
+
end
|
data/spec/task_spec.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Howzit::Task do
|
6
|
+
subject(:task) { Howzit::Task.new(:run, 'List Directory', 'ls') }
|
7
|
+
|
8
|
+
describe ".new" do
|
9
|
+
it "makes a new task instance" do
|
10
|
+
expect(task).to be_a Howzit::Task
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/spec/topic_spec.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Howzit::Topic do
|
6
|
+
title = 'Test Title'
|
7
|
+
content = 'Test Content'
|
8
|
+
subject(:topic) { Howzit::Topic.new(title, content) }
|
9
|
+
|
10
|
+
describe ".new" do
|
11
|
+
it "makes a new topic instance" do
|
12
|
+
expect(topic).to be_a Howzit::Topic
|
13
|
+
end
|
14
|
+
it "has the correct title" do
|
15
|
+
expect(topic.title).to eq title
|
16
|
+
end
|
17
|
+
it "has the correct content" do
|
18
|
+
expect(topic.content).to eq content
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe Howzit::Topic do
|
24
|
+
subject(:topic) { @hz.find_topic('Topic Balogna')[0] }
|
25
|
+
|
26
|
+
describe ".title" do
|
27
|
+
it "has the correct title" do
|
28
|
+
expect(topic.title).to match /Topic Balogna/
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe ".tasks" do
|
33
|
+
it "has 2 tasks" do
|
34
|
+
expect(topic.tasks.count).to eq 2
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe ".prereqs" do
|
39
|
+
it "has prereq" do
|
40
|
+
expect(topic.prereqs.count).to eq 1
|
41
|
+
end
|
42
|
+
it "has postreq" do
|
43
|
+
expect(topic.postreqs.count).to eq 1
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe ".run" do
|
48
|
+
Howzit.options[:default] = true
|
49
|
+
it "shows prereq and postreq" do
|
50
|
+
expect { topic.run }.to output(/prerequisite/).to_stdout
|
51
|
+
expect { topic.run }.to output(/postrequisite/).to_stdout
|
52
|
+
end
|
53
|
+
it "Copies to clipboard" do
|
54
|
+
expect {
|
55
|
+
ENV['RUBYOPT'] = '-W1'
|
56
|
+
Howzit.options[:log_level] = 0
|
57
|
+
topic.run
|
58
|
+
}.to output(/Copied/).to_stderr
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: howzit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -280,8 +280,12 @@ files:
|
|
280
280
|
- lib/howzit/util.rb
|
281
281
|
- lib/howzit/version.rb
|
282
282
|
- spec/.rubocop.yml
|
283
|
+
- spec/buildnote_spec.rb
|
284
|
+
- spec/buildnotes.md.bak
|
283
285
|
- spec/ruby_gem_spec.rb
|
284
286
|
- spec/spec_helper.rb
|
287
|
+
- spec/task_spec.rb
|
288
|
+
- spec/topic_spec.rb
|
285
289
|
- update_readmes.rb
|
286
290
|
homepage: https://github.com/ttscoff/howzit
|
287
291
|
licenses:
|
@@ -309,5 +313,9 @@ summary: Provides a way to access Markdown project notes by topic with query cap
|
|
309
313
|
and the ability to execute the tasks it describes.
|
310
314
|
test_files:
|
311
315
|
- spec/.rubocop.yml
|
316
|
+
- spec/buildnote_spec.rb
|
317
|
+
- spec/buildnotes.md.bak
|
312
318
|
- spec/ruby_gem_spec.rb
|
313
319
|
- spec/spec_helper.rb
|
320
|
+
- spec/task_spec.rb
|
321
|
+
- spec/topic_spec.rb
|