markdown_exec 2.8.3 → 2.8.5
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 +41 -0
- data/Gemfile.lock +1 -1
- data/Rakefile +33 -23
- data/bats/{block-types.bats → block-type-bash.bats} +0 -25
- data/bats/block-type-link.bats +9 -0
- data/bats/block-type-port.bats +16 -0
- data/bats/block-type-ux-allowed.bats +29 -0
- data/bats/block-type-ux-auto.bats +1 -1
- data/bats/block-type-ux-chained.bats +9 -0
- data/bats/block-type-ux-default.bats +8 -0
- data/bats/block-type-ux-echo-hash.bats +14 -0
- data/bats/block-type-ux-echo.bats +2 -2
- data/bats/block-type-ux-exec.bats +1 -1
- data/bats/block-type-ux-hidden.bats +9 -0
- data/bats/block-type-ux-invalid.bats +8 -0
- data/bats/block-type-ux-transform.bats +1 -1
- data/bats/indented-block-type-vars.bats +9 -0
- data/bats/line-decor-dynamic.bats +1 -1
- data/bats/test_helper.bash +9 -2
- data/bats/variable-expansion-multiline.bats +8 -0
- data/bats/variable-expansion.bats +1 -1
- data/docs/dev/block-type-ux-allowed.md +82 -0
- data/docs/dev/block-type-ux-auto.md +2 -1
- data/docs/dev/block-type-ux-chained.md +21 -0
- data/docs/dev/block-type-ux-default.md +42 -0
- data/docs/dev/block-type-ux-echo-hash.md +78 -0
- data/docs/dev/block-type-ux-echo.md +3 -1
- data/docs/dev/block-type-ux-exec.md +1 -0
- data/docs/dev/block-type-ux-hidden.md +21 -0
- data/docs/dev/block-type-ux-invalid.md +5 -0
- data/docs/dev/block-type-ux-require.md +9 -18
- data/docs/dev/indented-block-type-vars.md +6 -0
- data/docs/dev/line-decor-dynamic.md +2 -1
- data/docs/dev/variable-expansion-multiline.md +31 -0
- data/lib/ansi_formatter.rb +0 -1
- data/lib/ansi_string.rb +1 -1
- data/lib/array.rb +0 -1
- data/lib/array_util.rb +0 -1
- data/lib/block_label.rb +1 -1
- data/lib/cached_nested_file_reader.rb +1 -1
- data/lib/constants.rb +18 -0
- data/lib/directory_searcher.rb +1 -1
- data/lib/exceptions.rb +0 -1
- data/lib/fcb.rb +52 -9
- data/lib/filter.rb +1 -2
- data/lib/format_table.rb +1 -0
- data/lib/fout.rb +1 -1
- data/lib/hash.rb +0 -1
- data/lib/hash_delegator.rb +404 -224
- data/lib/link_history.rb +17 -17
- data/lib/logged_struct.rb +429 -0
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +3 -3
- data/lib/mdoc.rb +21 -31
- data/lib/menu.src.yml +15 -7
- data/lib/menu.yml +11 -6
- data/lib/namer.rb +3 -6
- data/lib/null_result.rb +131 -0
- data/lib/object_present.rb +1 -1
- data/lib/option_value.rb +1 -1
- data/lib/resize_terminal.rb +1 -2
- data/lib/saved_assets.rb +1 -1
- data/lib/saved_files_matcher.rb +1 -1
- data/lib/shell_session.rb +439 -0
- data/lib/streams_out.rb +0 -1
- data/lib/string_util.rb +11 -1
- data/lib/success_result.rb +112 -0
- data/lib/text_analyzer.rb +1 -0
- data/lib/ww.rb +9 -7
- metadata +25 -3
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            / a UX block requires a shell block and another UX block
         | 
| 2 | 
            +
            ``` :(shell)
         | 
| 3 | 
            +
            ENTITY='Pongo tapanuliensis,Pongo'
         | 
| 4 | 
            +
            ```
         | 
| 5 | 
            +
            ```ux :[SPECIES] +(shell) +(GENUS)
         | 
| 6 | 
            +
            echo: "${ENTITY%%,*}"
         | 
| 7 | 
            +
            name: SPECIES
         | 
| 8 | 
            +
            ```
         | 
| 9 | 
            +
            / required ux block requires another
         | 
| 10 | 
            +
            ```ux :(GENUS) +[NAME]
         | 
| 11 | 
            +
            echo: "${ENTITY##*,}"
         | 
| 12 | 
            +
            name: GENUS
         | 
| 13 | 
            +
            readonly: true
         | 
| 14 | 
            +
            ```
         | 
| 15 | 
            +
            / executed in context of prior ux blocks, uses their values
         | 
| 16 | 
            +
            ```ux :[NAME]
         | 
| 17 | 
            +
            echo: "$SPECIES - $GENUS"
         | 
| 18 | 
            +
            name: NAME
         | 
| 19 | 
            +
            readonly: true
         | 
| 20 | 
            +
            ```
         | 
| 21 | 
            +
            @import bats-document-configuration.md
         | 
| @@ -1,32 +1,23 @@ | |
| 1 | 
            -
            / an  | 
| 1 | 
            +
            / This is an hidden shell block that is required by UX blocks.
         | 
| 2 2 | 
             
            ``` :(shell)
         | 
| 3 3 | 
             
            ENTITY='Pongo tapanuliensis,Pongo'
         | 
| 4 4 | 
             
            ```
         | 
| 5 | 
            -
            ```ux  | 
| 6 | 
            -
             | 
| 7 | 
            -
            exec: echo "${ENTITY%%,*}"
         | 
| 5 | 
            +
            ```ux +(shell)
         | 
| 6 | 
            +
            echo: "${ENTITY%%,*}"
         | 
| 8 7 | 
             
            name: SPECIES
         | 
| 9 | 
            -
            transform: :chomp
         | 
| 10 8 | 
             
            ```
         | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
            default: :exec
         | 
| 14 | 
            -
            exec: echo "${ENTITY##*,}"
         | 
| 9 | 
            +
            ```ux +(shell)
         | 
| 10 | 
            +
            echo: "${ENTITY##*,}"
         | 
| 15 11 | 
             
            name: GENUS
         | 
| 16 | 
            -
            transform: :chomp
         | 
| 17 12 | 
             
            ```
         | 
| 18 13 | 
             
            / executed in context of prior ux blocks, uses their initial values
         | 
| 19 | 
            -
            ```ux | 
| 20 | 
            -
             | 
| 21 | 
            -
            exec: echo "$SPECIES - $GENUS"
         | 
| 14 | 
            +
            ```ux
         | 
| 15 | 
            +
            echo: "$SPECIES - $GENUS"
         | 
| 22 16 | 
             
            name: NAME
         | 
| 23 | 
            -
            transform: :chomp
         | 
| 24 17 | 
             
            ```
         | 
| 25 18 | 
             
            / executed after other ux blocks, uses their initial values
         | 
| 26 | 
            -
            ```ux | 
| 27 | 
            -
             | 
| 28 | 
            -
            exec: echo "$NAME"
         | 
| 19 | 
            +
            ```ux
         | 
| 20 | 
            +
            echo: "$NAME"
         | 
| 29 21 | 
             
            name: NAME2
         | 
| 30 | 
            -
            transform: :chomp
         | 
| 31 22 | 
             
            ```
         | 
| 32 23 | 
             
            @import bats-document-configuration.md
         | 
| @@ -4,6 +4,7 @@ | |
| 4 4 | 
             
            @import bats-document-configuration.md
         | 
| 5 5 | 
             
            ```opts :(document_opts)
         | 
| 6 6 | 
             
            line_decor_pre:
         | 
| 7 | 
            -
               | 
| 7 | 
            +
              # bold italicized bright yellow text on light yellow background
         | 
| 8 | 
            +
              - :color_method: :ansi_1__3__38_2_200_200_33__48_2_60_60_32__22_23_0
         | 
| 8 9 | 
             
                :pattern: '%([^_]{0,64})%'
         | 
| 9 10 | 
             
            ```
         | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            / assign a multiline string
         | 
| 2 | 
            +
            ```vars :(document_vars)
         | 
| 3 | 
            +
            Genus2: |
         | 
| 4 | 
            +
              Pongo
         | 
| 5 | 
            +
              Pongo
         | 
| 6 | 
            +
            ```
         | 
| 7 | 
            +
            /
         | 
| 8 | 
            +
            / display the variable
         | 
| 9 | 
            +
            __UX block__:
         | 
| 10 | 
            +
            ```ux
         | 
| 11 | 
            +
            name: Genus2
         | 
| 12 | 
            +
            readonly: true
         | 
| 13 | 
            +
            ```
         | 
| 14 | 
            +
            /
         | 
| 15 | 
            +
            / Confirm the string contains a newline `0a`
         | 
| 16 | 
            +
            __Command substitution__:
         | 
| 17 | 
            +
            Genus2 hex: $(printf "$Genus2" | hexdump -C)
         | 
| 18 | 
            +
            /
         | 
| 19 | 
            +
            / output with substitution
         | 
| 20 | 
            +
            __Command substitution__:
         | 
| 21 | 
            +
            Genus2 text: $(printf "$Genus2")
         | 
| 22 | 
            +
            /
         | 
| 23 | 
            +
            / output with substitution
         | 
| 24 | 
            +
            __Command substitution__:
         | 
| 25 | 
            +
            $(ls -1 G*)
         | 
| 26 | 
            +
            /
         | 
| 27 | 
            +
            / output with expansion
         | 
| 28 | 
            +
            __Variable expansion__:
         | 
| 29 | 
            +
            Genus2 text: ${Genus2}
         | 
| 30 | 
            +
            /
         | 
| 31 | 
            +
            @import bats-document-configuration.md
         | 
    
        data/lib/ansi_formatter.rb
    CHANGED
    
    
    
        data/lib/ansi_string.rb
    CHANGED
    
    | @@ -20,7 +20,7 @@ class AnsiString < String | |
| 20 20 | 
             
                    segments[0..-2].each do |segment|
         | 
| 21 21 | 
             
                      codes += "\033[#{segment.split('_').join(';')}m"
         | 
| 22 22 | 
             
                    end
         | 
| 23 | 
            -
                    codes +=  | 
| 23 | 
            +
                    codes += to_s
         | 
| 24 24 | 
             
                    codes += "\033[#{segments.last.split('_').join(';')}m"
         | 
| 25 25 | 
             
                    self.class.new(codes)
         | 
| 26 26 | 
             
                  when /^fg_bg_rgb_/
         | 
    
        data/lib/array.rb
    CHANGED
    
    
    
        data/lib/array_util.rb
    CHANGED
    
    
    
        data/lib/block_label.rb
    CHANGED
    
    
    
        data/lib/constants.rb
    CHANGED
    
    | @@ -103,6 +103,24 @@ end | |
| 103 103 | 
             
            BlockSelection = Struct.new(:id)
         | 
| 104 104 | 
             
            SelectedBlockMenuState = Struct.new(:block, :source, :state)
         | 
| 105 105 |  | 
| 106 | 
            +
            # user responses to prompts to choose
         | 
| 107 | 
            +
            class SelectResponse
         | 
| 108 | 
            +
              def initialize(value)
         | 
| 109 | 
            +
                @value = value
         | 
| 110 | 
            +
              end
         | 
| 111 | 
            +
             | 
| 112 | 
            +
              def continue?
         | 
| 113 | 
            +
                @value == :ok
         | 
| 114 | 
            +
              end
         | 
| 115 | 
            +
             | 
| 116 | 
            +
              def self.continue?(value)
         | 
| 117 | 
            +
                !value.is_a?(SelectResponse) || value.continue?
         | 
| 118 | 
            +
              end
         | 
| 119 | 
            +
            end
         | 
| 120 | 
            +
             | 
| 121 | 
            +
            SelectResponse::BACK = SelectResponse.new(:back)
         | 
| 122 | 
            +
            SelectResponse::OK = SelectResponse.new(:ok)
         | 
| 123 | 
            +
             | 
| 106 124 | 
             
            class TtyMenu
         | 
| 107 125 | 
             
              ENABLE = nil
         | 
| 108 126 | 
             
              DISABLE = ''
         | 
    
        data/lib/directory_searcher.rb
    CHANGED
    
    
    
        data/lib/exceptions.rb
    CHANGED
    
    
    
        data/lib/fcb.rb
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            #!/usr/bin/env ruby
         | 
| 1 | 
            +
            #!/usr/bin/env -S bundle exec ruby
         | 
| 2 2 | 
             
            # frozen_string_literal: true
         | 
| 3 3 |  | 
| 4 4 | 
             
            # encoding=utf-8
         | 
| @@ -48,6 +48,7 @@ module MarkdownExec | |
| 48 48 | 
             
                    call: nil,
         | 
| 49 49 | 
             
                    dname: nil,
         | 
| 50 50 | 
             
                    headings: [],
         | 
| 51 | 
            +
                    id: object_id,
         | 
| 51 52 | 
             
                    indent: '',
         | 
| 52 53 | 
             
                    name: nil,
         | 
| 53 54 | 
             
                    nickname: nil,
         | 
| @@ -62,6 +63,15 @@ module MarkdownExec | |
| 62 63 | 
             
                  }.merge(options)
         | 
| 63 64 | 
             
                end
         | 
| 64 65 |  | 
| 66 | 
            +
                def pub_name(**kwargs)
         | 
| 67 | 
            +
                  self.class.pub_name(@attrs, **kwargs)
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                def self.pub_name(attrs, **kwargs)
         | 
| 71 | 
            +
                  full = attrs.fetch(:nickname, nil) || attrs.fetch(:oname, nil)
         | 
| 72 | 
            +
                  full&.to_s&.pub_name(**kwargs)
         | 
| 73 | 
            +
                end
         | 
| 74 | 
            +
             | 
| 65 75 | 
             
                def code_name_included?(*names)
         | 
| 66 76 | 
             
                  names.include?(@attrs[:oname])
         | 
| 67 77 | 
             
                end
         | 
| @@ -74,6 +84,19 @@ module MarkdownExec | |
| 74 84 | 
             
                  @attrs.delete(key)
         | 
| 75 85 | 
             
                end
         | 
| 76 86 |  | 
| 87 | 
            +
                # Removes and returns the first matching name from dependencies collection
         | 
| 88 | 
            +
                # Checks nickname, oname, pub_name and s2title
         | 
| 89 | 
            +
                # 2024-08-04 match oname for long block names
         | 
| 90 | 
            +
                # 2024-08-04 match nickname
         | 
| 91 | 
            +
                # may not exist if block name is duplicated
         | 
| 92 | 
            +
                def delete_matching_name!(dependencies)
         | 
| 93 | 
            +
                  dependencies.delete(@attrs[:dname]) ||
         | 
| 94 | 
            +
                    dependencies.delete(@attrs[:nickname]) ||
         | 
| 95 | 
            +
                    dependencies.delete(@attrs[:oname]) ||
         | 
| 96 | 
            +
                    dependencies.delete(@attrs.pub_name) ||
         | 
| 97 | 
            +
                    dependencies.delete(@attrs[:s2title])
         | 
| 98 | 
            +
                end
         | 
| 99 | 
            +
             | 
| 77 100 | 
             
                # Derives a title from the body of an FCB object.
         | 
| 78 101 | 
             
                # @param fcb [Object] The FCB object whose title is to be derived.
         | 
| 79 102 | 
             
                # @return [String] The derived title.
         | 
| @@ -141,8 +164,8 @@ module MarkdownExec | |
| 141 164 | 
             
                      oname = @attrs[:oname] = format(export.menu_format, export.to_h)
         | 
| 142 165 | 
             
                      @attrs[:readonly] = export.readonly
         | 
| 143 166 | 
             
                    else
         | 
| 144 | 
            -
                      # triggered by an empty block
         | 
| 145 | 
            -
                       | 
| 167 | 
            +
                      # triggered by an empty or non-YAML block
         | 
| 168 | 
            +
                      return NullResult.new(message: 'Invalid YAML', data: data)
         | 
| 146 169 | 
             
                    end
         | 
| 147 170 | 
             
                  end
         | 
| 148 171 |  | 
| @@ -150,6 +173,8 @@ module MarkdownExec | |
| 150 173 | 
             
                    (yield oname, BLOCK_TYPE_COLOR_OPTIONS[@attrs[:type]]),
         | 
| 151 174 | 
             
                    @attrs[:indent]
         | 
| 152 175 | 
             
                  )
         | 
| 176 | 
            +
             | 
| 177 | 
            +
                  SuccessResult.instance
         | 
| 153 178 | 
             
                end
         | 
| 154 179 |  | 
| 155 180 | 
             
                # Formats multiline body content as a title string.
         | 
| @@ -163,6 +188,24 @@ module MarkdownExec | |
| 163 188 | 
             
                  end.join("\n") << "\n"
         | 
| 164 189 | 
             
                end
         | 
| 165 190 |  | 
| 191 | 
            +
                # :reek:ManualDispatch
         | 
| 192 | 
            +
                # 2024-08-04 match nickname
         | 
| 193 | 
            +
                def is_dependency_of?(dependency_names)
         | 
| 194 | 
            +
                  dependency_names.include?(@attrs[:dname]) ||
         | 
| 195 | 
            +
                    dependency_names.include?(@attrs[:nickname]) ||
         | 
| 196 | 
            +
                    dependency_names.include?(@attrs[:oname]) ||
         | 
| 197 | 
            +
                    dependency_names.include?(@attrs.pub_name) ||
         | 
| 198 | 
            +
                    dependency_names.include?(@attrs[:s2title])
         | 
| 199 | 
            +
                end
         | 
| 200 | 
            +
             | 
| 201 | 
            +
                def is_named?(name)
         | 
| 202 | 
            +
                  @attrs[:dname] == name ||
         | 
| 203 | 
            +
                    @attrs[:nickname] == name ||
         | 
| 204 | 
            +
                    @attrs[:oname] == name ||
         | 
| 205 | 
            +
                    @attrs.pub_name == name ||
         | 
| 206 | 
            +
                    @attrs[:s2title] == name
         | 
| 207 | 
            +
                end
         | 
| 208 | 
            +
             | 
| 166 209 | 
             
                # :reek:ManualDispatch
         | 
| 167 210 | 
             
                def method_missing(method, *args, &block)
         | 
| 168 211 | 
             
                  method_name = method.to_s
         | 
| @@ -181,8 +224,6 @@ module MarkdownExec | |
| 181 224 | 
             
                  raise err
         | 
| 182 225 | 
             
                end
         | 
| 183 226 |  | 
| 184 | 
            -
                public
         | 
| 185 | 
            -
             | 
| 186 227 | 
             
                def name_in_menu!(indented_multi_line)
         | 
| 187 228 | 
             
                  # Indent has been extracted from the first line,
         | 
| 188 229 | 
             
                  # remove indent from the remaining lines.
         | 
| @@ -300,13 +341,15 @@ if $PROGRAM_NAME == __FILE__ | |
| 300 341 | 
             
                end
         | 
| 301 342 |  | 
| 302 343 | 
             
                def test_to_h_method
         | 
| 303 | 
            -
                  assert_equal_hash @fcb_data.merge( | 
| 344 | 
            +
                  assert_equal_hash @fcb_data.merge(
         | 
| 345 | 
            +
                    { id: @fcb.id, random: @fcb.random }
         | 
| 346 | 
            +
                  ), @fcb.to_h
         | 
| 304 347 | 
             
                end
         | 
| 305 348 |  | 
| 306 349 | 
             
                def test_to_yaml_method
         | 
| 307 | 
            -
                  assert_equal_hash YAML.load(@fcb_data.merge( | 
| 308 | 
            -
             | 
| 309 | 
            -
             | 
| 350 | 
            +
                  assert_equal_hash YAML.load(@fcb_data.merge(
         | 
| 351 | 
            +
                    { id: @fcb.id, random: @fcb.random }
         | 
| 352 | 
            +
                  ).to_yaml), YAML.load(@fcb.to_yaml)
         | 
| 310 353 | 
             
                end
         | 
| 311 354 |  | 
| 312 355 | 
             
                def test_method_missing_getter
         | 
    
        data/lib/filter.rb
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            #!/usr/bin/env ruby
         | 
| 1 | 
            +
            #!/usr/bin/env -S bundle exec ruby
         | 
| 2 2 | 
             
            # frozen_string_literal: true
         | 
| 3 3 |  | 
| 4 4 | 
             
            # encoding=utf-8
         | 
| @@ -123,7 +123,6 @@ module MarkdownExec | |
| 123 123 | 
             
                #
         | 
| 124 124 | 
             
                def self.apply_other_filters(options, filters, fcb)
         | 
| 125 125 | 
             
                  name = fcb.oname
         | 
| 126 | 
            -
                  shell = fcb.shell
         | 
| 127 126 | 
             
                  filters[:fcb_chrome] = fcb.fetch(:chrome, false)
         | 
| 128 127 | 
             
                  filters[:shell_default] = (fcb.type == BlockType::SHELL)
         | 
| 129 128 |  | 
    
        data/lib/format_table.rb
    CHANGED
    
    
    
        data/lib/fout.rb
    CHANGED
    
    
    
        data/lib/hash.rb
    CHANGED