markdown_exec 0.2.0 → 0.2.4

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: 0d9976af006093768c7673d5ef0abeff6766539ff86029179d45db0530a4e203
4
- data.tar.gz: c2814cf1b85ba80352819c2866862e40a9185874469edc65e0673485e0ca4f7e
3
+ metadata.gz: 2336bb2091df5bf018181e832fb9c5e7a5b7ee542b6f71cde38a3afb3aa88ab4
4
+ data.tar.gz: '072654942ddf5897784c71724a7f9fa6fb5bea9b395d54ca18a3f3fd9b02c5af'
5
5
  SHA512:
6
- metadata.gz: 9720f8af38d17eba836b73407dedf71848c19663fa017277d3a62e003e19da36a3cad881796ce58e7b84d3d03a94a3a130d6876ac41c908d4694dadc80b53c6b
7
- data.tar.gz: 707486f6a6e424787ee7ef05336d5a7290375844f477f369aa7dce2dc72d7f0343d425d83ac778d6b12859b4e155c6fea0ed0acb0cc3719b2d42b5fbf99f2c7b
6
+ metadata.gz: 2f28a18aea943a7fec92b16d232b8c3722a30f6960fbd32bf84e95762b4ac322f0fb53f75563118a15136da72e49f16c580a8c7fbf05d2001857e068403834ef
7
+ data.tar.gz: 8bb762715d790e37906d61cf8834e86dfe7e4f9611b8f7477da508d2ff658d496c6e1e0c89fc42e9e5f2cf937e29dae3cddf062cabda867f3a5bb1466986f2c3
data/.rubocop.yml CHANGED
@@ -1,4 +1,9 @@
1
+ require:
2
+ - rubocop-minitest
3
+ - rubocop-rake
4
+
1
5
  AllCops:
6
+ NewCops: enable
2
7
  TargetRubyVersion: 2.6
3
8
 
4
9
  Metrics/AbcSize:
data/CHANGELOG.md CHANGED
@@ -1,4 +1,106 @@
1
- ## [Unreleased]
1
+ # Changelog
2
+
3
+
4
+ ## [0.2.4] - 2022-04-01
5
+
6
+ ### Added
7
+
8
+ - Command `--list-recent-scripts` to list the last *N* saved scripts.
9
+ - Command `--run-last-script` to re-run the last saved script.
10
+ - Command `--select-recent-script` to select and execute a recently saved script.
11
+
12
+ | YAML Name | Environment Variable | Option Name | Default | Purpose |
13
+ | :--- | :--- | :--- | :--- | :--- |
14
+ | list_count | MDE_LIST_COUNT | `--list_count` | `16` | Max. items to return in list |
15
+ | logged_stdout_filename_prefix | MDE_LOGGED_STDOUT_FILENAME_PREFIX | | `mde` | Name prefix for stdout files |
16
+ | save_execution_output | MDE_SAVE_EXECUTION_OUTPUT | `--save-execution-output` | False | Save standard output of the executed script |
17
+ | saved_script_filename_prefix | MDE_SAVED_SCRIPT_FILENAME_PREFIX | | `mde` | Name prefix for saved scripts |
18
+ | saved_script_folder | MDE_SAVED_SCRIPT_FOLDER | `--saved-script-folder` | `logs` | Saved script folder |
19
+ | saved_script_glob | MDE_SAVED_SCRIPT_GLOB | | `mde_*.sh` | Glob matching saved scripts |
20
+ | saved_stdout_folder | MDE_SAVED_STDOUT_FOLDER | `--saved-stdout-folder` | `logs` | Saved stdout folder |
21
+
22
+ ### Changed
23
+
24
+ - Fix saving of executed script.
25
+ - Sort configuration keys output by `-0` (Show configuration.)
26
+
27
+ ## [0.2.3] - 2022-03-29
28
+
29
+ ### Added
30
+
31
+ - `rubocop` checks.
32
+ - Added optional command-line positional arguments:
33
+ 1. document file
34
+ 2. block name
35
+
36
+ e.g. `mde doc1 block1` will execute the block named `block1` in file `doc1`.
37
+
38
+ ### Changed
39
+
40
+ - Naming saved script files: The file name contains the time stamp, document name, and block name.
41
+ - Renamed folder with fixtures.
42
+ - Command options:
43
+
44
+ | YAML Name | Environment Variable | Option Name | Default | Purpose |
45
+ | :--- | :--- | :--- | :--- | :--- |
46
+ | debug | MDE_DEBUG | `--debug` | False | Output debugging information (verbose) |
47
+ | filename | MDE_FILENAME | `--filename` | `README.md`* | File name of document |
48
+ | output_execution_summary | MDE_OUTPUT_STDOUT_SUMMARY | `--output-execution-summary` | False | Display summary for execution |
49
+ | output_script | MDE_OUTPUT_SCRIPT | `--output-script` | False | Display script |
50
+ | output_stdout | MDE_OUTPUT_EXECUTION | `--output-stdout` | True | Display standard output from execution |
51
+ | path | MDE_PATH | `--path` | `.` | Path to document(s) |
52
+ | save_executed_script | MDE_SAVE_EXECUTED_SCRIPT | `--save-executed-script` | False | Save executed script |
53
+ | saved_script_folder | MDE_SAVED_SCRIPT_FOLDER | `--saved-script-folder` | `logs` | Saved script folder |
54
+ | select_page_height | MDE_SELECT_PAGE_HEIGHT | | `12` | Menu page height (maximum) |
55
+ | user_must_approve | MDE_USER_MUST_APPROVE | `--user-must-approve` | True | Pause to approve execution |
56
+
57
+ - Configuration options:
58
+
59
+ | YAML Name | Environment Variable | Default |
60
+ | :--- | :--- | :--- |
61
+ | block_name_excluded_match | MDE_BLOCK_NAME_EXCLUDED_MATCH | `^\(.+\)$` |
62
+ | block_name_match | MDE_BLOCK_NAME_MATCH | `:(?<title>\S+)( \|$)` |
63
+ | block_required_scan | MDE_BLOCK_REQUIRED_SCAN | `\+\S+` |
64
+ | fenced_start_and_end_match | MDE_FENCED_START_AND_END_MATCH | ``^`{3,}`` |
65
+ | fenced_start_ex_match | MDE_FENCED_START_EX_MATCH | ``^`{3,}(?<shell>[^`\s]*) *(?<name>.*)$`` |
66
+ | heading1_match | MDE_HEADING1_MATCH | `^# *(?<name>[^#]*?) *$` |
67
+ | heading2_match | MDE_HEADING2_MATCH | `^## *(?<name>[^#]*?) *$` |
68
+ | heading3_match | MDE_HEADING3_MATCH | `^### *(?<name>.+?) *$` |
69
+ | md_filename_glob | MDE_MD_FILENAME_GLOB | `*.[Mm][Dd]` |
70
+ | md_filename_match | MDE_MD_FILENAME_MATCH | `.+\\.md` |
71
+
72
+ Most options can be configured in multiple ways. In order of use (earliest superceded by last):
73
+ 1. environment variables
74
+ 2. the configuration file `.mde.yml` in the current folder
75
+ 3. command line arguments
76
+
77
+ #### Representing boolean values
78
+
79
+ Boolean values for options are specified as strings and interpreted as:
80
+ | Value | Boolean |
81
+ | :---: | :---: |
82
+ | *empty string* | False |
83
+ | `0` | False |
84
+ | `1` | True |
85
+ | *anything else* | True |
86
+
87
+ E.g. `opt1=1` will set option `opt1` to True.
88
+
89
+ Boolean options configured with environment variables:
90
+ - Set to `1` or non-empty value to save executed scripts; empty or `0` to disable saving.
91
+ e.g. `export MDE_SAVE_EXECUTED_SCRIPT=1`
92
+ e.g. `export MDE_SAVE_EXECUTED_SCRIPT=`
93
+ - Specify variable on command line.
94
+ e.g. `MDE_SAVE_EXECUTED_SCRIPT=1 mde`
95
+
96
+ ## [0.2.2] - 2022-03-17
97
+
98
+ - Update documentation.
99
+
100
+ ## [0.2.1] - 2022-03-12
101
+
102
+ - Accept file or folder as first optional positional argument.
103
+ - Hide blocks with parentheses in the name, like "(name)". This is useful for blocks that are to be required and not selected to execute alone.
2
104
 
3
105
  ## [0.2.0] - 2022-03-12
4
106
 
data/Gemfile CHANGED
@@ -10,3 +10,5 @@ gem 'rake', '~> 13.0'
10
10
  gem 'minitest', '~> 5.0'
11
11
 
12
12
  gem 'rubocop', '~> 1.21'
13
+ gem 'rubocop-minitest', require: false
14
+ gem 'rubocop-rake', require: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_exec (0.1.1)
4
+ markdown_exec (0.2.4)
5
5
  open3 (~> 0.1.1)
6
6
  optparse (~> 0.1.1)
7
7
  tty-prompt (~> 0.23.1)
@@ -34,6 +34,10 @@ GEM
34
34
  unicode-display_width (>= 1.4.0, < 3.0)
35
35
  rubocop-ast (1.16.0)
36
36
  parser (>= 3.1.1.0)
37
+ rubocop-minitest (0.18.0)
38
+ rubocop (>= 0.90, < 2.0)
39
+ rubocop-rake (0.6.0)
40
+ rubocop (~> 1.0)
37
41
  ruby-progressbar (1.11.0)
38
42
  tty-color (0.6.0)
39
43
  tty-cursor (0.7.1)
@@ -57,6 +61,8 @@ DEPENDENCIES
57
61
  minitest (~> 5.0)
58
62
  rake (~> 13.0)
59
63
  rubocop (~> 1.21)
64
+ rubocop-minitest
65
+ rubocop-rake
60
66
 
61
67
  BUNDLED WITH
62
68
  2.2.32
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MarkdownExec
2
2
 
3
- This gem allows you to interactively select and run code blocks in markdown files.
3
+ Interactively select and execute fenced code blocks in markdown files. Build complex scripts by naming and requiring blocks.
4
4
 
5
5
  * Code blocks may be named.
6
6
 
@@ -10,30 +10,47 @@ This gem allows you to interactively select and run code blocks in markdown file
10
10
 
11
11
  * The code is presented for approval prior to execution.
12
12
 
13
+ ## Screenshots
14
+
15
+ ### Select a file
16
+ ![Select a file](/assets/select_a_file.png)
17
+
18
+ ### Select a block
19
+ ![Select a block](/assets/select_a_block.png)
20
+
21
+ ### Approve code
22
+ ![Approve code](/assets/approve_code.png)
23
+
24
+ ### Output
25
+ ![Output of execution](/assets/output_of_execution.png)
26
+
27
+ ### Example blocks
28
+ ![Example blocks](/assets/example_blocks.png)
29
+
13
30
  ## Installation
14
31
 
15
32
  Install:
16
-
17
33
  $ gem install markdown_exec
18
34
 
19
35
  ## Usage
20
36
 
21
- `mde --help`
37
+ ### `mde --help`
22
38
  Displays help information.
23
39
 
24
- `mde`
40
+ ### `mde`
25
41
  Process `README.md` file in the current folder. Displays all the blocks in the file and allows you to select using [up], [down], and [return]. Press [ctrl]-c to abort selection.
26
42
 
27
- `mde -f my.md`
43
+ ### `mde my.md` or `mde -f my.md`
28
44
  Select a block to execute from `my.md`.
29
45
 
30
- `mde -p .`
46
+ ### `mde .` or `mde -p .`
47
+
31
48
  Select a markdown file in the current folder. Select a block to execute from that file.
32
49
 
33
- `mde --list-blocks`
50
+ ### `mde --list-blocks`
34
51
  List all blocks in the all the markdown documents in the current folder.
35
52
 
36
- `mde --list-docs`
53
+ ### `mde --list-docs`
37
54
  List all markdown documents in the current folder.
38
55
 
39
56
  ## Behavior
@@ -42,7 +59,6 @@ List all markdown documents in the current folder.
42
59
  * If a folder is specified, its files are presented. When a file is selected, its blocks are presented.
43
60
 
44
61
  ## Configuration
45
-
46
62
  While starting up, reads the YAML configuration file `.mde.yml` in the current folder if it exists.
47
63
 
48
64
  e.g. Use to set the default file for the current folder.
@@ -51,49 +67,28 @@ e.g. Use to set the default file for the current folder.
51
67
  * `folder: documents` sets the folder to search for default or specified files.
52
68
 
53
69
  # Example blocks
54
-
55
- When prompted, select either the `awake` or `asleep` block. The standard output confirms which required were blocks were included. Naming "hidden" blocks with parentheses "(" and ")" is a convention used here to re-inforce the purpose of the named blocks.
70
+ When prompted, select either the `awake` or `asleep` block.
56
71
 
57
72
  ``` :(day)
58
- # block named "(day)", required by other blocks
59
- export MYTIME=early
73
+ export TIME=early
60
74
  ```
61
75
 
62
76
  ``` :(night)
63
- # block named "(night)", required by other blocks
64
- export MYTIME=late
77
+ export TIME=late
65
78
  ```
66
79
 
67
80
  ``` :awake +(day) +(report)
68
- # block named "awake", select to see result
69
81
  export ACTIVITY=awake
70
82
  ```
71
83
 
72
84
  ``` :asleep +(night) +(report)
73
- # block named "asleep", select to see result
74
85
  export ACTIVITY=asleep
75
86
  ```
76
87
 
77
88
  ``` :(report)
78
- # block named "(report)", required by other blocks
79
- echo "time: $MYTIME, activity: $ACTIVITY"
89
+ echo "$TIME -> $ACTIVITY"
80
90
  ```
81
91
 
82
- ## Example blocks
83
- ![Sample blocks](/assets/blocks.png)
84
-
85
- ## Selecting a file
86
- ![Selecting a file](/assets/select_file.png)
87
-
88
- ## Selecting a block
89
- ![Selecting a block](/assets/select.png)
90
-
91
- ## Approving code
92
- ![Approving code](/assets/approve.png)
93
-
94
- ## Output
95
- ![Output of execution](/assets/executed.png)
96
-
97
92
  # License
98
93
 
99
94
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -3,38 +3,50 @@
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rake/testtask'
5
5
 
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << 'test'
8
- t.libs << 'lib'
9
- t.test_files = FileList['test/**/*_test.rb']
6
+ Rake::TestTask.new(:test) do |task|
7
+ task.libs << 'test'
8
+ task.libs << 'lib'
9
+ task.test_files = FileList['test/**/*_test.rb']
10
10
  end
11
11
 
12
12
  require 'rubocop/rake_task'
13
13
 
14
- RuboCop::RakeTask.new
14
+ RuboCop::RakeTask.new do |task|
15
+ # task.requires << 'rubocop-minitest'
16
+ end
17
+
18
+ desc 'named task because minitest not included in rubocop tests'
19
+ task :rubocopminitest do
20
+ `rubocop --require rubocop-minitest`
21
+ end
15
22
 
16
23
  require_relative 'lib/markdown_exec/version'
17
24
 
18
- task default: %i[test rubocop]
25
+ task default: %i[test rubocop rubocopminitest]
19
26
 
20
27
  # task :default => :build
21
28
 
29
+ desc 'gem build'
22
30
  task :build do
23
31
  system "gem build #{MarkdownExec::GEM_NAME}.gemspec"
24
32
  end
25
33
 
34
+ desc 'gem install'
26
35
  task install: :build do
27
36
  system "gem install #{MarkdownExec::GEM_NAME}-#{MarkdownExec::VERSION}.gem"
28
37
  end
29
38
 
39
+ desc 'gem publish'
30
40
  task publish: :build do
31
41
  system "gem push #{MarkdownExec::GEM_NAME}-#{MarkdownExec::VERSION}.gem"
32
42
  end
33
43
 
44
+ desc 'gem uninstall'
34
45
  task uninstall: :build do
35
46
  system "gem uninstall #{MarkdownExec::GEM_NAME}"
36
47
  end
37
48
 
49
+ desc 'gem build clean'
38
50
  task :clean do
39
51
  system 'rm *.gem'
40
52
  end
Binary file
Binary file
Binary file
Binary file
Binary file
data/fixtures/bash1.md ADDED
@@ -0,0 +1,12 @@
1
+ ``` :one
2
+ a
3
+ ```
4
+ ```bash :two +one
5
+ b
6
+ ```
7
+ ```bash :three +two +one
8
+ c
9
+ ```
10
+ ```bash :four +three
11
+ d
12
+ ```
data/fixtures/bash2.md ADDED
@@ -0,0 +1,15 @@
1
+ ``` :one
2
+ a
3
+ ```
4
+ ``` :two +one
5
+ b
6
+ ```
7
+ ``` :three +two
8
+ c
9
+ ```
10
+ ``` :four
11
+ d
12
+ ```
13
+ ``` :five +four +one
14
+ e
15
+ ```
@@ -0,0 +1,6 @@
1
+ ``` :one
2
+ a
3
+ ```
4
+ ```expect
5
+ b
6
+ ```
@@ -0,0 +1,9 @@
1
+ ``` :one
2
+ a
3
+ ```
4
+ ``` :(two)
5
+ b
6
+ ```
7
+ ``` :three
8
+ c
9
+ ```
data/fixtures/exec1.md ADDED
@@ -0,0 +1,8 @@
1
+ ```bash ls
2
+ ls
3
+ ```
4
+
5
+ ```bash two-three
6
+ echo "TWO"
7
+ echo "THREE"
8
+ ```
@@ -0,0 +1,19 @@
1
+ ``` :one
2
+ a
3
+ ```
4
+ # h1
5
+ ``` :two
6
+ b
7
+ ```
8
+ ## h2
9
+ ``` :three
10
+ c
11
+ ```
12
+ ### h3
13
+ ``` :four
14
+ d
15
+ ```
16
+ ### h4
17
+ ``` :five
18
+ e
19
+ ```
@@ -0,0 +1,9 @@
1
+ #
2
+ ##
3
+ ``` one
4
+ a
5
+ ```
6
+
7
+ ```bash two
8
+ b
9
+ ```
@@ -0,0 +1,6 @@
1
+ ```
2
+ no name
3
+ ```
4
+ ``` :name1
5
+ with name
6
+ ```
@@ -4,5 +4,5 @@ module MarkdownExec
4
4
  APP_NAME = 'MDE'
5
5
  APP_DESC = 'Markdown block executor'
6
6
  GEM_NAME = 'markdown_exec'
7
- VERSION = '0.2.0'
7
+ VERSION = '0.2.4'
8
8
  end