howzit 2.0.21 → 2.0.24

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7fce97cf829010799ce06890d925d1f7eaff647299398650baf9eb898eb56eb
4
- data.tar.gz: 2fb9d03d33bd616c005b164fd4420d837fcb688882f7fe98d9779bfdf3abcb4c
3
+ metadata.gz: 4d5ddc7a4ec5cda133517d27dfef17d80299c17a68de2469e9dab66e81dffa33
4
+ data.tar.gz: 78fed9d51d054f4c39d3bb6b9daed3709e6a7f7644e5a6368bb924bb0b042665
5
5
  SHA512:
6
- metadata.gz: 3af874f2a2d88af1235d803cdf547e5820f32c817f8dbdc566db7a372ae732593cfeab069ccc759a071e5216e3e62a0a9c63a3c4097255f598efeafcecb70123
7
- data.tar.gz: 60a1fdf546e005d8b274269c3a7946017fecdc7adea5d028581bac6e044a03b0e0e8df313e82252c1c56b016984c803320e59bf873602aa1a4e3eabf278976f1
6
+ metadata.gz: 5427a3f6754462ae1311194407a3c6dfc71b084bb639afa29d961fad758ed554ce40ccdb21ec7b9175289343866da6d1ddb0f9db5fccb12f8224d206f9d53b98
7
+ data.tar.gz: 6222c4a34783c842fc342a27b2167588578afefa3f45a2fc16637b5d3f266d99d11bbefada5dd4a586902f914566a86efcef4262396133e573cf520923cd468a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,32 @@
1
+ ### 2.0.24
2
+
3
+ 2022-08-09 09:04
4
+
5
+ #### FIXED
6
+
7
+ - Avoid reading upstream files multiple times
8
+
9
+ ### 2.0.23
10
+
11
+ 2022-08-09 05:51
12
+
13
+ #### FIXED
14
+
15
+ - --grep function regression
16
+
17
+ ### 2.0.22
18
+
19
+ 2022-08-08 13:49
20
+
21
+ #### IMPROVED
22
+
23
+ - Paginate output of --templates
24
+
25
+ #### FIXED
26
+
27
+ - --templates attempting to create new build note
28
+ - Fix handling of paths when the same as note_file
29
+
1
30
  ### 2.0.21
2
31
 
3
32
  2022-08-08 13:16
data/bin/howzit CHANGED
@@ -64,25 +64,27 @@ OptionParser.new do |opts|
64
64
  end
65
65
 
66
66
  opts.on('--templates', 'List available templates') do
67
+ out = []
67
68
  Dir.chdir(Howzit.config.template_folder)
68
69
  Dir.glob('*.md').each do |file|
69
70
  template = File.basename(file, '.md')
70
- puts Howzit::Color.template("{Mk}template:{Yk}#{template}{x}")
71
- puts Howzit::Color.template('{bk}[{bl}tasks{bk}]──────────────────────────────────────┐{x}')
71
+ out.push(Howzit::Color.template("{Mk}template:{Yk}#{template}{x}"))
72
+ out.push(Howzit::Color.template('{bk}[{bl}tasks{bk}]──────────────────────────────────────┐{x}'))
72
73
  metadata = file.extract_metadata
73
- topics = Howzit.buildnote.read_file(file)
74
+ topics = Howzit::BuildNote.new(file: file).topics
74
75
  topics.each do |topic|
75
- puts Howzit::Color.template(" {bk}│{bw}-{x} {bcK}#{template}:#{topic.title.sub(/^.*?:/, '')}{x}")
76
+ out.push(Howzit::Color.template(" {bk}│{bw}-{x} {bcK}#{template}:#{topic.title.sub(/^.*?:/, '')}{x}"))
76
77
  end
77
78
  unless metadata.empty?
78
79
  meta = []
79
80
  meta << metadata['required'].split(/\s*,\s*/).map { |m| "*{bw}#{m}{xw}" } if metadata.key?('required')
80
81
  meta << metadata['optional'].split(/\s*,\s*/).map(&:to_s) if metadata.key?('optional')
81
- puts Howzit::Color.template('{bk}[{bl}meta{bk}]───────────────────────────────────────┤{x}')
82
- puts Howzit::Color.template(" {bk}│ {xw}#{meta.join(', ')}{x}")
82
+ out.push(Howzit::Color.template('{bk}[{bl}meta{bk}]───────────────────────────────────────┤{x}'))
83
+ out.push(Howzit::Color.template(" {bk}│ {xw}#{meta.join(', ')}{x}"))
83
84
  end
84
- puts Howzit::Color.template(' {bk}└───────────────────────────────────────────┘{x}')
85
+ out.push(Howzit::Color.template(' {bk}└───────────────────────────────────────────┘{x}'))
85
86
  end
87
+ Howzit::Util.page out.join("\n")
86
88
  Process.exit 0
87
89
  end
88
90
 
@@ -13,11 +13,13 @@ module Howzit
13
13
  ## @param file [String] The path to the build note file
14
14
  ##
15
15
  def initialize(file: nil)
16
+ file ||= note_file
17
+
16
18
  @topics = []
17
- create_note(prompt: true) if note_file.nil?
19
+ create_note(prompt: true) if file.nil?
18
20
 
19
- content = Util.read_file(note_file)
20
- raise "{br}No content found in build note (#{note_file}){x}".c if content.nil? || content.empty?
21
+ content = Util.read_file(file)
22
+ raise "{br}No content found in build note (#{file}){x}".c if content.nil? || content.empty?
21
23
 
22
24
  @metadata = content.split(/^#/)[0].strip.get_metadata
23
25
 
@@ -30,7 +32,7 @@ module Howzit
30
32
  ## @return description
31
33
  ##
32
34
  def inspect
33
- puts "#<Howzit::BuildNote @topics=[#{@topics.count}]>"
35
+ "#<Howzit::BuildNote @topics=[#{@topics.count}]>"
34
36
  end
35
37
 
36
38
  ##
@@ -203,14 +205,14 @@ module Howzit
203
205
  if File.exist?(file) && !default
204
206
  file = "{by}#{file}".c
205
207
  unless Prompt.yn("Are you sure you want to overwrite #{file}", default: false)
206
- puts 'Cancelled'
208
+ Howzit.console.info('Cancelled')
207
209
  Process.exit 0
208
210
  end
209
211
  end
210
212
 
211
213
  File.open(file, 'w') do |f|
212
214
  f.puts note
213
- puts "{by}Template {bw}#{title}{by} written to {bw}#{file}{x}".c
215
+ Howzit.console.info("{by}Template {bw}#{title}{by} written to {bw}#{file}{x}".c)
214
216
  end
215
217
 
216
218
  if File.exist?(file) && !default && Prompt.yn("{bg}Do you want to open {bw}#{file} {bg}for editing?{x}".c,
@@ -296,14 +298,14 @@ module Howzit
296
298
  if File.exist?(fname) && !default
297
299
  file = "{by}#{fname}".c
298
300
  unless Prompt.yn("Are you absolutely sure you want to overwrite #{file}", default: false)
299
- puts 'Canceled'
301
+ Howzit.console.info('Canceled')
300
302
  Process.exit 0
301
303
  end
302
304
  end
303
305
 
304
306
  File.open(fname, 'w') do |f|
305
307
  f.puts note
306
- puts "{by}Build notes for {bw}#{title}{by} written to {bw}#{fname}{x}".c
308
+ Howzit.console.info("{by}Build notes for {bw}#{title}{by} written to {bw}#{fname}{x}".c)
307
309
  end
308
310
 
309
311
  if File.exist?(fname) && !default && Prompt.yn("{bg}Do you want to open {bw}#{fname} {bg}for editing?{x}".c,
@@ -530,7 +532,6 @@ module Howzit
530
532
  ##
531
533
  def read_upstream
532
534
  buildnotes = glob_upstream
533
-
534
535
  topics_dict = []
535
536
  buildnotes.each do |path|
536
537
  topics_dict.concat(read_help_file(path))
@@ -596,7 +597,7 @@ module Howzit
596
597
  lines = sect.split(/\n/)
597
598
  title = lines.slice!(0).strip
598
599
  prefix = ''
599
- if path
600
+ if path && path != note_file
600
601
  if path =~ /#{Howzit.config.template_folder}/
601
602
  short_path = File.basename(path, '.md')
602
603
  else
@@ -625,12 +626,15 @@ module Howzit
625
626
  ##
626
627
  def read_help(path = nil)
627
628
  @topics = read_help_file(path)
628
- return unless path.nil? && Howzit.options[:include_upstream]
629
+ return unless Howzit.options[:include_upstream]
629
630
 
630
- upstream_topics = read_upstream
631
+ unless Howzit.has_read_upstream
632
+ upstream_topics = read_upstream
631
633
 
632
- upstream_topics.each do |topic|
633
- @topics.push(topic) unless find_topic(title.sub(/^.+:/, '')).count.positive?
634
+ upstream_topics.each do |topic|
635
+ @topics.push(topic) unless find_topic(topic.title.sub(/^.+:/, '')).count.positive?
636
+ end
637
+ Howzit.has_read_upstream = true
634
638
  end
635
639
 
636
640
  if note_file && @topics.empty?
@@ -689,7 +693,7 @@ module Howzit
689
693
  ## single topic
690
694
  ##
691
695
  def process_topic(topic, run, single: false)
692
- new_topic = topic.dup
696
+ new_topic = topic.is_a?(String) ? find_topic(topic)[0] : topic.dup
693
697
 
694
698
  # Handle variable replacement
695
699
  new_topic.content = new_topic.content.render_arguments
@@ -791,6 +795,7 @@ module Howzit
791
795
 
792
796
  if !topic_matches.empty?
793
797
  # If we found a match
798
+ topic_matches.map! { |topic| topic.is_a?(String) ? find_topic(topic)[0] : topic }
794
799
  topic_matches.each { |topic_match| output.push(process_topic(topic_match, Howzit.options[:run], single: true)) }
795
800
  else
796
801
  # If there's no argument or no match found, output all
@@ -3,5 +3,5 @@
3
3
  # Primary module for this gem.
4
4
  module Howzit
5
5
  # Current Howzit version.
6
- VERSION = '2.0.21'
6
+ VERSION = '2.0.24'
7
7
  end
data/lib/howzit.rb CHANGED
@@ -82,5 +82,13 @@ module Howzit
82
82
  def console
83
83
  @console ||= Howzit::ConsoleLogger.new(options[:log_level])
84
84
  end
85
+
86
+ def has_read_upstream
87
+ @has_read_upstream ||= false
88
+ end
89
+
90
+ def has_read_upstream=(has_read)
91
+ @has_read_upstream = has_read
92
+ end
85
93
  end
86
94
  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.21
4
+ version: 2.0.24
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-08 00:00:00.000000000 Z
11
+ date: 2022-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler