markdown_exec 1.8.7 → 1.8.9

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: 83a04f06ad7f74d2557e1967ae424a8b5f8b08e9ddbbad10091ab6612f94c106
4
- data.tar.gz: 54a9b79333781bb540ce1e37f686bf132d437c2ab5475c6cd64c40b3f821935e
3
+ metadata.gz: a81d96c57727583a17c019bcb0a8097c6d97633a7b5ee2b33e2d9a7e56a4c081
4
+ data.tar.gz: 4c67c34577546161914e77be928867128e55d926c3419c2ab4c6cc521d051cae
5
5
  SHA512:
6
- metadata.gz: 4106f3dc27781398aee563bba15355b05f67a118170da36e9c1c51b776ec7549576ee162b090a33a3da278694438a66746d2f4c31384315929eca57558c5ca7a
7
- data.tar.gz: d46fa757bcfbee2fbfdebee46050ff579d4cd050a3203c887db47a5de4cc275986308cd056ef264947f1d7f239b717a8617b2a51218594f85cd10b27d14156bf
6
+ metadata.gz: 6e7ffb35e3b7cf4aa9fa03095519d28aa088367a8b91cbcf440b143f732510a43401e78b435a0ea73f03a6754e55897fa9800b121f9f767d64715d4d79f019b3
7
+ data.tar.gz: a4f94c70dc8f58a7b6bf79a4baf063ef893173ccb26aa57f19a1ab485656ec469dcfa3f70555cb2bddddc55b8a3023576724d23dc30d2b16f444dbd732025b9f
data/.rubocop.yml CHANGED
@@ -104,3 +104,6 @@ Style/StringLiterals:
104
104
  Style/StringLiteralsInInterpolation:
105
105
  Enabled: true
106
106
  EnforcedStyle: single_quotes
107
+
108
+ Style/UnlessElse:
109
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,7 +1,44 @@
1
- ## [1.8.7] - 2023-12-31
2
-
3
1
  # Changelog
4
2
 
3
+ ## [1.8.9] - 2024-01-20
4
+
5
+ ### Added
6
+
7
+ - Variables set in inherited lines for use in scripts.
8
+
9
+ - Link key `save` to write inherited lines to disk.
10
+
11
+ ## [1.8.8] - 2024-01-15
12
+
13
+ ### Added
14
+
15
+ - Debounce/Control repeated launching of the same block via the menu.
16
+
17
+ - Option to match block nicknames.
18
+ Nicknames are used for scripting and are not displayed in the menu -- the block body is shown the menu.
19
+
20
+ - Option to execute script to launch Terminal window.
21
+ Provide batch variables to use in the execute_command_format script.
22
+ Limit iTerm window position to visible area.
23
+ Store output of executed script.
24
+ Menu to replay, review, and exit.
25
+
26
+ - Report line in document importing a missing file.
27
+
28
+ - Option to search for import files within each of the specified paths (recursion optional).
29
+
30
+ - Eval block loads (appends) local file to inherited lines.
31
+
32
+ - Eval block executes script and appends filtered output to inherited lines.
33
+ Select output using begin and end matching lines.
34
+ Transform selected output with per-line match and print specifications.
35
+
36
+ ### Changed
37
+
38
+ - Sanitize block names in formatted lines above and below inherited code.
39
+
40
+ ## [1.8.7] - 2023-12-31
41
+
5
42
  ### Added
6
43
 
7
44
  - Option for block name that presents the menu.
@@ -26,7 +63,8 @@
26
63
 
27
64
  ### Added
28
65
 
29
- - "eval" key for link block type to compute lines to append to the inherited state.
66
+ - "eval" boolean value for Link blocks to compute lines to append to the inherited state.
67
+ - "return" boolean value for Link blocks to return to the original page.
30
68
  - Options for dumping data associated with the menu or state.
31
69
  - Debug and irb gems.
32
70
 
data/Gemfile CHANGED
@@ -9,6 +9,7 @@ gemspec
9
9
  gem 'clipboard'
10
10
  gem 'debug'
11
11
  gem 'erb'
12
+ gem 'httparty' # 2024-01-01 for ChatGPI API
12
13
  gem 'irb', '>= 1.8.0'
13
14
  gem 'mocha', require: false
14
15
  gem 'minitest', require: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (1.8.7)
4
+ markdown_exec (1.8.9)
5
5
  clipboard (~> 1.3.6)
6
6
  open3 (~> 0.1.1)
7
7
  optparse (~> 0.1.1)
@@ -47,6 +47,9 @@ GEM
47
47
  erb (4.0.3)
48
48
  cgi (>= 0.3.3)
49
49
  erubi (1.12.0)
50
+ httparty (0.21.0)
51
+ mini_mime (>= 1.0.0)
52
+ multi_xml (>= 0.5.2)
50
53
  i18n (1.14.1)
51
54
  concurrent-ruby (~> 1.0)
52
55
  io-console (0.7.1)
@@ -60,9 +63,11 @@ GEM
60
63
  crass (~> 1.0.2)
61
64
  nokogiri (>= 1.12.0)
62
65
  method_source (1.0.0)
66
+ mini_mime (1.1.5)
63
67
  minitest (5.20.0)
64
68
  mocha (2.1.0)
65
69
  ruby2_keywords (>= 0.0.5)
70
+ multi_xml (0.6.0)
66
71
  nokogiri (1.15.4-arm64-darwin)
67
72
  racc (~> 1.4)
68
73
  open3 (0.1.2)
@@ -182,6 +187,7 @@ DEPENDENCIES
182
187
  clipboard
183
188
  debug
184
189
  erb
190
+ httparty
185
191
  irb (>= 1.8.0)
186
192
  markdown_exec!
187
193
  minitest
data/Rakefile CHANGED
@@ -82,6 +82,7 @@ task :minitest do
82
82
  './lib/directory_searcher.rb',
83
83
  './lib/fcb.rb',
84
84
  './lib/filter.rb',
85
+ './lib/find_files.rb',
85
86
  './lib/hash_delegator.rb',
86
87
  './lib/markdown_exec.rb',
87
88
  './lib/mdoc.rb',
data/bin/bmde CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env bundle exec ruby
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # encoding=utf-8
@@ -13,7 +13,7 @@ __filedirs_all()
13
13
  }
14
14
 
15
15
  _mde_echo_version() {
16
- echo "1.8.7"
16
+ echo "1.8.9"
17
17
  }
18
18
 
19
19
  _mde() {
@@ -80,9 +80,9 @@ _mde() {
80
80
 
81
81
  --saved-stdout-folder) COMPREPLY="logs"; return 0 ;;
82
82
 
83
- --user-must-approve) COMPREPLY="1"; return 0 ;;
83
+ --user-must-approve) COMPREPLY="0"; return 0 ;;
84
84
 
85
- -q) COMPREPLY="1"; return 0 ;;
85
+ -q) COMPREPLY="0"; return 0 ;;
86
86
 
87
87
  --display-level) COMPREPLY="1"; return 0 ;;
88
88
 
@@ -178,4 +178,4 @@ _mde() {
178
178
 
179
179
  complete -o filenames -o nospace -F _mde mde
180
180
  # _mde_echo_version
181
- # echo "Updated: 2023-12-31 17:23:18 UTC"
181
+ # echo "Updated: 2024-01-20 19:29:56 UTC"
data/examples/colors.md CHANGED
@@ -43,7 +43,8 @@ warning_color: fg_rgbh_ff_7f_00
43
43
  ```
44
44
 
45
45
  ::: Example blocks
46
-
46
+ ```
47
+ ```
47
48
  ```bash :Bash1
48
49
  ```
49
50
  ```link :Link1
@@ -0,0 +1,66 @@
1
+ This is a concise guide for using Bash commands to find and list recent files in a Linux system. The commands are safe to use and can help you quickly locate recently modified or accessed files.
2
+
3
+ 1. **List Recently Modified Files**:
4
+ You can use the `ls` command with sorting options to list recently modified files in the current directory.
5
+
6
+ ```bash
7
+ ls -lt
8
+ ```
9
+
10
+ 2. **Using `stat` for File Details**:
11
+ To get detailed information about file modifications, access, and change, use the `stat` command.
12
+
13
+ Example for a specific file:
14
+ ```bash
15
+ stat .
16
+ ```
17
+
18
+ 3. **Find Files**:
19
+ A. **Find Files Modified in the Last N Days**:
20
+ The `find` command is useful for searching files modified within a specific number of days.
21
+
22
+ For example, to find files modified in the last 7 days:
23
+ ```bash
24
+ find . -type f -mtime -7
25
+ ```
26
+
27
+ B. **Display Files Accessed Recently**:
28
+ Similarly, you can list files that were accessed recently using the `find` command.
29
+
30
+ 1. To list files accessed in the last 3 days:
31
+ ```bash
32
+ find . -type f -atime -3
33
+ ```
34
+
35
+ 2. **Advanced Search with `find`**:
36
+ Combine `find` with other commands for advanced searching. For instance, to list and sort files by modification time:
37
+
38
+ ```bash
39
+ find . -type f -mtime -7 -exec ls -lt {} +
40
+ ```
41
+
42
+ These commands provide a basic way to manage and track file modifications and access on your system. They are particularly useful for system administration and file management tasks.
43
+
44
+ ```link :Link1
45
+ ```
46
+
47
+ ```link :Link2
48
+ ```
49
+
50
+ ```opts :Opts1
51
+ ```
52
+
53
+ ```opts :Opts2
54
+ ```
55
+
56
+ ```port :Port1
57
+ ```
58
+
59
+ ```port :Port2
60
+ ```
61
+
62
+ ```vars :Vars1
63
+ ```
64
+
65
+ ```vars :Vars2
66
+ ```
data/examples/linked.md CHANGED
@@ -1,52 +1,101 @@
1
- Demonstrate setting a variable interactively for use in generated scripts.
1
+ Demonstrate setting variable values interactively for use in generated scripts.
2
2
 
3
3
  ```opts :(document_options)
4
- dump_inherited_lines: true
5
4
  pause_after_script_execution: false
6
5
  user_must_approve: false
7
6
  ```
8
7
 
9
- ::: Set VARIABLE to "A"
8
+ ::: Set variable ALPHA in a Vars block
9
+ For each environment variable named in block,
10
+ append an inherited line that assigns the variable the specified value.
11
+ ```vars :set_ALPHA_to_1_via_vars_block
12
+ ALPHA: 1
13
+ ```
10
14
 
11
- ```link :set_to_A +(set_to_A)
12
- block: display_variable
15
+ ::: Set variable ALPHA in a Link block
16
+ For each environment variable in `vars`,
17
+ append an inherited line that assigns the variable the specified value.
18
+ Subsequently, run the `display_variable_ALPHA` block.
19
+ ```link :set_ALPHA_to_2_via_link_block_and_display
20
+ block: display_variable_ALPHA
21
+ vars:
22
+ ALPHA: 2
13
23
  ```
14
24
 
15
- ```bash :(set_to_A)
16
- VARIABLE=A
25
+ Make the code in the required block `(bash_set_to_3)` into inherited lines.
26
+ Subsequently, run the `display_variable_ALPHA` block.
27
+ ```bash :(bash_set_to_3)
28
+ ALPHA=3
29
+ ```
30
+ ```link :set_ALPHA_to_3_via_required_block_and_display +(bash_set_to_3)
31
+ block: display_variable_ALPHA
17
32
  ```
18
33
 
19
- ```link :set_to_A_eval +(set_to_A_eval)
20
- block: display_variable
34
+ Evaluate the code in the required block `(bash_eval_set_to_4)` and
35
+ save (transformed) output into inherited lines.
36
+ Subsequently, run the `display_variable_ALPHA` block.
37
+ ```link :set_ALPHA_to_4_via_evaluated_required_block_and_display +(bash_eval_set_to_4)
21
38
  eval: true
39
+ next_block: display_variable_ALPHA
22
40
  ```
23
-
24
- ```bash :(set_to_A_eval)
25
- echo VARIABLE=A
41
+ ```bash :(bash_eval_set_to_4)
42
+ echo 'ALPHA="4"'
26
43
  ```
27
44
 
28
- ::: Set VARIABLE to "B"
29
-
30
- ```link :set_to_B +(set_to_B)
31
- block: display_variable
45
+ ::: Display value of ALPHA
46
+ ```bash :display_variable_ALPHA
47
+ source bin/colorize_env_vars.sh
48
+ echo The current value of environment variable ALPHA is now:
49
+ colorize_env_vars '' ALPHA
32
50
  ```
33
51
 
34
- ```bash :(set_to_B)
35
- VARIABLE=B
52
+ ::: Load file into inherited lines
53
+ Load (do not evaluate) and append to inherited lines.
54
+ ```link :load1
55
+ load: examples/load1.sh
36
56
  ```
37
-
38
- ```link :set_to_B_eval +(set_to_B_eval)
39
- block: display_variable
57
+ Load, evaluate, and append output to inherited lines.
58
+ ```link :load2_eval
59
+ load: examples/load2.sh
40
60
  eval: true
41
61
  ```
42
62
 
43
- ```bash :(set_to_B_eval)
44
- echo VARIABLE=B
63
+ ::: Save and Load
64
+ Save inherited lines to a file.
65
+ ```link :save1
66
+ save: tmp/save1.sh
67
+ ```
68
+ Load inherited lines from a file.
69
+ Subsequently, run the `display_variables` block.
70
+ ```link :load_saved
71
+ load: tmp/save1.sh
72
+ block: display_variables
73
+ ```
74
+ Display variables ALPHA, var1, var2
75
+ ```bash :display_variables
76
+ source bin/colorize_env_vars.sh
77
+ colorize_env_vars '' ALPHA var1 var2
45
78
  ```
46
79
 
47
- ::: Display value of VARIABLE
48
-
49
- ```bash :display_variable
80
+ Execute a script requiring input from the user.
81
+ Save the output setting TIMESTAMP into inherited lines.
82
+ Subsequently, run the `display_TIMESTAMP` block.
83
+ ```bash :(input_timestamp)
84
+ if [[ -z $TIMESTAMP ]]; then
85
+ default="$(date -u +%y%m%d)"
86
+ echo "yymmdd? (default: $default / today UTC) "
87
+ read -r TIMESTAMP
88
+ [[ -z $TIMESTAMP ]] && TIMESTAMP="$(date -u +%y%m%d)"
89
+ fi
90
+ ```
91
+ ```bash :(inherit_timestamp)
92
+ echo "TIMESTAMP=\"$TIMESTAMP\""
93
+ ```
94
+ ```link :set_timestamp +(input_timestamp) +(inherit_timestamp)
95
+ exec: true
96
+ block: display_TIMESTAMP
97
+ ```
98
+ ```bash :display_TIMESTAMP
50
99
  source bin/colorize_env_vars.sh
51
- colorize_env_vars '' VARIABLE
100
+ colorize_env_vars '' TIMESTAMP
52
101
  ```
data/examples/load1.sh ADDED
@@ -0,0 +1,5 @@
1
+ # line 1
2
+ var1=line2
3
+ # line 3
4
+ var2=line4
5
+ # line 5
data/examples/load2.sh ADDED
@@ -0,0 +1,5 @@
1
+ # line 1
2
+ echo "var1=line2"
3
+ # line 3
4
+ echo "var2=line4"
5
+ # line 5
@@ -0,0 +1,26 @@
1
+ # Demo block nicknames
2
+
3
+ ```opts :(document_options)
4
+ save_executed_script: true
5
+ ```
6
+
7
+ ::: This block has no name.
8
+ ::: The code block is displayed.
9
+
10
+ ```bash
11
+ echo Unnamed block
12
+ ```
13
+
14
+ ::: These blocks use nicknames.
15
+ ::: The code blocks are displayed.
16
+ ::: The nicknames can be used for requiring blocks.
17
+
18
+ ```bash :[A]
19
+ echo From the required block 2
20
+ ```
21
+
22
+ ::: Execute this block that requires the block above.
23
+
24
+ ```bash :[B] +[A]
25
+ echo From the parent block 1
26
+ ```
data/lib/array.rb CHANGED
@@ -4,6 +4,10 @@
4
4
  # encoding=utf-8
5
5
 
6
6
  class Array
7
+ def pluck(key)
8
+ map { |hash| hash[key] if hash.is_a?(Hash) }.compact
9
+ end
10
+
7
11
  # Processes each element of the array, yielding the previous, current, and next elements to the given block.
8
12
  # Deletes the current element if the block returns true.
9
13
  # @return [Array] The modified array after conditional deletions.
@@ -8,6 +8,7 @@
8
8
  require 'fileutils'
9
9
  require_relative 'constants'
10
10
  require_relative 'exceptions'
11
+ require_relative 'find_files'
11
12
 
12
13
  ##
13
14
  # The CachedNestedFileReader class provides functionality to read file lines with the ability
@@ -38,25 +39,28 @@ class CachedNestedFileReader
38
39
  )
39
40
  end
40
41
 
41
- def readlines(filename, depth = 0, &block)
42
+ def readlines(filename, depth = 0, context: '', import_paths: nil, &block)
42
43
  if @file_cache.key?(filename)
43
44
  @file_cache[filename].each(&block) if block
44
45
  return @file_cache[filename]
45
46
  end
46
47
 
47
48
  directory_path = File.dirname(filename)
48
- # lines = File.readlines(filename, chomp: true)
49
49
  processed_lines = []
50
-
51
- File.readlines(filename, chomp: true).each do |line|
50
+ File.readlines(filename, chomp: true).each.with_index do |line, ind|
52
51
  if Regexp.new(@import_pattern) =~ line
53
52
  name_strip = $~[:name].strip
54
53
  included_file_path = if name_strip =~ %r{^/}
55
54
  name_strip
55
+ elsif import_paths
56
+ find_files(name_strip, import_paths + [directory_path])&.first
56
57
  else
57
58
  File.join(directory_path, name_strip)
58
59
  end
60
+
59
61
  processed_lines += readlines(included_file_path, depth + 1,
62
+ context: "#{filename}:#{ind + 1}",
63
+ import_paths: import_paths,
60
64
  &block)
61
65
  else
62
66
  nested_line = NestedLine.new(line, depth)
@@ -68,58 +72,58 @@ class CachedNestedFileReader
68
72
  @file_cache[filename] = processed_lines
69
73
  rescue Errno::ENOENT
70
74
  # Exceptions.error_handler('readlines', { abort: true })
71
- warn_format('readlines', "No such file -- #{filename}", { abort: true })
75
+ warn_format('readlines', "No such file -- #{filename} @@ #{context}", { abort: true })
72
76
  end
73
77
  end
74
78
 
75
- if $PROGRAM_NAME == __FILE__
76
- require 'minitest/autorun'
77
- require 'tempfile'
79
+ return if $PROGRAM_NAME != __FILE__
78
80
 
79
- class CachedNestedFileReaderTest < Minitest::Test
80
- def setup
81
- @file2 = Tempfile.new('test2.txt')
82
- @file2.write("ImportedLine1\nImportedLine2")
83
- @file2.rewind
81
+ require 'minitest/autorun'
82
+ require 'tempfile'
84
83
 
85
- @file1 = Tempfile.new('test1.txt')
86
- @file1.write("Line1\nLine2\n #insert #{@file2.path}\nLine3")
87
- @file1.rewind
88
- @reader = CachedNestedFileReader.new(import_pattern: /^ *#insert (?'name'.+)$/)
89
- end
84
+ class CachedNestedFileReaderTest < Minitest::Test
85
+ def setup
86
+ @file2 = Tempfile.new('test2.txt')
87
+ @file2.write("ImportedLine1\nImportedLine2")
88
+ @file2.rewind
90
89
 
91
- def teardown
92
- @file1.close
93
- @file1.unlink
90
+ @file1 = Tempfile.new('test1.txt')
91
+ @file1.write("Line1\nLine2\n #insert #{@file2.path}\nLine3")
92
+ @file1.rewind
93
+ @reader = CachedNestedFileReader.new(import_pattern: /^ *#insert (?'name'.+)$/)
94
+ end
94
95
 
95
- @file2.close
96
- @file2.unlink
97
- end
96
+ def teardown
97
+ @file1.close
98
+ @file1.unlink
98
99
 
99
- def test_readlines_without_imports
100
- result = @reader.readlines(@file2.path).map(&:to_s)
101
- assert_equal %w[ImportedLine1 ImportedLine2], result
102
- end
100
+ @file2.close
101
+ @file2.unlink
102
+ end
103
103
 
104
- def test_readlines_with_imports
105
- result = @reader.readlines(@file1.path).map(&:to_s)
106
- assert_equal %w[Line1 Line2 ImportedLine1 ImportedLine2 Line3],
107
- result
108
- end
104
+ def test_readlines_without_imports
105
+ result = @reader.readlines(@file2.path).map(&:to_s)
106
+ assert_equal %w[ImportedLine1 ImportedLine2], result
107
+ end
109
108
 
110
- def test_caching_functionality
111
- # First read
109
+ def test_readlines_with_imports
110
+ result = @reader.readlines(@file1.path).map(&:to_s)
111
+ assert_equal %w[Line1 Line2 ImportedLine1 ImportedLine2 Line3],
112
+ result
113
+ end
112
114
 
113
- result1 = @reader.readlines(@file2.path).map(&:to_s)
115
+ def test_caching_functionality
116
+ # First read
114
117
 
115
- # Simulate file content change
116
- @file2.reopen(@file2.path, 'w') { |f| f.write('ChangedLine') }
118
+ result1 = @reader.readlines(@file2.path).map(&:to_s)
117
119
 
118
- # Second read (should read from cache, not the changed file)
119
- result2 = @reader.readlines(@file2.path).map(&:to_s)
120
+ # Simulate file content change
121
+ @file2.reopen(@file2.path, 'w') { |f| f.write('ChangedLine') }
120
122
 
121
- assert_equal result1, result2
122
- assert_equal %w[ImportedLine1 ImportedLine2], result2
123
- end
123
+ # Second read (should read from cache, not the changed file)
124
+ result2 = @reader.readlines(@file2.path).map(&:to_s)
125
+
126
+ assert_equal result1, result2
127
+ assert_equal %w[ImportedLine1 ImportedLine2], result2
124
128
  end
125
129
  end
@@ -0,0 +1,22 @@
1
+ require 'yaml'
2
+ require 'terminal-table'
3
+
4
+ cmd = 'aws ce get-cost-and-usage --time-period Start=2023-12-01,End=2023-12-31 --granularity MONTHLY --metrics "UnblendedCost" "UsageQuantity" --group-by Type=DIMENSION,Key=SERVICE'
5
+
6
+ # Parse the YAML content
7
+ text = system(cmd)
8
+ data = YAML.load(text)
9
+
10
+ # Extracting the relevant information
11
+ services = data["ResultsByTime"][0]["Groups"].map do |group|
12
+ service_name = group["Keys"][0]
13
+ unblended_cost = "#{group['Metrics']['UnblendedCost']['Amount']} #{group['Metrics']['UnblendedCost']['Unit']}"
14
+ usage_quantity = "#{group['Metrics']['UsageQuantity']['Amount']} #{group['Metrics']['UsageQuantity']['Unit']}"
15
+ [service_name, unblended_cost, usage_quantity]
16
+ end
17
+
18
+ # Create a table
19
+ table = Terminal::Table.new :headings => ['Service', 'Unblended Cost', 'Usage Quantity'], :rows => services
20
+
21
+ # Output the table
22
+ puts table
data/lib/constants.rb CHANGED
@@ -17,6 +17,18 @@ IndexedLine = Struct.new(:index, :line) do
17
17
  end
18
18
  end
19
19
 
20
+ class LinkKeys
21
+ Block = 'block'
22
+ Eval = 'eval'
23
+ Exec = 'exec'
24
+ File = 'file'
25
+ Load = 'load'
26
+ NextBlock = 'next_block'
27
+ Return = 'return'
28
+ Save = 'save'
29
+ Vars = 'vars'
30
+ end
31
+
20
32
  class LoadFile
21
33
  Load = true
22
34
  Reuse = false
data/lib/exceptions.rb CHANGED
@@ -4,12 +4,14 @@
4
4
  # encoding=utf-8
5
5
 
6
6
  module Exceptions
7
- def self.error_handler(name = '', opts = {}, format_string: "\nError: %{name} -- %{message}", color_symbol: :red, take_count: 16)
7
+ def self.error_handler(name = '', opts = {}, backtrace: $@, format_string: "\nError: %{name} -- %{message}", color_symbol: :red, take_count: 16)
8
8
  warn(error = format(format_string,
9
9
  { name: name, message: $! }).send(color_symbol))
10
- warn($@.select do |s|
11
- s.include? 'markdown_exec'
12
- end.reject { |s| s.include? 'vendor' }.take(take_count).map.with_index { |line, ind| " * #{ind}: #{line}" })
10
+ if backtrace
11
+ warn(backtrace.select do |s|
12
+ s.include? 'markdown_exec'
13
+ end.reject { |s| s.include? 'vendor' }.take(take_count).map.with_index { |line, ind| " * #{ind}: #{line}" })
14
+ end
13
15
 
14
16
  binding.pry if $tap_enable
15
17
  raise ArgumentError, error unless opts.fetch(:abort, true)
data/lib/fcb.rb CHANGED
@@ -21,6 +21,7 @@ module MarkdownExec
21
21
  dname: nil,
22
22
  indent: '',
23
23
  name: nil,
24
+ nickname: nil,
24
25
  oname: nil,
25
26
  reqs: [],
26
27
  shell: '',
@@ -38,12 +39,13 @@ module MarkdownExec
38
39
  # @param fcb [Object] The FCB object whose title is to be derived.
39
40
  # @return [String] The derived title.
40
41
  def derive_title_from_body
41
- body_content = @attrs[:body]
42
- unless body_content
42
+ unless (body_content = @attrs[:body])
43
+ # empty body -> empty title
43
44
  @attrs[:title] = ''
44
45
  return
45
46
  end
46
47
 
48
+ # body -> title
47
49
  @attrs[:title] = if body_content.count == 1
48
50
  body_content.first
49
51
  else
@@ -113,6 +115,7 @@ if $PROGRAM_NAME == __FILE__
113
115
  headings: %w[Header1 Header2],
114
116
  dname: 'Sample name',
115
117
  indent: '',
118
+ nickname: nil,
116
119
  name: 'Sample name',
117
120
  oname: 'Sample name',
118
121
  reqs: %w[req1 req2],