speculate_about 0.6.1 → 1.0.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/lib/speculations/parser/state/candidate.rb +3 -3
- data/lib/speculations/parser/state/in.rb +2 -2
- data/lib/speculations/parser/state/includes.rb +31 -0
- data/lib/speculations/parser/state/triggers.rb +1 -1
- data/lib/speculations/parser/state.rb +1 -0
- data/lib/speculations/parser.rb +3 -1
- data/lib/speculations/version.rb +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 691aa57b9ad1035ca6eb20fe75f89b818414dcd33e05acd9d6621e13ee1cfb23
         | 
| 4 | 
            +
              data.tar.gz: 286766d1c5243bc9c1c6eb205c6e38ee97b3d06c90f4d77b6d84638a56d465e2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: cea1cc7dc006a7315fac53026959d444ae5a9bdcad161a94f57df7fdf3bead8cf5ee23aac5b9eaecdd68bc888cbf0df9e290acc4e09435f2b5bd771113ce38c3
         | 
| 7 | 
            +
              data.tar.gz: 6dcd950c3ea0bace47c8ecf3e42dd38ff41d747ac92918c30c08e2403e0c6c2471dcf69c1f3eddc04049988c40d555b07f470ee6a3e873cf8c36aa1223828690
         | 
| @@ -11,17 +11,17 @@ module Speculations | |
| 11 11 | 
             
                        new_parent = node.parent_of_level(level.pred)
         | 
| 12 12 | 
             
                        node = new_parent.new_context(title: match[2], lnb: lnb, level: level)
         | 
| 13 13 | 
             
                        [:out, node]
         | 
| 14 | 
            -
                      when match = State.maybe_example(line)
         | 
| 15 | 
            -
                        [:candidate, node, match[:title]]
         | 
| 16 14 | 
             
                      when match = State.maybe_include(line)
         | 
| 17 15 | 
             
                        [:candidate, node, :inc]
         | 
| 16 | 
            +
                      when match = State.maybe_example(line)
         | 
| 17 | 
            +
                        [:candidate, node, match[:title]]
         | 
| 18 18 | 
             
                      when match = State.ruby_code_block(line)
         | 
| 19 19 | 
             
                        if ctxt == :inc
         | 
| 20 20 | 
             
                          node = node.new_include(lnb: lnb)
         | 
| 21 21 | 
             
                        else
         | 
| 22 22 | 
             
                          node = node.new_example(title: ctxt, lnb: lnb)
         | 
| 23 23 | 
             
                        end
         | 
| 24 | 
            -
                        [:in, node]
         | 
| 24 | 
            +
                        [:in, node, (ctxt == :inc ? :includes : :out)]
         | 
| 25 25 | 
             
                      else
         | 
| 26 26 | 
             
                        [:out, node]
         | 
| 27 27 | 
             
                      end
         | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            module Speculations
         | 
| 2 | 
            +
              class Parser
         | 
| 3 | 
            +
                module State
         | 
| 4 | 
            +
                  module Includes extend self
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                    def parse line, lnb, node, _ctxt
         | 
| 7 | 
            +
                      case
         | 
| 8 | 
            +
                      when match = State.context_match(line)
         | 
| 9 | 
            +
                        make_new_context(lnb: lnb, node: node, match: match)
         | 
| 10 | 
            +
                      when match = State.maybe_include(line)
         | 
| 11 | 
            +
                        [:candidate, node, :inc]
         | 
| 12 | 
            +
                      when match = State.maybe_example(line)
         | 
| 13 | 
            +
                        [:candidate, node, match[:title]]
         | 
| 14 | 
            +
                      else
         | 
| 15 | 
            +
                        [:includes, node]
         | 
| 16 | 
            +
                      end
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    private
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                    def make_new_context(lnb:, match:, node:)
         | 
| 22 | 
            +
                      level = match[:level].size
         | 
| 23 | 
            +
                      new_parent = node.parent_of_level(level.pred)
         | 
| 24 | 
            +
                      node = new_parent.new_context(title: match[:title], lnb: lnb, level: level)
         | 
| 25 | 
            +
                      [:out, node]
         | 
| 26 | 
            +
                    end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
| @@ -3,7 +3,7 @@ module Speculations::Parser::State::Triggers | |
| 3 3 | 
             
              BLANK_RGX   = %r{\A\s*\z}
         | 
| 4 4 | 
             
              CONTEXT_RGX = %r[\A\s{0,3}(?<level>\#{1,7})\s+Context:?\s+(?<title>.*)]
         | 
| 5 5 | 
             
              EOBLOCK_RGX = %r[\A\s{0,3}```\s*\z]
         | 
| 6 | 
            -
              GIVEN_RGX   = %r[\A\s{0,3}(?:Given|When)\b]
         | 
| 6 | 
            +
              GIVEN_RGX   = %r[\A\s{0,3}(?:Given|When|And)\b]
         | 
| 7 7 | 
             
              EXAMPLE_RGX = %r[\A\s{0,3}Example:?\s+(<?title>.*)]
         | 
| 8 8 | 
             
              RUBY_RGX    = %r[\A\s{0,3}```ruby]
         | 
| 9 9 | 
             
              THEN_RGX    = %r[\A\s{0,3}(?:Then|But|And|Also|Or)\b\s*(?<title>.*)]
         | 
    
        data/lib/speculations/parser.rb
    CHANGED
    
    | @@ -8,6 +8,7 @@ module Speculations | |
| 8 8 | 
             
                  @__parsers__ ||= {
         | 
| 9 9 | 
             
                    candidate: State::Candidate,
         | 
| 10 10 | 
             
                    in: State::In,
         | 
| 11 | 
            +
                    includes: State::Includes,
         | 
| 11 12 | 
             
                    out: State::Out
         | 
| 12 13 | 
             
                  }
         | 
| 13 14 | 
             
                end
         | 
| @@ -31,7 +32,8 @@ module Speculations | |
| 31 32 | 
             
                  root = node = Context.new(filename: @filename)
         | 
| 32 33 | 
             
                  ctxt = nil
         | 
| 33 34 | 
             
                  @input.each_with_index do |line, lnb|
         | 
| 34 | 
            -
                     | 
| 35 | 
            +
                    parser = self.class.parsers.fetch(@state)
         | 
| 36 | 
            +
                    @state, node, ctxt = parser.parse(line, lnb.succ, node, ctxt)
         | 
| 35 37 | 
             
                  end
         | 
| 36 38 | 
             
                  root
         | 
| 37 39 | 
             
                end
         | 
    
        data/lib/speculations/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: speculate_about
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Robert Dober
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2022-01- | 
| 11 | 
            +
            date: 2022-01-30 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description: Allows Markdown or other text files to be used as literal specs, à la
         | 
| 14 14 | 
             
              Elixr doctest, but from any file.
         | 
| @@ -29,6 +29,7 @@ files: | |
| 29 29 | 
             
            - lib/speculations/parser/state.rb
         | 
| 30 30 | 
             
            - lib/speculations/parser/state/candidate.rb
         | 
| 31 31 | 
             
            - lib/speculations/parser/state/in.rb
         | 
| 32 | 
            +
            - lib/speculations/parser/state/includes.rb
         | 
| 32 33 | 
             
            - lib/speculations/parser/state/out.rb
         | 
| 33 34 | 
             
            - lib/speculations/parser/state/triggers.rb
         | 
| 34 35 | 
             
            - lib/speculations/version.rb
         |