code-ruby 1.4.0 → 1.5.2
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/.node-version +1 -1
- data/.npm-version +1 -1
- data/.rubocop.yml +8 -7
- data/.ruby-version +1 -1
- data/.tool-versions +2 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +34 -34
- data/VERSION +1 -1
- data/bin/code +12 -8
- data/code-ruby.gemspec +2 -2
- data/lib/code/concerns/shared.rb +10 -59
- data/lib/code/node/code.rb +10 -0
- data/lib/code/node/dictionary.rb +34 -15
- data/lib/code/node/function_parameter.rb +1 -1
- data/lib/code/object/boolean.rb +3 -2
- data/lib/code/object/class.rb +2 -2
- data/lib/code/object/code.rb +2 -2
- data/lib/code/object/context.rb +1 -1
- data/lib/code/object/date.rb +3 -3
- data/lib/code/object/decimal.rb +3 -3
- data/lib/code/object/dictionary.rb +23 -7
- data/lib/code/object/duration.rb +3 -3
- data/lib/code/object/function.rb +2 -2
- data/lib/code/object/global.rb +1 -5
- data/lib/code/object/html.rb +4 -5
- data/lib/code/object/http.rb +0 -2
- data/lib/code/object/integer.rb +3 -3
- data/lib/code/object/list.rb +9 -2
- data/lib/code/object/nothing.rb +2 -2
- data/lib/code/object/parameter.rb +2 -2
- data/lib/code/object/range.rb +2 -2
- data/lib/code/object/string.rb +2 -2
- data/lib/code/object/time.rb +100 -6
- data/lib/code/object.rb +5 -5
- data/lib/code/parser/call.rb +7 -6
- data/lib/code/parser/dictionary.rb +7 -5
- data/lib/code/parser/equal.rb +0 -4
- data/lib/code/parser/function.rb +8 -2
- data/lib/code/parser/group.rb +20 -4
- data/lib/code/parser/if.rb +8 -2
- data/lib/code/parser/name.rb +4 -8
- data/lib/code/parser/while.rb +8 -2
- data/lib/code/type/sig.rb +2 -2
- data/lib/code/type.rb +1 -1
- data/lib/code.rb +7 -7
- data/package-lock.json +2 -2
- data/package.json +2 -2
- data/spec/code/object/http_spec.rb +70 -66
- data/spec/code_spec.rb +18 -2
- metadata +4 -6
- data/TODO +0 -219
- data/bin/console +0 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 581653fe0886e86410048da9af0e26e3f084a6539d6b1320cc5a39709683a561
         | 
| 4 | 
            +
              data.tar.gz: 61833954737c769eb64ccb4606023d4fa993ba3832f875dc74476cfb5a9ef1fb
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b7cf5543d7f2290ac8c4980a47b1bdfdbf16f056aaf0e4f9476a4a36a9c72eb021d49534d45c45a92bee63859d2778fbc04dcf8b7093ac66e0acfe719fc297b1
         | 
| 7 | 
            +
              data.tar.gz: 16e9a0c4848b02a7e6c9dd04f1b4a0ffc788b262b0bd1a8eddabd0433fac5b2d4a0f6b800debef0107372269fc3803a168dd929e296124b54286bedba345db96
         | 
    
        data/.node-version
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            23.11.0
         | 
    
        data/.npm-version
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            11.2.0
         | 
    
        data/.rubocop.yml
    CHANGED
    
    | @@ -1,12 +1,11 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            AllCops:
         | 
| 3 3 | 
             
              Exclude:
         | 
| 4 | 
            -
              - " | 
| 5 | 
            -
              - " | 
| 6 | 
            -
              -  | 
| 7 | 
            -
              - vendor/**/*
         | 
| 4 | 
            +
              - "**/node_modules/**/*"
         | 
| 5 | 
            +
              - "**/vendor/**/*"
         | 
| 6 | 
            +
              - "**/db/schema.rb"
         | 
| 8 7 | 
             
              NewCops: enable
         | 
| 9 | 
            -
              TargetRubyVersion: 3. | 
| 8 | 
            +
              TargetRubyVersion: 3.0
         | 
| 10 9 | 
             
            Layout/ClosingHeredocIndentation:
         | 
| 11 10 | 
             
              Enabled: false
         | 
| 12 11 | 
             
            Layout/FirstArgumentIndentation:
         | 
| @@ -23,6 +22,8 @@ Layout/MultilineMethodCallIndentation: | |
| 23 22 | 
             
              Enabled: false
         | 
| 24 23 | 
             
            Layout/MultilineOperationIndentation:
         | 
| 25 24 | 
             
              Enabled: false
         | 
| 25 | 
            +
            Layout/SpaceInsideHashLiteralBraces:
         | 
| 26 | 
            +
              Enabled: false
         | 
| 26 27 | 
             
            Lint/EmptyClass:
         | 
| 27 28 | 
             
              Enabled: false
         | 
| 28 29 | 
             
            Lint/MissingSuper:
         | 
| @@ -119,11 +120,11 @@ Style/StringLiterals: | |
| 119 120 | 
             
              Enabled: false
         | 
| 120 121 | 
             
            Style/StringLiteralsInInterpolation:
         | 
| 121 122 | 
             
              Enabled: false
         | 
| 122 | 
            -
             | 
| 123 | 
            +
            plugins:
         | 
| 123 124 | 
             
            - rubocop-factory_bot
         | 
| 124 125 | 
             
            - rubocop-performance
         | 
| 125 126 | 
             
            - rubocop-rails
         | 
| 126 127 | 
             
            - rubocop-rake
         | 
| 127 128 | 
             
            - rubocop-rspec
         | 
| 128 | 
            -
            - rubocop-rspec_rails
         | 
| 129 129 | 
             
            - rubocop-capybara
         | 
| 130 | 
            +
            - rubocop-rspec_rails
         | 
    
        data/.ruby-version
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            3. | 
| 1 | 
            +
            3.4.2
         | 
    
        data/.tool-versions
    CHANGED
    
    | @@ -1,3 +1,3 @@ | |
| 1 | 
            -
            ruby 3. | 
| 1 | 
            +
            ruby 3.4.2
         | 
| 2 2 | 
             
            yarn 1.22.22
         | 
| 3 | 
            -
            nodejs  | 
| 3 | 
            +
            nodejs 23.11.0
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                code-ruby (1. | 
| 4 | 
            +
                code-ruby (1.5.2)
         | 
| 5 5 | 
             
                  activesupport
         | 
| 6 6 | 
             
                  base64
         | 
| 7 7 | 
             
                  bigdecimal
         | 
| @@ -41,15 +41,15 @@ GEM | |
| 41 41 | 
             
                  thor (~> 1.0)
         | 
| 42 42 | 
             
                cmdparse (3.0.7)
         | 
| 43 43 | 
             
                concurrent-ruby (1.3.5)
         | 
| 44 | 
            -
                connection_pool (2.5. | 
| 44 | 
            +
                connection_pool (2.5.3)
         | 
| 45 45 | 
             
                crack (1.0.0)
         | 
| 46 46 | 
             
                  bigdecimal
         | 
| 47 47 | 
             
                  rexml
         | 
| 48 | 
            -
                csv (3.3. | 
| 48 | 
            +
                csv (3.3.4)
         | 
| 49 49 | 
             
                did-you-mean (0.1.1)
         | 
| 50 50 | 
             
                  levenshtein (>= 0.2.0)
         | 
| 51 | 
            -
                diff-lcs (1.6. | 
| 52 | 
            -
                dorian (2.6. | 
| 51 | 
            +
                diff-lcs (1.6.2)
         | 
| 52 | 
            +
                dorian (2.6.4)
         | 
| 53 53 | 
             
                  csv
         | 
| 54 54 | 
             
                  dorian-arguments
         | 
| 55 55 | 
             
                  dorian-eval
         | 
| @@ -76,7 +76,7 @@ GEM | |
| 76 76 | 
             
                dorian-to_struct (2.0.2)
         | 
| 77 77 | 
             
                drb (2.2.1)
         | 
| 78 78 | 
             
                geom2d (0.4.1)
         | 
| 79 | 
            -
                git (3.0. | 
| 79 | 
            +
                git (3.0.2)
         | 
| 80 80 | 
             
                  activesupport (>= 5.0)
         | 
| 81 81 | 
             
                  addressable (~> 2.8)
         | 
| 82 82 | 
             
                  process_executer (~> 1.3)
         | 
| @@ -86,56 +86,56 @@ GEM | |
| 86 86 | 
             
                  thor
         | 
| 87 87 | 
             
                  tilt
         | 
| 88 88 | 
             
                hashdiff (1.1.2)
         | 
| 89 | 
            -
                hexapdf (1. | 
| 89 | 
            +
                hexapdf (1.3.0)
         | 
| 90 90 | 
             
                  cmdparse (~> 3.0, >= 3.0.3)
         | 
| 91 91 | 
             
                  geom2d (~> 0.4, >= 0.4.1)
         | 
| 92 92 | 
             
                  openssl (>= 2.2.1)
         | 
| 93 93 | 
             
                  strscan (>= 3.1.2)
         | 
| 94 94 | 
             
                i18n (1.14.7)
         | 
| 95 95 | 
             
                  concurrent-ruby (~> 1.0)
         | 
| 96 | 
            -
                json (2. | 
| 97 | 
            -
                language-ruby (1. | 
| 96 | 
            +
                json (2.12.0)
         | 
| 97 | 
            +
                language-ruby (1.2.0)
         | 
| 98 98 | 
             
                  dorian-arguments
         | 
| 99 99 | 
             
                  zeitwerk
         | 
| 100 | 
            -
                language_server-protocol (3.17.0. | 
| 100 | 
            +
                language_server-protocol (3.17.0.5)
         | 
| 101 101 | 
             
                levenshtein (0.2.2)
         | 
| 102 102 | 
             
                libv8-node (23.6.1.0)
         | 
| 103 103 | 
             
                libv8-node (23.6.1.0-arm64-darwin)
         | 
| 104 104 | 
             
                libv8-node (23.6.1.0-x86_64-linux)
         | 
| 105 105 | 
             
                lint_roller (1.1.0)
         | 
| 106 106 | 
             
                logger (1.7.0)
         | 
| 107 | 
            -
                mini_portile2 (2.8. | 
| 108 | 
            -
                mini_racer (0.18. | 
| 107 | 
            +
                mini_portile2 (2.8.9)
         | 
| 108 | 
            +
                mini_racer (0.18.1)
         | 
| 109 109 | 
             
                  libv8-node (~> 23.6.1.0)
         | 
| 110 110 | 
             
                minitest (5.25.5)
         | 
| 111 111 | 
             
                mustermann (3.0.3)
         | 
| 112 112 | 
             
                  ruby2_keywords (~> 0.0.1)
         | 
| 113 113 | 
             
                net-http (0.6.0)
         | 
| 114 114 | 
             
                  uri
         | 
| 115 | 
            -
                nokogiri (1.18. | 
| 115 | 
            +
                nokogiri (1.18.8)
         | 
| 116 116 | 
             
                  mini_portile2 (~> 2.8.2)
         | 
| 117 117 | 
             
                  racc (~> 1.4)
         | 
| 118 | 
            -
                nokogiri (1.18. | 
| 118 | 
            +
                nokogiri (1.18.8-arm64-darwin)
         | 
| 119 119 | 
             
                  racc (~> 1.4)
         | 
| 120 | 
            -
                nokogiri (1.18. | 
| 120 | 
            +
                nokogiri (1.18.8-x86_64-linux-gnu)
         | 
| 121 121 | 
             
                  racc (~> 1.4)
         | 
| 122 122 | 
             
                openssl (3.3.0)
         | 
| 123 123 | 
             
                ostruct (0.6.1)
         | 
| 124 | 
            -
                parallel (1. | 
| 125 | 
            -
                parser (3.3. | 
| 124 | 
            +
                parallel (1.27.0)
         | 
| 125 | 
            +
                parser (3.3.8.0)
         | 
| 126 126 | 
             
                  ast (~> 2.4.1)
         | 
| 127 127 | 
             
                  racc
         | 
| 128 128 | 
             
                prettier_print (1.2.1)
         | 
| 129 129 | 
             
                prism (1.4.0)
         | 
| 130 130 | 
             
                process_executer (1.3.0)
         | 
| 131 | 
            -
                public_suffix (6.0. | 
| 131 | 
            +
                public_suffix (6.0.2)
         | 
| 132 132 | 
             
                racc (1.8.1)
         | 
| 133 | 
            -
                rack (3.1. | 
| 133 | 
            +
                rack (3.1.14)
         | 
| 134 134 | 
             
                rack-protection (4.1.1)
         | 
| 135 135 | 
             
                  base64 (>= 0.1.0)
         | 
| 136 136 | 
             
                  logger (>= 1.6.0)
         | 
| 137 137 | 
             
                  rack (>= 3.0.0, < 4)
         | 
| 138 | 
            -
                rack-session (2.1. | 
| 138 | 
            +
                rack-session (2.1.1)
         | 
| 139 139 | 
             
                  base64 (>= 0.1.0)
         | 
| 140 140 | 
             
                  rack (>= 3.0.0)
         | 
| 141 141 | 
             
                rainbow (3.1.1)
         | 
| @@ -149,14 +149,14 @@ GEM | |
| 149 149 | 
             
                  rspec-mocks (~> 3.13.0)
         | 
| 150 150 | 
             
                rspec-core (3.13.3)
         | 
| 151 151 | 
             
                  rspec-support (~> 3.13.0)
         | 
| 152 | 
            -
                rspec-expectations (3.13. | 
| 152 | 
            +
                rspec-expectations (3.13.4)
         | 
| 153 153 | 
             
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 154 154 | 
             
                  rspec-support (~> 3.13.0)
         | 
| 155 | 
            -
                rspec-mocks (3.13. | 
| 155 | 
            +
                rspec-mocks (3.13.4)
         | 
| 156 156 | 
             
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 157 157 | 
             
                  rspec-support (~> 3.13.0)
         | 
| 158 | 
            -
                rspec-support (3.13. | 
| 159 | 
            -
                rubocop (1.75. | 
| 158 | 
            +
                rspec-support (3.13.3)
         | 
| 159 | 
            +
                rubocop (1.75.6)
         | 
| 160 160 | 
             
                  json (~> 2.3)
         | 
| 161 161 | 
             
                  language_server-protocol (~> 3.17.0.2)
         | 
| 162 162 | 
             
                  lint_roller (~> 1.1.0)
         | 
| @@ -164,10 +164,10 @@ GEM | |
| 164 164 | 
             
                  parser (>= 3.3.0.2)
         | 
| 165 165 | 
             
                  rainbow (>= 2.2.2, < 4.0)
         | 
| 166 166 | 
             
                  regexp_parser (>= 2.9.3, < 3.0)
         | 
| 167 | 
            -
                  rubocop-ast (>= 1. | 
| 167 | 
            +
                  rubocop-ast (>= 1.44.0, < 2.0)
         | 
| 168 168 | 
             
                  ruby-progressbar (~> 1.7)
         | 
| 169 169 | 
             
                  unicode-display_width (>= 2.4.0, < 4.0)
         | 
| 170 | 
            -
                rubocop-ast (1. | 
| 170 | 
            +
                rubocop-ast (1.44.1)
         | 
| 171 171 | 
             
                  parser (>= 3.3.7.2)
         | 
| 172 172 | 
             
                  prism (~> 1.4)
         | 
| 173 173 | 
             
                rubocop-capybara (2.22.1)
         | 
| @@ -176,20 +176,20 @@ GEM | |
| 176 176 | 
             
                rubocop-factory_bot (2.27.1)
         | 
| 177 177 | 
             
                  lint_roller (~> 1.1)
         | 
| 178 178 | 
             
                  rubocop (~> 1.72, >= 1.72.1)
         | 
| 179 | 
            -
                rubocop-performance (1. | 
| 179 | 
            +
                rubocop-performance (1.25.0)
         | 
| 180 180 | 
             
                  lint_roller (~> 1.1)
         | 
| 181 | 
            -
                  rubocop (>= 1. | 
| 181 | 
            +
                  rubocop (>= 1.75.0, < 2.0)
         | 
| 182 182 | 
             
                  rubocop-ast (>= 1.38.0, < 2.0)
         | 
| 183 | 
            -
                rubocop-rails (2. | 
| 183 | 
            +
                rubocop-rails (2.31.0)
         | 
| 184 184 | 
             
                  activesupport (>= 4.2.0)
         | 
| 185 185 | 
             
                  lint_roller (~> 1.1)
         | 
| 186 186 | 
             
                  rack (>= 1.1)
         | 
| 187 | 
            -
                  rubocop (>= 1. | 
| 187 | 
            +
                  rubocop (>= 1.75.0, < 2.0)
         | 
| 188 188 | 
             
                  rubocop-ast (>= 1.38.0, < 2.0)
         | 
| 189 189 | 
             
                rubocop-rake (0.7.1)
         | 
| 190 190 | 
             
                  lint_roller (~> 1.1)
         | 
| 191 191 | 
             
                  rubocop (>= 1.72.1)
         | 
| 192 | 
            -
                rubocop-rspec (3. | 
| 192 | 
            +
                rubocop-rspec (3.6.0)
         | 
| 193 193 | 
             
                  lint_roller (~> 1.1)
         | 
| 194 194 | 
             
                  rubocop (~> 1.72, >= 1.72.1)
         | 
| 195 195 | 
             
                rubocop-rspec_rails (2.31.0)
         | 
| @@ -207,7 +207,7 @@ GEM | |
| 207 207 | 
             
                  rack-protection (= 4.1.1)
         | 
| 208 208 | 
             
                  rack-session (>= 2.0.0, < 3)
         | 
| 209 209 | 
             
                  tilt (~> 2.0)
         | 
| 210 | 
            -
                strscan (3.1. | 
| 210 | 
            +
                strscan (3.1.5)
         | 
| 211 211 | 
             
                syntax_tree (6.2.0)
         | 
| 212 212 | 
             
                  prettier_print (>= 1.2.0)
         | 
| 213 213 | 
             
                syntax_tree-haml (4.0.3)
         | 
| @@ -261,7 +261,7 @@ DEPENDENCIES | |
| 261 261 | 
             
              webmock
         | 
| 262 262 |  | 
| 263 263 | 
             
            RUBY VERSION
         | 
| 264 | 
            -
               ruby 3. | 
| 264 | 
            +
               ruby 3.4.2p28
         | 
| 265 265 |  | 
| 266 266 | 
             
            BUNDLED WITH
         | 
| 267 | 
            -
               2.6. | 
| 267 | 
            +
               2.6.7
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            1. | 
| 1 | 
            +
            1.5.2
         | 
    
        data/bin/code
    CHANGED
    
    | @@ -48,15 +48,19 @@ input = 'loop { print("> ") puts(evaluate(read)) }' if input.blank? | |
| 48 48 | 
             
            if parsed.options.parse
         | 
| 49 49 | 
             
              pp Code::Parser.parse(input).to_raw
         | 
| 50 50 | 
             
            else
         | 
| 51 | 
            -
               | 
| 52 | 
            -
                 | 
| 53 | 
            -
                   | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 57 | 
            -
             | 
| 51 | 
            +
              begin
         | 
| 52 | 
            +
                print(
         | 
| 53 | 
            +
                  Code.evaluate(
         | 
| 54 | 
            +
                    input,
         | 
| 55 | 
            +
                    output: $stdout,
         | 
| 56 | 
            +
                    error: $stderr,
         | 
| 57 | 
            +
                    input: $stdin,
         | 
| 58 | 
            +
                    timeout: parsed.options.timeout
         | 
| 59 | 
            +
                  )
         | 
| 58 60 | 
             
                )
         | 
| 59 | 
            -
               | 
| 61 | 
            +
              rescue Code::Error => e
         | 
| 62 | 
            +
                warn e.message
         | 
| 63 | 
            +
              end
         | 
| 60 64 | 
             
            end
         | 
| 61 65 |  | 
| 62 66 | 
             
            if profile
         | 
    
        data/code-ruby.gemspec
    CHANGED
    
    | @@ -6,7 +6,7 @@ Gem::Specification.new do |s| | |
| 6 6 | 
             
              s.summary = "a programming language for the internet"
         | 
| 7 7 | 
             
              s.description = s.summary
         | 
| 8 8 | 
             
              s.authors = ["Dorian Marié"]
         | 
| 9 | 
            -
              s.email = "dorian@dorianmarie. | 
| 9 | 
            +
              s.email = "dorian@dorianmarie.com"
         | 
| 10 10 | 
             
              s.files = `git ls-files`.lines.map(&:strip)
         | 
| 11 11 | 
             
              s.require_paths = ["lib"]
         | 
| 12 12 | 
             
              s.homepage = "https://github.com/dorianmariecom/code-ruby"
         | 
| @@ -27,5 +27,5 @@ Gem::Specification.new do |s| | |
| 27 27 |  | 
| 28 28 | 
             
              s.metadata["rubygems_mfa_required"] = "true"
         | 
| 29 29 |  | 
| 30 | 
            -
              s.required_ruby_version = ">= 3. | 
| 30 | 
            +
              s.required_ruby_version = ">= 3.0"
         | 
| 31 31 | 
             
            end
         | 
    
        data/lib/code/concerns/shared.rb
    CHANGED
    
    | @@ -3,7 +3,7 @@ | |
| 3 3 | 
             
            class Code
         | 
| 4 4 | 
             
              module Concerns
         | 
| 5 5 | 
             
                module Shared
         | 
| 6 | 
            -
                   | 
| 6 | 
            +
                  attr_accessor :raw, :methods
         | 
| 7 7 |  | 
| 8 8 | 
             
                  def call(**args)
         | 
| 9 9 | 
             
                    code_operator = args.fetch(:operator, nil).to_code
         | 
| @@ -103,6 +103,9 @@ class Code | |
| 103 103 | 
             
                      else
         | 
| 104 104 | 
             
                        code_to_json
         | 
| 105 105 | 
             
                      end
         | 
| 106 | 
            +
                    when "methods"
         | 
| 107 | 
            +
                      sig(args)
         | 
| 108 | 
            +
                      code_methods
         | 
| 106 109 | 
             
                    when "name"
         | 
| 107 110 | 
             
                      sig(args)
         | 
| 108 111 | 
             
                      code_name
         | 
| @@ -213,8 +216,8 @@ class Code | |
| 213 216 | 
             
                    keys.to_h { |key| [key, hash.fetch(key)] }
         | 
| 214 217 | 
             
                  end
         | 
| 215 218 |  | 
| 216 | 
            -
                  def sig(args, &)
         | 
| 217 | 
            -
                    Type::Sig.sig(args, object: self, &)
         | 
| 219 | 
            +
                  def sig(args, &block)
         | 
| 220 | 
            +
                    Type::Sig.sig(args, object: self, &block)
         | 
| 218 221 |  | 
| 219 222 | 
             
                    Object::Nothing.new
         | 
| 220 223 | 
             
                  end
         | 
| @@ -287,62 +290,6 @@ class Code | |
| 287 290 | 
             
                    code_to_string.code_parameterize
         | 
| 288 291 | 
             
                  end
         | 
| 289 292 |  | 
| 290 | 
            -
                  def code_falsy?
         | 
| 291 | 
            -
                    Object::Boolean.new(falsy?)
         | 
| 292 | 
            -
                  end
         | 
| 293 | 
            -
             | 
| 294 | 
            -
                  def code_truthy?
         | 
| 295 | 
            -
                    Object::Boolean.new(truthy?)
         | 
| 296 | 
            -
                  end
         | 
| 297 | 
            -
             | 
| 298 | 
            -
                  def code_to_boolean
         | 
| 299 | 
            -
                    Object::Boolean.new(self)
         | 
| 300 | 
            -
                  end
         | 
| 301 | 
            -
             | 
| 302 | 
            -
                  def code_to_class
         | 
| 303 | 
            -
                    Object::Class.new(self)
         | 
| 304 | 
            -
                  end
         | 
| 305 | 
            -
             | 
| 306 | 
            -
                  def code_to_date
         | 
| 307 | 
            -
                    Object::Date.new(self)
         | 
| 308 | 
            -
                  end
         | 
| 309 | 
            -
             | 
| 310 | 
            -
                  def code_to_decimal
         | 
| 311 | 
            -
                    Object::Decimal.new(self)
         | 
| 312 | 
            -
                  end
         | 
| 313 | 
            -
             | 
| 314 | 
            -
                  def code_to_dictionary
         | 
| 315 | 
            -
                    Object::Dictionary.new(self)
         | 
| 316 | 
            -
                  end
         | 
| 317 | 
            -
             | 
| 318 | 
            -
                  def code_to_duration
         | 
| 319 | 
            -
                    Object::Duration.new(self)
         | 
| 320 | 
            -
                  end
         | 
| 321 | 
            -
             | 
| 322 | 
            -
                  def code_to_integer
         | 
| 323 | 
            -
                    Object::Integer.new(self)
         | 
| 324 | 
            -
                  end
         | 
| 325 | 
            -
             | 
| 326 | 
            -
                  def code_to_list
         | 
| 327 | 
            -
                    Object::List.new(self)
         | 
| 328 | 
            -
                  end
         | 
| 329 | 
            -
             | 
| 330 | 
            -
                  def code_to_nothing
         | 
| 331 | 
            -
                    Object::Nothing.new(self)
         | 
| 332 | 
            -
                  end
         | 
| 333 | 
            -
             | 
| 334 | 
            -
                  def code_to_range
         | 
| 335 | 
            -
                    Object::Range.new(self)
         | 
| 336 | 
            -
                  end
         | 
| 337 | 
            -
             | 
| 338 | 
            -
                  def code_to_string
         | 
| 339 | 
            -
                    Object::String.new(self)
         | 
| 340 | 
            -
                  end
         | 
| 341 | 
            -
             | 
| 342 | 
            -
                  def code_to_time
         | 
| 343 | 
            -
                    Object::Time.new(self)
         | 
| 344 | 
            -
                  end
         | 
| 345 | 
            -
             | 
| 346 293 | 
             
                  def to_s
         | 
| 347 294 | 
             
                    code_to_string.raw
         | 
| 348 295 | 
             
                  end
         | 
| @@ -418,6 +365,10 @@ class Code | |
| 418 365 | 
             
                  def code_name
         | 
| 419 366 | 
             
                    Object::String.new(name.to_s.split("::")[2..].join("::"))
         | 
| 420 367 | 
             
                  end
         | 
| 368 | 
            +
             | 
| 369 | 
            +
                  def code_methods
         | 
| 370 | 
            +
                    Object::List.new(methods)
         | 
| 371 | 
            +
                  end
         | 
| 421 372 | 
             
                end
         | 
| 422 373 | 
             
              end
         | 
| 423 374 | 
             
            end
         | 
    
        data/lib/code/node/code.rb
    CHANGED
    
    
    
        data/lib/code/node/dictionary.rb
    CHANGED
    
    | @@ -4,29 +4,48 @@ class Code | |
| 4 4 | 
             
              class Node
         | 
| 5 5 | 
             
                class Dictionary < Node
         | 
| 6 6 | 
             
                  class KeyValue < Node
         | 
| 7 | 
            +
                    attr_reader :resolve_key
         | 
| 8 | 
            +
             | 
| 7 9 | 
             
                    def initialize(parsed)
         | 
| 8 10 | 
             
                      return if parsed.blank?
         | 
| 9 11 |  | 
| 10 | 
            -
                      if parsed. | 
| 11 | 
            -
                         | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 12 | 
            +
                      if (name_code = parsed.delete(:name_code))
         | 
| 13 | 
            +
                        if name_code.key?(:code)
         | 
| 14 | 
            +
                          @key =
         | 
| 15 | 
            +
                            Node::String.new([{ text: name_code.delete(:name).presence }])
         | 
| 16 | 
            +
                          @value = Node::Code.new(name_code.delete(:code).presence)
         | 
| 17 | 
            +
                          @resolve_key = false
         | 
| 18 | 
            +
                        else
         | 
| 19 | 
            +
                          @key = Node::Call.new({ name: name_code.delete(:name).presence })
         | 
| 20 | 
            +
                          @value = @key
         | 
| 21 | 
            +
                          @resolve_key = true
         | 
| 22 | 
            +
                        end
         | 
| 23 | 
            +
                      elsif (statement_code = parsed.delete(:statement_code))
         | 
| 24 | 
            +
                        @key =
         | 
| 25 | 
            +
                          Node::Statement.new(statement_code.delete(:statement).presence)
         | 
| 17 26 |  | 
| 18 | 
            -
             | 
| 27 | 
            +
                        if statement_code.key?(:code)
         | 
| 28 | 
            +
                          @value = Node::Code.new(statement_code.delete(:code).presence)
         | 
| 29 | 
            +
                          @resolve_key = false
         | 
| 30 | 
            +
                        else
         | 
| 31 | 
            +
                          @value = @key
         | 
| 32 | 
            +
                          @resolve_key = true
         | 
| 33 | 
            +
                        end
         | 
| 34 | 
            +
                      else
         | 
| 35 | 
            +
                        @key = @value = Node::Code.new(parsed.delete(:code).presence)
         | 
| 36 | 
            +
                        @resolve_key = true
         | 
| 37 | 
            +
                      end
         | 
| 19 38 | 
             
                    end
         | 
| 20 39 |  | 
| 21 40 | 
             
                    def evaluate(**args)
         | 
| 22 | 
            -
                      key = @key&. | 
| 41 | 
            +
                      key = resolve_key? ? @key&.resolve(**args) : @key&.evaluate(**args)
         | 
| 42 | 
            +
                      key ||= Object::Nothing.new
         | 
| 43 | 
            +
                      value = @value.evaluate(**args)
         | 
| 44 | 
            +
                      [key, value]
         | 
| 45 | 
            +
                    end
         | 
| 23 46 |  | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
                        [key, value]
         | 
| 27 | 
            -
                      else
         | 
| 28 | 
            -
                        [key, key]
         | 
| 29 | 
            -
                      end
         | 
| 47 | 
            +
                    def resolve_key?
         | 
| 48 | 
            +
                      !!resolve_key
         | 
| 30 49 | 
             
                    end
         | 
| 31 50 | 
             
                  end
         | 
| 32 51 |  | 
    
        data/lib/code/object/boolean.rb
    CHANGED
    
    | @@ -3,8 +3,9 @@ | |
| 3 3 | 
             
            class Code
         | 
| 4 4 | 
             
              class Object
         | 
| 5 5 | 
             
                class Boolean < ::Code::Object
         | 
| 6 | 
            -
                  def initialize(*args, **_kargs, &)
         | 
| 7 | 
            -
                     | 
| 6 | 
            +
                  def initialize(*args, **_kargs, &_block)
         | 
| 7 | 
            +
                    self.raw =
         | 
| 8 | 
            +
                      (args.first.is_an?(Object) ? args.first.truthy? : !!args.first)
         | 
| 8 9 | 
             
                  end
         | 
| 9 10 |  | 
| 10 11 | 
             
                  def call(**args)
         | 
    
        data/lib/code/object/class.rb
    CHANGED
    
    
    
        data/lib/code/object/code.rb
    CHANGED
    
    
    
        data/lib/code/object/context.rb
    CHANGED
    
    
    
        data/lib/code/object/date.rb
    CHANGED
    
    | @@ -3,10 +3,10 @@ | |
| 3 3 | 
             
            class Code
         | 
| 4 4 | 
             
              class Object
         | 
| 5 5 | 
             
                class Date < Object
         | 
| 6 | 
            -
                  def initialize(*args, **_kargs, &)
         | 
| 7 | 
            -
                     | 
| 6 | 
            +
                  def initialize(*args, **_kargs, &_block)
         | 
| 7 | 
            +
                    self.raw = ::Date.parse(args.map(&:to_s).join("-"))
         | 
| 8 8 | 
             
                  rescue ::Date::Error
         | 
| 9 | 
            -
                     | 
| 9 | 
            +
                    self.raw = ::Date.current
         | 
| 10 10 | 
             
                  end
         | 
| 11 11 |  | 
| 12 12 | 
             
                  def self.call(**args)
         | 
    
        data/lib/code/object/decimal.rb
    CHANGED
    
    | @@ -3,8 +3,8 @@ | |
| 3 3 | 
             
            class Code
         | 
| 4 4 | 
             
              class Object
         | 
| 5 5 | 
             
                class Decimal < Object
         | 
| 6 | 
            -
                  def initialize(*args, **_kargs, &)
         | 
| 7 | 
            -
                     | 
| 6 | 
            +
                  def initialize(*args, **_kargs, &_block)
         | 
| 7 | 
            +
                    self.raw =
         | 
| 8 8 | 
             
                      if args.first.class.in?(NUMBER_CLASSES)
         | 
| 9 9 | 
             
                        if args.second.class.in?(NUMBER_CLASSES)
         | 
| 10 10 | 
             
                          args.first.to_s.to_d * (10**args.second.to_s.to_d)
         | 
| @@ -15,7 +15,7 @@ class Code | |
| 15 15 | 
             
                        0.to_d
         | 
| 16 16 | 
             
                      end
         | 
| 17 17 | 
             
                  rescue FloatDomainError
         | 
| 18 | 
            -
                     | 
| 18 | 
            +
                    self.raw = 0.to_d
         | 
| 19 19 | 
             
                  end
         | 
| 20 20 |  | 
| 21 21 | 
             
                  def call(**args)
         | 
| @@ -15,8 +15,8 @@ class Code | |
| 15 15 | 
             
                  delegate :code_two?, to: :code_size
         | 
| 16 16 | 
             
                  delegate :code_zero?, to: :code_size
         | 
| 17 17 |  | 
| 18 | 
            -
                  def initialize(*args, **kargs, &)
         | 
| 19 | 
            -
                     | 
| 18 | 
            +
                  def initialize(*args, **kargs, &_block)
         | 
| 19 | 
            +
                    self.raw =
         | 
| 20 20 | 
             
                      args
         | 
| 21 21 | 
             
                        .map do |arg|
         | 
| 22 22 | 
             
                          if arg.is_an?(::Hash)
         | 
| @@ -218,7 +218,7 @@ class Code | |
| 218 218 | 
             
                  end
         | 
| 219 219 |  | 
| 220 220 | 
             
                  def code_clear
         | 
| 221 | 
            -
                     | 
| 221 | 
            +
                    self.raw = {}
         | 
| 222 222 | 
             
                    self
         | 
| 223 223 | 
             
                  end
         | 
| 224 224 |  | 
| @@ -265,11 +265,19 @@ class Code | |
| 265 265 | 
             
                          .map
         | 
| 266 266 | 
             
                          .with_index do |code_argument, index|
         | 
| 267 267 | 
             
                            if code_default.nothing?
         | 
| 268 | 
            -
                              [ | 
| 268 | 
            +
                              [
         | 
| 269 | 
            +
                                code_argument,
         | 
| 270 | 
            +
                                code_delete(code_argument, index: index, **globals)
         | 
| 271 | 
            +
                              ]
         | 
| 269 272 | 
             
                            else
         | 
| 270 273 | 
             
                              [
         | 
| 271 274 | 
             
                                code_argument,
         | 
| 272 | 
            -
                                code_delete( | 
| 275 | 
            +
                                code_delete(
         | 
| 276 | 
            +
                                  code_argument,
         | 
| 277 | 
            +
                                  code_default,
         | 
| 278 | 
            +
                                  index: index,
         | 
| 279 | 
            +
                                  **globals
         | 
| 280 | 
            +
                                )
         | 
| 273 281 | 
             
                              ]
         | 
| 274 282 | 
             
                            end
         | 
| 275 283 | 
             
                          end
         | 
| @@ -378,11 +386,19 @@ class Code | |
| 378 386 | 
             
                          .map
         | 
| 379 387 | 
             
                          .with_index do |code_argument, index|
         | 
| 380 388 | 
             
                            if code_default.nothing?
         | 
| 381 | 
            -
                              [ | 
| 389 | 
            +
                              [
         | 
| 390 | 
            +
                                code_argument,
         | 
| 391 | 
            +
                                code_fetch(code_argument, index: index, **globals)
         | 
| 392 | 
            +
                              ]
         | 
| 382 393 | 
             
                            else
         | 
| 383 394 | 
             
                              [
         | 
| 384 395 | 
             
                                code_argument,
         | 
| 385 | 
            -
                                code_fetch( | 
| 396 | 
            +
                                code_fetch(
         | 
| 397 | 
            +
                                  code_argument,
         | 
| 398 | 
            +
                                  code_default,
         | 
| 399 | 
            +
                                  index: index,
         | 
| 400 | 
            +
                                  **globals
         | 
| 401 | 
            +
                                )
         | 
| 386 402 | 
             
                              ]
         | 
| 387 403 | 
             
                            end
         | 
| 388 404 | 
             
                          end
         | 
    
        data/lib/code/object/duration.rb
    CHANGED
    
    | @@ -3,8 +3,8 @@ | |
| 3 3 | 
             
            class Code
         | 
| 4 4 | 
             
              class Object
         | 
| 5 5 | 
             
                class Duration < Object
         | 
| 6 | 
            -
                  def initialize(*args, **_kargs, &)
         | 
| 7 | 
            -
                     | 
| 6 | 
            +
                  def initialize(*args, **_kargs, &_block)
         | 
| 7 | 
            +
                    self.raw =
         | 
| 8 8 | 
             
                      if args.first.is_an?(::ActiveSupport::Duration)
         | 
| 9 9 | 
             
                        args.first
         | 
| 10 10 | 
             
                      elsif args.first.is_a?(Duration)
         | 
| @@ -13,7 +13,7 @@ class Code | |
| 13 13 | 
             
                        ::ActiveSupport::Duration.parse(args.first.to_s)
         | 
| 14 14 | 
             
                      end
         | 
| 15 15 | 
             
                  rescue ::ActiveSupport::Duration::ISO8601Parser::ParsingError
         | 
| 16 | 
            -
                     | 
| 16 | 
            +
                    self.raw = 0.seconds
         | 
| 17 17 | 
             
                  end
         | 
| 18 18 |  | 
| 19 19 | 
             
                  def call(**args)
         |