howzit 2.0.20 → 2.0.23

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: 22f532430daee5c4c7a1d662d959aa5141848be745940e497b0f5d5d920e0739
4
- data.tar.gz: 4db5982c0f1409754cf41206b747ccc39b02ceacdaf100dc12e32185d8c13602
3
+ metadata.gz: aef13e763de59e83d14808c8778e5941c43b1b68669d09a9047dd53aaff60b38
4
+ data.tar.gz: 0f4052f07e44bbe1b9679a021abd147bc0830941351221baa61cb09f6bfe25c6
5
5
  SHA512:
6
- metadata.gz: 7d57db8ee804c204c42b1b30fac02bede10a2ec1b46c31aaf33a688a3441c6338e033e568d61eecedf3ec5a0c05087106532504a4c7cfcbff6daf1ccd9efea20
7
- data.tar.gz: 99d46ccfe0612d10c832e093a6b1f95fd4c48a72750e2375bc67b5bc8c1a017d15580f5806fa90fb47e8aae6db1f31c3fc931fd51d588ce1aa249bddfe875538
6
+ metadata.gz: 69231c5b96a7c011710787d6f47ef628286a5b7237489c6220f1bc25a9aab2d76d70f438b9d1872e2531710f100b3d09f715acabb138c7a8cfc6967d6dde9f70
7
+ data.tar.gz: 49c1e9266d4401d8ca863a9f107ab4e2c2722db719ab253b03db1b1c8983aeb83e3c715971d15be5ebe42d074f79b4ee521a9062a216422023c9884123555646
data/CHANGELOG.md CHANGED
@@ -1,3 +1,33 @@
1
+ ### 2.0.23
2
+
3
+ 2022-08-09 05:51
4
+
5
+ #### FIXED
6
+
7
+ - --grep function regression
8
+
9
+ ### 2.0.22
10
+
11
+ 2022-08-08 13:49
12
+
13
+ #### IMPROVED
14
+
15
+ - Paginate output of --templates
16
+
17
+ #### FIXED
18
+
19
+ - --templates attempting to create new build note
20
+ - Fix handling of paths when the same as note_file
21
+
22
+ ### 2.0.21
23
+
24
+ 2022-08-08 13:16
25
+
26
+ #### IMPROVED
27
+
28
+ - Use os-agnostic copy function for --hook
29
+ - Rename link title for --hook
30
+
1
31
  ### 2.0.20
2
32
 
3
33
  2022-08-08 11:38
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Howzit
2
2
 
3
3
  [![Gem](https://img.shields.io/gem/v/howzit.svg)](https://rubygems.org/gems/howzit)
4
- [![Travis](https://img.shields.io/travis/makenew/ruby-gem.svg)](https://travis-ci.org/makenew/ruby-gem)
4
+ [![Travis](https://api.travis-ci.com/ttscoff/howzit.svg?branch=main)](https://travis-ci.org/makenew/ruby-gem)
5
5
  [![GitHub license](https://img.shields.io/github/license/ttscoff/howzit.svg)](./LICENSE.txt)
6
6
 
7
7
  A command-line reference tool for tracking project build systems
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
 
@@ -153,11 +155,9 @@ OptionParser.new do |opts|
153
155
  Howzit.options[:grep] = pat
154
156
  end
155
157
 
156
- if RbConfig::CONFIG['target_os'] =~ /darwin.*/i
157
- opts.on('--hook', 'Copy a link to the build note file, ready for pasting into Hook.app or other notes') do
158
- Howzit.buildnote.hook
159
- Process.exit 0
160
- end
158
+ opts.on('--hook', 'Copy a link to the build note file, ready for pasting into Hook.app or other notes') do
159
+ Howzit.buildnote.hook
160
+ Process.exit 0
161
161
  end
162
162
 
163
163
  opts.on('-r', '--run', 'Execute @run, @open, and/or @copy commands for given topic') do
@@ -12,6 +12,7 @@ complete -c howzit -l templates -d "List available templates"
12
12
  complete -c howzit -l title-only -d "Output title only"
13
13
  complete -c howzit -s c -l create -d "Create a skeleton build note in the current working directory"
14
14
  complete -c howzit -f -l config-get -d "Display the configuration settings or setting for a specific key"
15
+ complete -c howzit -f -l hook -d "Copy a link to the build notes file (macOS)"
15
16
  complete -c howzit -f -l config-set -d "Set a config value (must be a valid key)"
16
17
  complete -c howzit -l edit-config -d "Edit configuration file using editor (subl)"
17
18
  complete -c howzit -s e -l edit -d "Edit buildnotes file in current working directory using editor (subl)"
@@ -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
 
@@ -77,9 +79,9 @@ module Howzit
77
79
  ##
78
80
  def hook
79
81
  title = Util.read_file(note_file).note_title(note_file, 20)
80
- title = "#{title} build notes"
82
+ title = "#{title} project notes"
81
83
  url = "[#{title}](file://#{note_file})"
82
- `echo #{Shellwords.escape(url)}'\\c'|pbcopy`
84
+ Util.os_copy(url)
83
85
  Howzit.console.info('Link copied to clipboard.')
84
86
  end
85
87
 
@@ -596,7 +598,7 @@ module Howzit
596
598
  lines = sect.split(/\n/)
597
599
  title = lines.slice!(0).strip
598
600
  prefix = ''
599
- if path
601
+ if path && path != note_file
600
602
  if path =~ /#{Howzit.config.template_folder}/
601
603
  short_path = File.basename(path, '.md')
602
604
  else
@@ -689,7 +691,7 @@ module Howzit
689
691
  ## single topic
690
692
  ##
691
693
  def process_topic(topic, run, single: false)
692
- new_topic = topic.dup
694
+ new_topic = topic.is_a?(String) ? find_topic(topic)[0] : topic.dup
693
695
 
694
696
  # Handle variable replacement
695
697
  new_topic.content = new_topic.content.render_arguments
@@ -791,6 +793,7 @@ module Howzit
791
793
 
792
794
  if !topic_matches.empty?
793
795
  # If we found a match
796
+ topic_matches.map! { |topic| topic.is_a?(String) ? find_topic(topic)[0] : topic }
794
797
  topic_matches.each { |topic_match| output.push(process_topic(topic_match, Howzit.options[:run], single: true)) }
795
798
  else
796
799
  # If there's no argument or no match found, output all
data/lib/howzit/task.rb CHANGED
@@ -94,62 +94,7 @@ module Howzit
94
94
  def run_copy
95
95
  title = Howzit.options[:show_all_code] ? @action : @title
96
96
  Howzit.console.info("{bg}Copied {bw}#{title}{bg} to clipboard{x}".c)
97
- os_copy(@action)
98
- end
99
-
100
- ##
101
- ## Platform-agnostic copy-to-clipboard
102
- ##
103
- ## @param string [String] The string to copy
104
- ##
105
- def os_copy(string)
106
- os = RbConfig::CONFIG['target_os']
107
- out = "{bg}Copying {bw}#{string}".c
108
- case os
109
- when /darwin.*/i
110
- Howzit.console.debug("#{out} (macOS){x}".c)
111
- `echo #{Shellwords.escape(string)}'\\c'|pbcopy`
112
- when /mingw|mswin/i
113
- Howzit.console.debug("#{out} (Windows){x}".c)
114
- `echo #{Shellwords.escape(string)} | clip`
115
- else
116
- if 'xsel'.available?
117
- Howzit.console.debug("#{out} (Linux, xsel){x}".c)
118
- `echo #{Shellwords.escape(string)}'\\c'|xsel -i`
119
- elsif 'xclip'.available?
120
- Howzit.console.debug("#{out} (Linux, xclip){x}".c)
121
- `echo #{Shellwords.escape(string)}'\\c'|xclip -i`
122
- else
123
- Howzit.console.debug(out)
124
- Howzit.console.warn('Unable to determine executable for clipboard.')
125
- end
126
- end
127
- end
128
-
129
- ##
130
- ## Platform-agnostic open command
131
- ##
132
- ## @param command [String] The command
133
- ##
134
- def os_open(command)
135
- os = RbConfig::CONFIG['target_os']
136
- out = "{bg}Opening {bw}#{command}".c
137
- case os
138
- when /darwin.*/i
139
- Howzit.console.debug "#{out} (macOS){x}".c if Howzit.options[:log_level] < 2
140
- `open #{Shellwords.escape(command)}`
141
- when /mingw|mswin/i
142
- Howzit.console.debug "#{out} (Windows){x}".c if Howzit.options[:log_level] < 2
143
- `start #{Shellwords.escape(command)}`
144
- else
145
- if 'xdg-open'.available?
146
- Howzit.console.debug "#{out} (Linux){x}".c if Howzit.options[:log_level] < 2
147
- `xdg-open #{Shellwords.escape(command)}`
148
- else
149
- Howzit.console.debug out if Howzit.options[:log_level] < 2
150
- Howzit.console.debug 'Unable to determine executable for `open`.'
151
- end
152
- end
97
+ Util.os_copy(@action)
153
98
  end
154
99
 
155
100
  ##
@@ -169,7 +114,7 @@ module Howzit
169
114
  when :copy
170
115
  run_copy
171
116
  when :open
172
- os_open(@action)
117
+ Util.os_open(@action)
173
118
  end
174
119
  end
175
120
 
data/lib/howzit/util.rb CHANGED
@@ -179,6 +179,61 @@ module Howzit
179
179
  puts output
180
180
  end
181
181
  end
182
+
183
+ ##
184
+ ## Platform-agnostic copy-to-clipboard
185
+ ##
186
+ ## @param string [String] The string to copy
187
+ ##
188
+ def os_copy(string)
189
+ os = RbConfig::CONFIG['target_os']
190
+ out = "{bg}Copying {bw}#{string}".c
191
+ case os
192
+ when /darwin.*/i
193
+ Howzit.console.debug("#{out} (macOS){x}".c)
194
+ `echo #{Shellwords.escape(string)}'\\c'|pbcopy`
195
+ when /mingw|mswin/i
196
+ Howzit.console.debug("#{out} (Windows){x}".c)
197
+ `echo #{Shellwords.escape(string)} | clip`
198
+ else
199
+ if 'xsel'.available?
200
+ Howzit.console.debug("#{out} (Linux, xsel){x}".c)
201
+ `echo #{Shellwords.escape(string)}'\\c'|xsel -i`
202
+ elsif 'xclip'.available?
203
+ Howzit.console.debug("#{out} (Linux, xclip){x}".c)
204
+ `echo #{Shellwords.escape(string)}'\\c'|xclip -i`
205
+ else
206
+ Howzit.console.debug(out)
207
+ Howzit.console.warn('Unable to determine executable for clipboard.')
208
+ end
209
+ end
210
+ end
211
+
212
+ ##
213
+ ## Platform-agnostic open command
214
+ ##
215
+ ## @param command [String] The command
216
+ ##
217
+ def os_open(command)
218
+ os = RbConfig::CONFIG['target_os']
219
+ out = "{bg}Opening {bw}#{command}".c
220
+ case os
221
+ when /darwin.*/i
222
+ Howzit.console.debug "#{out} (macOS){x}".c if Howzit.options[:log_level] < 2
223
+ `open #{Shellwords.escape(command)}`
224
+ when /mingw|mswin/i
225
+ Howzit.console.debug "#{out} (Windows){x}".c if Howzit.options[:log_level] < 2
226
+ `start #{Shellwords.escape(command)}`
227
+ else
228
+ if 'xdg-open'.available?
229
+ Howzit.console.debug "#{out} (Linux){x}".c if Howzit.options[:log_level] < 2
230
+ `xdg-open #{Shellwords.escape(command)}`
231
+ else
232
+ Howzit.console.debug out if Howzit.options[:log_level] < 2
233
+ Howzit.console.debug 'Unable to determine executable for `open`.'
234
+ end
235
+ end
236
+ end
182
237
  end
183
238
  end
184
239
  end
@@ -3,5 +3,5 @@
3
3
  # Primary module for this gem.
4
4
  module Howzit
5
5
  # Current Howzit version.
6
- VERSION = '2.0.20'
6
+ VERSION = '2.0.23'
7
7
  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.20
4
+ version: 2.0.23
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