markdown_exec 2.5.0 → 2.6.0
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 +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +2 -2
- data/Rakefile +3 -3
- data/bats/block-types.bats +13 -7
- data/bats/import.bats +6 -0
- data/bats/markup.bats +6 -15
- data/bats/options-collapse.bats +26 -0
- data/bats/options.bats +1 -1
- data/bats/table.bats +8 -0
- data/bats/test_helper.bash +74 -49
- data/bats/variable-expansion.bats +46 -0
- data/bin/tab_completion.sh +1 -1
- data/docs/dev/bats-document-configuration.md +8 -1
- data/docs/dev/block-type-bash.md +1 -1
- data/docs/dev/block-type-opts.md +1 -5
- data/docs/dev/block-type-vars.md +4 -0
- data/docs/dev/import-missing.md +2 -0
- data/docs/dev/menu-cli.md +1 -1
- data/docs/dev/options-collapse.md +47 -0
- data/docs/dev/requiring-blocks.md +3 -0
- data/docs/dev/specs.md +2 -1
- data/docs/dev/table-crash.md +39 -0
- data/docs/dev/table-indent.md +26 -0
- data/docs/dev/text-decoration.md +2 -5
- data/docs/dev/variable-expansion.md +2 -4
- data/examples/bash-blocks.md +1 -1
- data/examples/block-names.md +1 -1
- data/examples/block-types.md +1 -1
- data/examples/data-files.md +1 -1
- data/examples/document_options.md +2 -2
- data/examples/indent.md +1 -1
- data/examples/interrupt.md +1 -1
- data/examples/link-blocks-vars.md +1 -1
- data/examples/linked.md +1 -1
- data/examples/linked1.md +1 -1
- data/examples/nickname.md +1 -1
- data/examples/opts-blocks-require.md +1 -1
- data/examples/opts-blocks.md +1 -1
- data/examples/opts_output_execution.md +1 -1
- data/examples/pass-through-arguments.md +1 -1
- data/examples/pause-after-execution.md +1 -1
- data/examples/port-blocks.md +1 -1
- data/examples/save.md +1 -1
- data/examples/text-markup.md +1 -1
- data/examples/variable-expansion.md +6 -2
- data/examples/vars-blocks.md +1 -1
- data/examples/wrap.md +1 -1
- data/lib/block_types.rb +4 -0
- data/lib/cached_nested_file_reader.rb +7 -4
- data/lib/collapser.rb +302 -0
- data/lib/constants.rb +10 -0
- data/lib/evaluate_shell_expressions.rb +0 -3
- data/lib/fcb.rb +13 -17
- data/lib/format_table.rb +11 -7
- data/lib/hash_delegator.rb +461 -272
- data/lib/hierarchy_string.rb +5 -1
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +16 -32
- data/lib/mdoc.rb +100 -35
- data/lib/menu.src.yml +124 -17
- data/lib/menu.yml +102 -16
- data/lib/ww.rb +75 -22
- metadata +12 -9
- data/lib/append_to_bash_history.rb +0 -303
- data/lib/ce_get_cost_and_usage.rb +0 -23
- data/lib/doh.rb +0 -190
- data/lib/layered_hash.rb +0 -143
- data/lib/poly.rb +0 -171
data/lib/poly.rb
DELETED
@@ -1,171 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# encoding=utf-8
|
5
|
-
|
6
|
-
$pd = false
|
7
|
-
|
8
|
-
class Poly
|
9
|
-
# attr_reader :table
|
10
|
-
def initialize(table = {})
|
11
|
-
@table = table.tap { |ret|
|
12
|
-
pp [__LINE__, 'Poly.initialize()', 'table', table.to_yaml] if $pd
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
def fetch(key, *args)
|
17
|
-
key_sym = key.to_sym
|
18
|
-
if respond_to?("get_#{key}")
|
19
|
-
send("get_#{key}")
|
20
|
-
elsif @table.key?(key_sym)
|
21
|
-
@table[key_sym]
|
22
|
-
elsif block_given?
|
23
|
-
yield key_sym
|
24
|
-
elsif args.count.positive?
|
25
|
-
# binding.irb
|
26
|
-
args.first
|
27
|
-
else
|
28
|
-
binding.irb
|
29
|
-
raise KeyError, "key not found: #{key}"
|
30
|
-
end.tap { |ret|
|
31
|
-
pp([__LINE__, "Poly.fetch #{key} #{args}", '->',
|
32
|
-
ret]) if $pd
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
def key?(name)
|
37
|
-
@table.key?(name.to_sym).tap { |ret|
|
38
|
-
pp([__LINE__, "Poly.key? #{name}", '->', ret]) if $pd
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
|
-
def method_missing(name, *args)
|
43
|
-
pt = nil
|
44
|
-
if name.to_s.end_with?('=')
|
45
|
-
# Setter method
|
46
|
-
attribute = name.to_s.chomp('=').to_sym
|
47
|
-
value = args.first
|
48
|
-
if respond_to?("set_#{attribute}")
|
49
|
-
pt = 'send set_'
|
50
|
-
send("set_#{attribute}", value)
|
51
|
-
else
|
52
|
-
pt = 'table set'
|
53
|
-
@table[attribute] = value
|
54
|
-
end
|
55
|
-
elsif respond_to?("get_#{name}")
|
56
|
-
pt = 'send get_'
|
57
|
-
# Getter method
|
58
|
-
send("get_#{name}")
|
59
|
-
elsif @table.respond_to?(name)
|
60
|
-
pt = 'send name'
|
61
|
-
@table.send(name, *args)
|
62
|
-
else
|
63
|
-
pt = 'table read'
|
64
|
-
@table[name.to_sym]
|
65
|
-
end.tap { |ret|
|
66
|
-
pp([__LINE__,
|
67
|
-
"Poly.method_missing #{name} #{args.map(&:to_s).join(' ')}", pt, '->', ret]) if $pd
|
68
|
-
}
|
69
|
-
end
|
70
|
-
|
71
|
-
def respond_to_missing?(name, include_private = false)
|
72
|
-
# name.to_s.end_with?('=') || @table.key?(name.to_sym) || @table.respond_to?(name) || super
|
73
|
-
(name.to_s.end_with?('=') || @table.key?(name.to_sym) || @table.respond_to?(name) || super).tap { |ret|
|
74
|
-
pp([__LINE__, "Poly.respond_to_missing? #{name}", '->', ret]) if $pd
|
75
|
-
}
|
76
|
-
end
|
77
|
-
|
78
|
-
def [](key)
|
79
|
-
if respond_to?("get_#{key}")
|
80
|
-
send("get_#{key}")
|
81
|
-
else
|
82
|
-
@table[key.to_sym]
|
83
|
-
end.tap { |ret| pp([__LINE__, "Poly.[] #{key}", '->', ret]) if $pd }
|
84
|
-
end
|
85
|
-
|
86
|
-
def []=(key, value)
|
87
|
-
if respond_to?("set_#{key}")
|
88
|
-
send("set_#{key}", value)
|
89
|
-
else
|
90
|
-
@table[key.to_sym] = value
|
91
|
-
end.tap { |ret|
|
92
|
-
pp([__LINE__, "Poly.[]= #{key} #{value}", '->',
|
93
|
-
ret]) if $pd
|
94
|
-
}
|
95
|
-
end
|
96
|
-
|
97
|
-
# for export to Prompt library
|
98
|
-
# def merge(*args)
|
99
|
-
# Proc.new { |x| @table.merge x }
|
100
|
-
# end
|
101
|
-
def merge(*args)
|
102
|
-
# pp caller
|
103
|
-
# binding.irb
|
104
|
-
@table.merge(*args).tap { |ret|
|
105
|
-
pp([__LINE__, "Poly.merge", '->', ret]) if $pd
|
106
|
-
}
|
107
|
-
end
|
108
|
-
|
109
|
-
# for export to Prompt library
|
110
|
-
def to_h
|
111
|
-
@table.tap { |ret| pp([__LINE__, "Poly.to_h", '->', ret]) if $pd }
|
112
|
-
end
|
113
|
-
|
114
|
-
def to_yaml
|
115
|
-
@table.to_yaml.tap { |ret|
|
116
|
-
pp([__LINE__, "Poly.to_yaml", '->', ret]) if $pd
|
117
|
-
}
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
# class CustomStruct < Poly
|
122
|
-
# # Custom setter for virtual attribute :full_name
|
123
|
-
# def set_full_name(value)
|
124
|
-
# names = value.split(' ')
|
125
|
-
# @table[:first_name] = names.first
|
126
|
-
# @table[:last_name] = names.last
|
127
|
-
# end
|
128
|
-
|
129
|
-
# # Custom getter for virtual attribute :full_name
|
130
|
-
# def get_full_name
|
131
|
-
# "#{@table[:first_name]} #{@table[:last_name]}"
|
132
|
-
# end
|
133
|
-
# end
|
134
|
-
|
135
|
-
# # Example usage
|
136
|
-
# person = CustomStruct.new
|
137
|
-
# person.first_name = 'John'
|
138
|
-
# person.last_name = 'Doe'
|
139
|
-
# puts person.first_name # => John
|
140
|
-
# puts person.last_name # => Doe
|
141
|
-
|
142
|
-
# # Setting and getting a virtual attribute
|
143
|
-
# person.full_name = 'Jane Smith'
|
144
|
-
# puts person.first_name # => Jane
|
145
|
-
# puts person.last_name # => Smith
|
146
|
-
# puts person.full_name # => Jane Smith
|
147
|
-
|
148
|
-
# # Setting and getting a regular attribute
|
149
|
-
# person.age = 30
|
150
|
-
# puts person.age # => 30
|
151
|
-
|
152
|
-
# # Using array notation
|
153
|
-
# person[:age] = 35
|
154
|
-
# puts person[:age] # => 35
|
155
|
-
|
156
|
-
# person[:full_name] = 'Alice Johnson'
|
157
|
-
# puts person[:first_name] # => Alice
|
158
|
-
# puts person[:last_name] # => Johnson
|
159
|
-
# puts person[:full_name] # => Alice Johnson
|
160
|
-
|
161
|
-
# # Using fetch method
|
162
|
-
# puts person.fetch(:age) # => 35
|
163
|
-
# puts person.fetch(:nonexistent, 'default') # => default
|
164
|
-
# puts person.fetch(:nonexistent) { |key| "block default for #{key}" } # => block default for nonexistent
|
165
|
-
|
166
|
-
# # This will raise a KeyError
|
167
|
-
# begin
|
168
|
-
# person.fetch(:nonexistent)
|
169
|
-
# rescue KeyError => e
|
170
|
-
# puts e.message # => key not found: nonexistent
|
171
|
-
# end
|