markdown_exec 0.2.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +73 -11
- data/Gemfile +6 -5
- data/Gemfile.lock +13 -1
- data/README.md +56 -12
- data/Rakefile +35 -1
- data/assets/approve_code.png +0 -0
- data/assets/output_of_execution.png +0 -0
- data/assets/select_a_block.png +0 -0
- data/assets/select_a_file.png +0 -0
- data/bin/tab_completion.sh +143 -0
- data/bin/tab_completion.sh.erb +85 -0
- data/lib/markdown_exec/version.rb +3 -2
- data/lib/markdown_exec.rb +695 -275
- data/lib/shared.rb +121 -0
- metadata +20 -10
- data/fixtures/bash1.md +0 -12
- data/fixtures/bash2.md +0 -15
- data/fixtures/exclude1.md +0 -6
- data/fixtures/exclude2.md +0 -9
- data/fixtures/exec1.md +0 -8
- data/fixtures/heading1.md +0 -19
- data/fixtures/sample1.md +0 -9
- data/fixtures/title1.md +0 -6
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,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown_exec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
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-
|
11
|
+
date: 2022-05-21 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
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: open3
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,6 +87,7 @@ email:
|
|
73
87
|
- fareed@phomento.com
|
74
88
|
executables:
|
75
89
|
- mde
|
90
|
+
- tab_completion.sh
|
76
91
|
extensions: []
|
77
92
|
extra_rdoc_files: []
|
78
93
|
files:
|
@@ -92,16 +107,11 @@ files:
|
|
92
107
|
- bin/console
|
93
108
|
- bin/mde
|
94
109
|
- bin/setup
|
95
|
-
-
|
96
|
-
-
|
97
|
-
- fixtures/exclude1.md
|
98
|
-
- fixtures/exclude2.md
|
99
|
-
- fixtures/exec1.md
|
100
|
-
- fixtures/heading1.md
|
101
|
-
- fixtures/sample1.md
|
102
|
-
- fixtures/title1.md
|
110
|
+
- bin/tab_completion.sh
|
111
|
+
- bin/tab_completion.sh.erb
|
103
112
|
- lib/markdown_exec.rb
|
104
113
|
- lib/markdown_exec/version.rb
|
114
|
+
- lib/shared.rb
|
105
115
|
homepage: https://rubygems.org/gems/markdown_exec
|
106
116
|
licenses:
|
107
117
|
- MIT
|
data/fixtures/bash1.md
DELETED
data/fixtures/bash2.md
DELETED
data/fixtures/exclude1.md
DELETED
data/fixtures/exclude2.md
DELETED
data/fixtures/exec1.md
DELETED
data/fixtures/heading1.md
DELETED
data/fixtures/sample1.md
DELETED