markdown_exec 0.2.1 → 0.2.3

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: 7a2b550aaccca7d0752e57c39808f5d8d3b889b9d74cf3330dee6832b2f6c535
4
- data.tar.gz: 1296490dd79071f78b5009cb843c911fe822257ed148b4c1a516366eb02407ca
3
+ metadata.gz: 7ec074d1854ef0150cf60852fd39d7db7bc88461f7d9f5ae6547fe009142ffb4
4
+ data.tar.gz: 8d6eb3c7759bf180b996f8a68ec8b52d0e52a230365b163f06528e9c11627e42
5
5
  SHA512:
6
- metadata.gz: 43f659be4397e4bb24811a8219de7b58e9665aa8751063281e2cfbbf94263ceda15f411a34fe31293869f0bbdba761c2afce72ea7f800b54edba75424313bd19
7
- data.tar.gz: bd48ac8a5ebedbc8b92af6345743d1bd6cf50705d05769e7144ccad998ddf0f00de72366779cb654a4272c3cc2f044c4c7e46ae9df935dcb4fc486a67e54453e
6
+ metadata.gz: '095584193734695c29729060ca4ccd424088ca59cdd8bf539dda5a6b914d7fd71d373304f071e46b49072bf01b09ae2a1f0cf86bf314f3d79ace9acd166a3531'
7
+ data.tar.gz: c8e55fa064fe9bc8c170c9431dd1a5dc9fd3f20f1fe42925c00c4f2ed5113d597f457ecdba225cf4533563cd0c3f14f35ebc1ad096e8a89f8ec654a5cd87cd8c
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,5 +1,111 @@
1
+ # Changelog
2
+
3
+ ## [ToDo]
4
+
5
+ - pipe stdin to script
6
+ - yes/no/write/clipboard/record/edit/history
7
+ - add confirm block to generated file
8
+ - present timestamp, result of last exec for each command
9
+ - user settings
10
+ - hidden w , w/o () in names
11
+ - exit in menus
12
+ - fix regexp in pathnames
13
+ - tab completion from md file
14
+ - read file once to allow for tempdoc stream
15
+ - include md or blocks file
16
+
17
+ - tree display
18
+
19
+ - mde options in md file or included file
20
+
21
+ - include blocks from local md file
22
+
23
+ - save outputs, errors
24
+
25
+ - chmod a+x logged script
26
+
27
+ - exec most recent logged scripts
28
+
29
+ - cmd to list last n
30
+ - cmd to repeat last
31
+
1
32
  ## [Unreleased]
2
33
 
34
+ ## [0.2.3] - 2022-03
35
+
36
+ ### Added
37
+
38
+ - `rubocop` checks.
39
+ - Added optional command-line positional arguments:
40
+ 1. document file
41
+ 2. block name
42
+
43
+ e.g. `mde doc1 block1` will execute the block named `block1` in file `doc1`.
44
+
45
+ ### Changed
46
+
47
+ - Naming saved script files: The file name contains the time stamp, document name, and block name.
48
+
49
+ - Renamed folder with fixtures.
50
+
51
+ - Command options:
52
+
53
+ | YAML Name | Environment Variable | Option Name | Default | Purpose |
54
+ | :--- | :--- | :--- | :--- | :--- |
55
+ | debug | MDE_DEBUG | `--debug` | False | Output debugging information (verbose) |
56
+ | filename | MDE_FILENAME | `--filename` | `README.md`* | File name of document |
57
+ | output_execution_summary | MDE_OUTPUT_STDOUT_SUMMARY | `--output-execution-summary` | False | Display summary for execution |
58
+ | output_script | MDE_OUTPUT_SCRIPT | `--output-script` | False | Display script |
59
+ | output_stdout | MDE_OUTPUT_EXECUTION | `--output-stdout` | True | Display standard output from execution |
60
+ | path | MDE_PATH | `--path` | `.` | Path to document(s) |
61
+ | save_executed_script | MDE_SAVE_EXECUTED_SCRIPT | `--save-executed-script` | False | Save executed script |
62
+ | saved_script_folder | MDE_SAVED_SCRIPT_FOLDER | `--saved-script-folder` | `logs` | Saved script folder |
63
+ | select_page_height | MDE_SELECT_PAGE_HEIGHT | | `12` | Menu page height (maximum) |
64
+ | user_must_approve | MDE_USER_MUST_APPROVE | `--user-must-approve` | True | Pause to approve execution |
65
+
66
+ - Configuration options:
67
+
68
+ | YAML Name | Environment Variable | Default |
69
+ | :--- | :--- | :--- |
70
+ | block_name_excluded_match | MDE_BLOCK_NAME_EXCLUDED_MATCH | `^\(.+\)$` |
71
+ | block_name_match | MDE_BLOCK_NAME_MATCH | `:(?<title>\S+)( \|$)` |
72
+ | block_required_scan | MDE_BLOCK_REQUIRED_SCAN | `\+\S+` |
73
+ | fenced_start_and_end_match | MDE_FENCED_START_AND_END_MATCH | `^\`{3,}` |
74
+ | fenced_start_ex_match | MDE_FENCED_START_EX_MATCH | `^\`{3,}(?<shell>[^\`\s]*) *(?<name>.*)$` |
75
+ | heading1_match | MDE_HEADING1_MATCH | `^# *(?<name>[^#]*?) *$` |
76
+ | heading2_match | MDE_HEADING2_MATCH | `^## *(?<name>[^#]*?) *$` |
77
+ | heading3_match | MDE_HEADING3_MATCH | `^### *(?<name>.+?) *$` |
78
+ | md_filename_glob | MDE_MD_FILENAME_GLOB | `*.[Mm][Dd]` |
79
+ | md_filename_match | MDE_MD_FILENAME_MATCH | `.+\\.md` |
80
+
81
+ Most options can be configured in multiple ways. In order of use (earliest superceded by last):
82
+ 1. environment variables
83
+ 2. the configuration file `.mde.yml` in the current folder
84
+ 3. command line arguments
85
+
86
+ #### Representing boolean values
87
+
88
+ Boolean values for options are specified as strings and interpreted as:
89
+ | Value | Boolean |
90
+ | :---: | :---: |
91
+ | *empty string* | False |
92
+ | `0` | False |
93
+ | `1` | True |
94
+ | *anything else* | True |
95
+
96
+ E.g. `opt1=1` will set option `opt1` to True.
97
+
98
+ Boolean options configured with environment variables:
99
+ - Set to `1` or non-empty value to save executed scripts; empty or `0` to disable saving.
100
+ e.g. `export MDE_SAVE_EXECUTED_SCRIPT=1`
101
+ e.g. `export MDE_SAVE_EXECUTED_SCRIPT=`
102
+ - Specify variable on command line.
103
+ e.g. `MDE_SAVE_EXECUTED_SCRIPT=1 mde`
104
+
105
+ ## [0.2.2] - 2022-03-17
106
+
107
+ - Update documentation.
108
+
3
109
  ## [0.2.1] - 2022-03-12
4
110
 
5
111
  - Accept file or folder as first optional positional argument.
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.3)
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,32 +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`
28
- `mde my.md`
43
+ ### `mde my.md` or `mde -f my.md`
29
44
  Select a block to execute from `my.md`.
30
45
 
31
- `mde -p .`
32
- `mde .`
46
+ ### `mde .` or `mde -p .`
47
+
33
48
  Select a markdown file in the current folder. Select a block to execute from that file.
34
49
 
35
- `mde --list-blocks`
50
+ ### `mde --list-blocks`
36
51
  List all blocks in the all the markdown documents in the current folder.
37
52
 
38
- `mde --list-docs`
53
+ ### `mde --list-docs`
39
54
  List all markdown documents in the current folder.
40
55
 
41
56
  ## Behavior
@@ -44,7 +59,6 @@ List all markdown documents in the current folder.
44
59
  * If a folder is specified, its files are presented. When a file is selected, its blocks are presented.
45
60
 
46
61
  ## Configuration
47
-
48
62
  While starting up, reads the YAML configuration file `.mde.yml` in the current folder if it exists.
49
63
 
50
64
  e.g. Use to set the default file for the current folder.
@@ -53,7 +67,6 @@ e.g. Use to set the default file for the current folder.
53
67
  * `folder: documents` sets the folder to search for default or specified files.
54
68
 
55
69
  # Example blocks
56
-
57
70
  When prompted, select either the `awake` or `asleep` block.
58
71
 
59
72
  ``` :(day)
@@ -76,21 +89,6 @@ export ACTIVITY=asleep
76
89
  echo "$TIME -> $ACTIVITY"
77
90
  ```
78
91
 
79
- ## Example blocks
80
- ![Sample blocks](/assets/blocks.png)
81
-
82
- ## Selecting a file
83
- ![Selecting a file](/assets/select_file.png)
84
-
85
- ## Selecting a block
86
- ![Selecting a block](/assets/select.png)
87
-
88
- ## Approving code
89
- ![Approving code](/assets/approve.png)
90
-
91
- ## Output
92
- ![Output of execution](/assets/executed.png)
93
-
94
92
  # License
95
93
 
96
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.1'
7
+ VERSION = '0.2.3'
8
8
  end