howzit 2.0.23 → 2.0.26

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aef13e763de59e83d14808c8778e5941c43b1b68669d09a9047dd53aaff60b38
4
- data.tar.gz: 0f4052f07e44bbe1b9679a021abd147bc0830941351221baa61cb09f6bfe25c6
3
+ metadata.gz: 0ef20bf69eaecc6f2d2df7ac9621dfbd227af13148ce2e0465d466b6206d8a59
4
+ data.tar.gz: 5923dbabfc6ec5d6bc1783ebb21b1a231fbfdaaa2ecd3887582b014a9642d8ab
5
5
  SHA512:
6
- metadata.gz: 69231c5b96a7c011710787d6f47ef628286a5b7237489c6220f1bc25a9aab2d76d70f438b9d1872e2531710f100b3d09f715acabb138c7a8cfc6967d6dde9f70
7
- data.tar.gz: 49c1e9266d4401d8ca863a9f107ab4e2c2722db719ab253b03db1b1c8983aeb83e3c715971d15be5ebe42d074f79b4ee521a9062a216422023c9884123555646
6
+ metadata.gz: b5e8c29926fa85e6b52e4d8463504a474f4d0e35765a8bf85294ab46f84e11c10d9f77f002d85ed2ea0db4657edd23a9faabe03f5c7ba0796aa38407d00e1180
7
+ data.tar.gz: 9340eff4ab693b1e82e11b201d63da704a4dc4d647bd5443b7b2bdfa8b5f1af98dc61cf4b42f76247c2ba4adbf2651ab82ea082136f68bdf0c5ebc0c904898d5
data/.travis.yml CHANGED
@@ -14,3 +14,4 @@ script: "bundle exec rspec spec --exclude-pattern 'cli*'"
14
14
  branches:
15
15
  only:
16
16
  - main
17
+ - develop
data/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ### 2.0.26
2
+
3
+ 2022-08-23 11:36
4
+
5
+ #### IMPROVED
6
+
7
+ - Add ctrl-a/d bindings to fzf menu for select/deselect all
8
+
9
+ ### 2.0.25
10
+
11
+ 2022-08-09 12:46
12
+
13
+ #### FIXED
14
+
15
+ - Template metadata inheritence
16
+
17
+ ### 2.0.24
18
+
19
+ 2022-08-09 09:04
20
+
21
+ #### FIXED
22
+
23
+ - Avoid reading upstream files multiple times
24
+
1
25
  ### 2.0.23
2
26
 
3
27
  2022-08-09 05:51
@@ -12,7 +12,7 @@ module Howzit
12
12
  ##
13
13
  ## @param file [String] The path to the build note file
14
14
  ##
15
- def initialize(file: nil)
15
+ def initialize(file: nil, meta: nil)
16
16
  file ||= note_file
17
17
 
18
18
  @topics = []
@@ -21,7 +21,9 @@ module Howzit
21
21
  content = Util.read_file(file)
22
22
  raise "{br}No content found in build note (#{file}){x}".c if content.nil? || content.empty?
23
23
 
24
- @metadata = content.split(/^#/)[0].strip.get_metadata
24
+ this_meta = content.split(/^#/)[0].strip.get_metadata
25
+
26
+ @metadata = meta.nil? ? this_meta : meta.merge(this_meta)
25
27
 
26
28
  read_help(file)
27
29
  end
@@ -32,7 +34,7 @@ module Howzit
32
34
  ## @return description
33
35
  ##
34
36
  def inspect
35
- puts "#<Howzit::BuildNote @topics=[#{@topics.count}]>"
37
+ "#<Howzit::BuildNote @topics=[#{@topics.count}]>"
36
38
  end
37
39
 
38
40
  ##
@@ -205,14 +207,14 @@ module Howzit
205
207
  if File.exist?(file) && !default
206
208
  file = "{by}#{file}".c
207
209
  unless Prompt.yn("Are you sure you want to overwrite #{file}", default: false)
208
- puts 'Cancelled'
210
+ Howzit.console.info('Cancelled')
209
211
  Process.exit 0
210
212
  end
211
213
  end
212
214
 
213
215
  File.open(file, 'w') do |f|
214
216
  f.puts note
215
- puts "{by}Template {bw}#{title}{by} written to {bw}#{file}{x}".c
217
+ Howzit.console.info("{by}Template {bw}#{title}{by} written to {bw}#{file}{x}".c)
216
218
  end
217
219
 
218
220
  if File.exist?(file) && !default && Prompt.yn("{bg}Do you want to open {bw}#{file} {bg}for editing?{x}".c,
@@ -298,14 +300,14 @@ module Howzit
298
300
  if File.exist?(fname) && !default
299
301
  file = "{by}#{fname}".c
300
302
  unless Prompt.yn("Are you absolutely sure you want to overwrite #{file}", default: false)
301
- puts 'Canceled'
303
+ Howzit.console.info('Canceled')
302
304
  Process.exit 0
303
305
  end
304
306
  end
305
307
 
306
308
  File.open(fname, 'w') do |f|
307
309
  f.puts note
308
- puts "{by}Build notes for {bw}#{title}{by} written to {bw}#{fname}{x}".c
310
+ Howzit.console.info("{by}Build notes for {bw}#{title}{by} written to {bw}#{fname}{x}".c)
309
311
  end
310
312
 
311
313
  if File.exist?(fname) && !default && Prompt.yn("{bg}Do you want to open {bw}#{fname} {bg}for editing?{x}".c,
@@ -451,11 +453,12 @@ module Howzit
451
453
  ## @return [Array] extracted topics
452
454
  ##
453
455
  def read_template(template, file, subtopics = nil)
454
- note = BuildNote.new(file: file)
456
+ note = BuildNote.new(file: file, meta: @metadata)
455
457
 
456
458
  template_topics = subtopics.nil? ? note.topics : extract_subtopics(note, subtopics)
457
459
  template_topics.map do |topic|
458
460
  topic.parent = template
461
+ topic.content = topic.content.render_template(@metadata)
459
462
  topic
460
463
  end
461
464
  end
@@ -532,7 +535,6 @@ module Howzit
532
535
  ##
533
536
  def read_upstream
534
537
  buildnotes = glob_upstream
535
-
536
538
  topics_dict = []
537
539
  buildnotes.each do |path|
538
540
  topics_dict.concat(read_help_file(path))
@@ -608,6 +610,7 @@ module Howzit
608
610
  end
609
611
  title = "#{short_path}:#{title}"
610
612
  end
613
+
611
614
  topic = Topic.new(title, prefix + lines.join("\n").strip.render_template(@metadata))
612
615
 
613
616
  topics.push(topic)
@@ -627,12 +630,15 @@ module Howzit
627
630
  ##
628
631
  def read_help(path = nil)
629
632
  @topics = read_help_file(path)
630
- return unless path.nil? && Howzit.options[:include_upstream]
633
+ return unless Howzit.options[:include_upstream]
631
634
 
632
- upstream_topics = read_upstream
635
+ unless Howzit.has_read_upstream
636
+ upstream_topics = read_upstream
633
637
 
634
- upstream_topics.each do |topic|
635
- @topics.push(topic) unless find_topic(title.sub(/^.+:/, '')).count.positive?
638
+ upstream_topics.each do |topic|
639
+ @topics.push(topic) unless find_topic(topic.title.sub(/^.+:/, '')).count.positive?
640
+ end
641
+ Howzit.has_read_upstream = true
636
642
  end
637
643
 
638
644
  if note_file && @topics.empty?
data/lib/howzit/prompt.rb CHANGED
@@ -98,8 +98,9 @@ module Howzit
98
98
  '-1',
99
99
  '-m',
100
100
  "--height=#{height}",
101
- '--header="Use tab to mark multiple selections, enter to display/run"',
102
- '--prompt="Select a section > "',
101
+ '--header="Tab: add selection, ctrl-a/d: (de)select all, return: display/run"',
102
+ '--bind ctrl-a:select-all,ctrl-d:deselect-all,ctrl-t:toggle-all',
103
+ '--prompt="Select a topic > "',
103
104
  %(--preview="howzit --no-pager --header-format block --no-color --default --multiple first {}")
104
105
  ]
105
106
  res = `echo #{Shellwords.escape(matches.join("\n"))} | fzf #{settings.join(' ')}`.strip
@@ -3,5 +3,5 @@
3
3
  # Primary module for this gem.
4
4
  module Howzit
5
5
  # Current Howzit version.
6
- VERSION = '2.0.23'
6
+ VERSION = '2.0.26'
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.23
4
+ version: 2.0.26
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-09 00:00:00.000000000 Z
11
+ date: 2022-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler