howzit 1.2.12 → 1.2.13

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: 875d039552876588bf298e4297ffec3955a6a73da6c2f89f608f7d11ed9d4e93
4
- data.tar.gz: ecd7f0dd8f67999de4e223745f79096cc06ebd84e867400bc729f2323e8f8360
3
+ metadata.gz: 36a27d1566deff8857d39035c0e40f696a29d78b7ae24274a73ceacc54541321
4
+ data.tar.gz: 7b13d6644bf397e10f629689b159102a33dd5aa2c3610f368819de3dc8736007
5
5
  SHA512:
6
- metadata.gz: bfcad0fc1a4fbf0140dc91ae5cf03e52c3d42aed4a404c91fab642db05d9849b92c0c73d4f87d79ca0b58d1583a6a0ab5ef0ef9936812913567aeb3f24508a93
7
- data.tar.gz: db44b03b2f2c25c84187692a9d46a328a22d4a7dce0adc20304ab31fe58e91b6ca4bef6848ab69efcce5e0c60e9c8955501f4232d5643f664d35cb81da9bcbdf
6
+ metadata.gz: 9da1ea212df950e75a34006a44b0ade09c02fd4fe7c02ea0fddfffcf2936e6ca5db0d7f0c9e6cc44aac3d65eb4544aa9d4c03c156487f9311f39f08ee12199d4
7
+ data.tar.gz: 99f9be58ff9184a2f96e7db6fed83e3fc19f0945e31c9d58daa32db022b175a8c99a329a9c023528af52100f46583ac892091eb04ed5d9e9e791087fe8f8c82d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 1.2.13
2
+
3
+ 2022-08-01 20:50
4
+
1
5
  ### 1.2.12
2
6
 
3
7
  2022-08-01 16:23
data/Rakefile CHANGED
@@ -29,3 +29,8 @@ task :ver do
29
29
  puts "version.rb: #{version}"
30
30
  puts "changelog: #{cver}"
31
31
  end
32
+
33
+ desc 'Changelog version check'
34
+ task :cver do
35
+ puts IO.read(File.join(File.dirname(__FILE__), 'CHANGELOG.md')).match(/^#+ (\d+\.\d+\.\d+(\w+)?)/)[1]
36
+ end
@@ -160,30 +160,40 @@ module Howzit
160
160
  warn "\nCanceled"
161
161
  exit!
162
162
  end
163
+ default = !$stdout.isatty || @options[:default]
163
164
  # First make sure there isn't already a buildnotes file
164
165
  if note_file
165
166
  fname = Color.template("{by}#{note_file}{bw}")
166
- res = yn("#{fname} exists and appears to be a build note, continue anyway?", false)
167
- unless res
168
- puts 'Canceled'
169
- Process.exit 0
167
+ unless default
168
+ res = yn("#{fname} exists and appears to be a build note, continue anyway?", false)
169
+ unless res
170
+ puts 'Canceled'
171
+ Process.exit 0
172
+ end
170
173
  end
171
174
  end
172
175
 
173
176
  title = File.basename(Dir.pwd)
174
- printf Color.template("{bw}Project name {xg}[#{title}]{bw}: {x}")
175
- input = $stdin.gets.chomp
176
- title = input unless input.empty?
177
-
177
+ if default
178
+ input = title
179
+ else
180
+ printf Color.template("{bw}Project name {xg}[#{title}]{bw}: {x}")
181
+ input = $stdin.gets.chomp
182
+ title = input unless input.empty?
183
+ end
178
184
  summary = ''
179
- printf Color.template('{bw}Project summary: {x}')
180
- input = $stdin.gets.chomp
181
- summary = input unless input.empty?
185
+ unless default
186
+ printf Color.template('{bw}Project summary: {x}')
187
+ input = $stdin.gets.chomp
188
+ summary = input unless input.empty?
189
+ end
182
190
 
183
191
  fname = 'buildnotes.md'
184
- printf Color.template("{bw}Build notes filename (must begin with 'howzit' or 'build')\n{xg}[#{fname}]{bw}: {x}")
185
- input = $stdin.gets.chomp
186
- fname = input unless input.empty?
192
+ unless default
193
+ printf Color.template("{bw}Build notes filename (must begin with 'howzit' or 'build')\n{xg}[#{fname}]{bw}: {x}")
194
+ input = $stdin.gets.chomp
195
+ fname = input unless input.empty?
196
+ end
187
197
 
188
198
  note = <<~EOBUILDNOTES
189
199
  # #{title}
@@ -210,7 +220,7 @@ module Howzit
210
220
 
211
221
  EOBUILDNOTES
212
222
 
213
- if File.exist?(fname)
223
+ if File.exist?(fname) && !default
214
224
  file = Color.template("{by}#{fname}")
215
225
  res = yn("Are you absolutely sure you want to overwrite #{file}", false)
216
226
 
@@ -689,7 +699,8 @@ module Howzit
689
699
  title_only: false,
690
700
  choose: false,
691
701
  quiet: false,
692
- verbose: false
702
+ verbose: false,
703
+ default: false
693
704
  }
694
705
 
695
706
  defaults = {
@@ -733,7 +744,7 @@ module Howzit
733
744
  end
734
745
 
735
746
  opts.on('-e', '--edit', "Edit buildnotes file in current working directory
736
- using #{File.basename(ENV['EDITOR'])}") do
747
+ using $EDITOR") do
737
748
  edit_note
738
749
  Process.exit 0
739
750
  end
@@ -797,7 +808,7 @@ module Howzit
797
808
  @options[:wrap] = w.to_i
798
809
  end
799
810
 
800
- opts.on('--edit-config', "Edit configuration file using #{File.basename(ENV['EDITOR'])}") do
811
+ opts.on('--edit-config', "Edit configuration file using default $EDITOR") do
801
812
  edit_config(defaults)
802
813
  Process.exit 0
803
814
  end
@@ -852,6 +863,10 @@ module Howzit
852
863
  puts "Howzit v#{VERSION}"
853
864
  Process.exit 0
854
865
  end
866
+
867
+ opts.on('--default', 'Answer all prompts with default response') do
868
+ @options[:default] = true
869
+ end
855
870
  end.parse!(args)
856
871
 
857
872
  @cli_args = args
@@ -1040,7 +1055,7 @@ module Howzit
1040
1055
  File.join(config_dir, 'templates')
1041
1056
  end
1042
1057
 
1043
- def create_config
1058
+ def create_config(defaults)
1044
1059
  dir, file = [config_dir, config_file]
1045
1060
  unless File.directory?(dir)
1046
1061
  warn "Creating config directory at #{dir}"
@@ -1055,7 +1070,7 @@ module Howzit
1055
1070
  end
1056
1071
 
1057
1072
  def load_config(defaults)
1058
- file = create_config
1073
+ file = create_config(defaults)
1059
1074
  config = YAML.load(IO.read(file))
1060
1075
  newconfig = config ? defaults.merge(config) : defaults
1061
1076
  write_config(newconfig)
data/lib/howzit/prompt.rb CHANGED
@@ -1,8 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Howzit
4
+ # Command line prompt utils
4
5
  module Prompt
5
6
  def yn(prompt, default = true)
7
+ return default if !$stdout.isatty
8
+
6
9
  system 'stty cbreak'
7
10
  yn = color_single_options(default ? %w[Y n] : %w[y N])
8
11
  $stdout.syswrite "\e[1;37m#{prompt} #{yn}\e[1;37m? \e[0m"
@@ -2,5 +2,5 @@
2
2
  # Primary module for this gem.
3
3
  module Howzit
4
4
  # Current Howzit version.
5
- VERSION = '1.2.12'.freeze
5
+ VERSION = '1.2.13'.freeze
6
6
  end
@@ -12,7 +12,9 @@ end
12
12
 
13
13
  describe Howzit::BuildNotes do
14
14
  Dir.chdir('spec')
15
- subject { Howzit::BuildNotes.new(['--no-upstream']) }
15
+ how = Howzit::BuildNotes.new(['--no-upstream', '--default'])
16
+ how.create_note
17
+ subject { how }
16
18
 
17
19
  describe ".note_file" do
18
20
  it "locates a build note file" do
@@ -20,12 +22,6 @@ describe Howzit::BuildNotes do
20
22
  end
21
23
  end
22
24
 
23
- describe ".get_note_title" do
24
- it "is named howzit test" do
25
- expect(subject.get_note_title).to match(/howzit test/)
26
- end
27
- end
28
-
29
25
  describe ".grep_topics" do
30
26
  it "found editable" do
31
27
  expect(subject.grep_topics('editable')).to include('File Structure')
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: 1.2.12
4
+ version: 1.2.13
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-01 00:00:00.000000000 Z
11
+ date: 2022-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler