markdown_exec 0.2.6 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/shared.rb ADDED
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+
3
+ # encoding=utf-8
4
+
5
+ require 'shellwords'
6
+ require 'yaml'
7
+
8
+ # │0 │ to restore default │
9
+ # │ │ color │
10
+ # ├───┼───────────────────────┤
11
+ # │ │ │
12
+ # │1 │ for brighter colors │
13
+ # ├───┼───────────────────────┤
14
+ # │ │ │
15
+ # │4 │ for underlined text │
16
+ # ├───┼───────────────────────┤
17
+ # │ │ │
18
+ # │5 │ for flashing text
19
+ class String
20
+ def black
21
+ "\033[30m#{self}\033[0m"
22
+ end
23
+
24
+ def red
25
+ "\033[31m#{self}\033[0m"
26
+ end
27
+
28
+ def bred
29
+ "\033[1;31m#{self}\033[0m"
30
+ end
31
+
32
+ def green
33
+ "\033[32m#{self}\033[0m"
34
+ end
35
+
36
+ def bgreen
37
+ "\033[1;32m#{self}\033[0m"
38
+ end
39
+
40
+ def yellow
41
+ "\033[33m#{self}\033[0m"
42
+ end
43
+
44
+ def byellow
45
+ "\033[1;33m#{self}\033[0m"
46
+ end
47
+
48
+ def blue
49
+ "\033[34m#{self}\033[0m"
50
+ end
51
+
52
+ def magenta
53
+ "\033[35m#{self}\033[0m"
54
+ end
55
+
56
+ def cyan
57
+ "\033[36m#{self}\033[0m"
58
+ end
59
+
60
+ def white
61
+ "\033[37m#{self}\033[0m"
62
+ end
63
+
64
+ def bwhite
65
+ "\033[1;37m#{self}\033[0m"
66
+ end
67
+ end
68
+
69
+ public
70
+
71
+ def env_bool(name, default: false)
72
+ return default if name.nil? || (val = ENV[name]).nil?
73
+ return false if val.empty? || val == '0'
74
+
75
+ true
76
+ end
77
+
78
+ def env_int(name, default: 0)
79
+ return default if name.nil? || (val = ENV[name]).nil?
80
+ return default if val.empty?
81
+
82
+ val.to_i
83
+ end
84
+
85
+ def env_str(name, default: '')
86
+ return default if name.nil? || (val = ENV[name]).nil?
87
+
88
+ val || default
89
+ end
90
+
91
+ # debug output
92
+ #
93
+ def tap_inspect(format: nil, name: 'return')
94
+ return self unless $pdebug
95
+
96
+ cvt = {
97
+ json: :to_json,
98
+ string: :to_s,
99
+ yaml: :to_yaml,
100
+ else: :inspect
101
+ }
102
+ fn = cvt.fetch(format, cvt[:else])
103
+
104
+ puts "-> #{caller[0].scan(/in `?(\S+)'$/)[0][0]}()" \
105
+ " #{name}: #{method(fn).call}"
106
+
107
+ self
108
+ end
109
+
110
+ def value_for_cli(value)
111
+ case value.class.to_s
112
+ when 'String'
113
+ Shellwords.escape value
114
+ when 'FalseClass', 'TrueClass'
115
+ value ? '1' : '0'
116
+ else
117
+ Shellwords.escape value.to_s
118
+ end
119
+ end
120
+
121
+ $pdebug = env_bool 'MDE_DEBUG'
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown_exec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fareed Stevenson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-07 00:00:00.000000000 Z
11
+ date: 2022-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: clipboard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.3.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.3.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: mrdialog
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.3
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: open3
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -73,6 +101,7 @@ email:
73
101
  - fareed@phomento.com
74
102
  executables:
75
103
  - mde
104
+ - tab_completion.sh
76
105
  extensions: []
77
106
  extra_rdoc_files: []
78
107
  files:
@@ -92,16 +121,11 @@ files:
92
121
  - bin/console
93
122
  - bin/mde
94
123
  - bin/setup
95
- - fixtures/bash1.md
96
- - fixtures/bash2.md
97
- - fixtures/exclude1.md
98
- - fixtures/exclude2.md
99
- - fixtures/exec1.md
100
- - fixtures/heading1.md
101
- - fixtures/sample1.md
102
- - fixtures/title1.md
124
+ - bin/tab_completion.sh
125
+ - bin/tab_completion.sh.erb
103
126
  - lib/markdown_exec.rb
104
127
  - lib/markdown_exec/version.rb
128
+ - lib/shared.rb
105
129
  homepage: https://rubygems.org/gems/markdown_exec
106
130
  licenses:
107
131
  - MIT
@@ -110,7 +134,14 @@ metadata:
110
134
  homepage_uri: https://rubygems.org/gems/markdown_exec
111
135
  rubygems_mfa_required: 'true'
112
136
  source_code_uri: https://github.com/fareedst/markdown_exec
113
- post_install_message:
137
+ post_install_message: |2+
138
+
139
+ To install tab completion:
140
+ - Append a command to load the completion script to your shell configuration file.
141
+ - This gem must be installed and executable for the command to be composed correctly.
142
+
143
+ echo "source $(mde --pwd)/bin/tab_completion.sh" >> ~/.bash_profile
144
+
114
145
  rdoc_options: []
115
146
  require_paths:
116
147
  - lib
@@ -130,3 +161,4 @@ signing_key:
130
161
  specification_version: 4
131
162
  summary: Interactively select and execute fenced code blocks in markdown files.
132
163
  test_files: []
164
+ ...
data/fixtures/bash1.md DELETED
@@ -1,12 +0,0 @@
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 DELETED
@@ -1,15 +0,0 @@
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
- ```
data/fixtures/exclude1.md DELETED
@@ -1,6 +0,0 @@
1
- ``` :one
2
- a
3
- ```
4
- ```expect
5
- b
6
- ```
data/fixtures/exclude2.md DELETED
@@ -1,9 +0,0 @@
1
- ``` :one
2
- a
3
- ```
4
- ``` :(two)
5
- b
6
- ```
7
- ``` :three
8
- c
9
- ```
data/fixtures/exec1.md DELETED
@@ -1,8 +0,0 @@
1
- ```bash ls
2
- ls
3
- ```
4
-
5
- ```bash two-three
6
- echo "TWO"
7
- echo "THREE"
8
- ```
data/fixtures/heading1.md DELETED
@@ -1,19 +0,0 @@
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
- ```
data/fixtures/sample1.md DELETED
@@ -1,9 +0,0 @@
1
- #
2
- ##
3
- ``` one
4
- a
5
- ```
6
-
7
- ```bash two
8
- b
9
- ```
data/fixtures/title1.md DELETED
@@ -1,6 +0,0 @@
1
- ```
2
- no name
3
- ```
4
- ``` :name1
5
- with name
6
- ```