code-ruby 0.7.0 → 0.7.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/Gemfile.lock +15 -15
- data/bin/code +21 -10
- data/lib/code/parser/whitespace.rb +1 -1
- data/lib/code/parser.rb +1 -1
- data/lib/code/version.rb +1 -1
- data/spec/code_spec.rb +1 -0
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a4443807269930ca7780ac7dea378b206922ceb64efd2c67268faf6dc4019ec3
         | 
| 4 | 
            +
              data.tar.gz: f02f48a5adf807a5d02e95906946161b005b0899ebf94be4707add11fccbdfb0
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f940cbc1443f45503c5200eec011b9e75057ef6cafd8519884432de7600d2137afc6559e1e5e96f616a6476910b1ace98558e2eba2260cbfac16f1819fde198b
         | 
| 7 | 
            +
              data.tar.gz: 8ca5252fdf014aecf582d52f0bf95a23ff74f34d96ac763c438d88cffd9f02add548303a5502462294f6d823328e4e0e3132313b57d014e358b6de5601ec351e
         | 
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                code-ruby (0. | 
| 4 | 
            +
                code-ruby (0.7.1)
         | 
| 5 5 | 
             
                  bigdecimal (~> 3)
         | 
| 6 6 | 
             
                  language-ruby (~> 0)
         | 
| 7 7 | 
             
                  zeitwerk (~> 2)
         | 
| @@ -10,24 +10,24 @@ GEM | |
| 10 10 | 
             
              remote: https://rubygems.org/
         | 
| 11 11 | 
             
              specs:
         | 
| 12 12 | 
             
                bigdecimal (3.1.6)
         | 
| 13 | 
            -
                diff-lcs (1.5. | 
| 14 | 
            -
                language-ruby (0.6. | 
| 13 | 
            +
                diff-lcs (1.5.1)
         | 
| 14 | 
            +
                language-ruby (0.6.2)
         | 
| 15 15 | 
             
                  zeitwerk (~> 2)
         | 
| 16 | 
            -
                rspec (3. | 
| 17 | 
            -
                  rspec-core (~> 3. | 
| 18 | 
            -
                  rspec-expectations (~> 3. | 
| 19 | 
            -
                  rspec-mocks (~> 3. | 
| 20 | 
            -
                rspec-core (3. | 
| 21 | 
            -
                  rspec-support (~> 3. | 
| 22 | 
            -
                rspec-expectations (3. | 
| 16 | 
            +
                rspec (3.13.0)
         | 
| 17 | 
            +
                  rspec-core (~> 3.13.0)
         | 
| 18 | 
            +
                  rspec-expectations (~> 3.13.0)
         | 
| 19 | 
            +
                  rspec-mocks (~> 3.13.0)
         | 
| 20 | 
            +
                rspec-core (3.13.0)
         | 
| 21 | 
            +
                  rspec-support (~> 3.13.0)
         | 
| 22 | 
            +
                rspec-expectations (3.13.0)
         | 
| 23 23 | 
             
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 24 | 
            -
                  rspec-support (~> 3. | 
| 25 | 
            -
                rspec-mocks (3. | 
| 24 | 
            +
                  rspec-support (~> 3.13.0)
         | 
| 25 | 
            +
                rspec-mocks (3.13.0)
         | 
| 26 26 | 
             
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 27 | 
            -
                  rspec-support (~> 3. | 
| 28 | 
            -
                rspec-support (3. | 
| 27 | 
            +
                  rspec-support (~> 3.13.0)
         | 
| 28 | 
            +
                rspec-support (3.13.0)
         | 
| 29 29 | 
             
                ruby-prof (1.7.0)
         | 
| 30 | 
            -
                zeitwerk (2.6. | 
| 30 | 
            +
                zeitwerk (2.6.13)
         | 
| 31 31 |  | 
| 32 32 | 
             
            PLATFORMS
         | 
| 33 33 | 
             
              arm64-darwin-23
         | 
    
        data/bin/code
    CHANGED
    
    | @@ -4,11 +4,18 @@ | |
| 4 4 | 
             
            require 'optparse'
         | 
| 5 5 | 
             
            require_relative '../lib/code-ruby'
         | 
| 6 6 |  | 
| 7 | 
            -
            options = { | 
| 7 | 
            +
            options = {
         | 
| 8 | 
            +
              timeout: 0,
         | 
| 9 | 
            +
              profile: false,
         | 
| 10 | 
            +
              profiler: 'text',
         | 
| 11 | 
            +
              input: "",
         | 
| 12 | 
            +
              context: "",
         | 
| 13 | 
            +
              parse: false
         | 
| 14 | 
            +
            }
         | 
| 8 15 |  | 
| 9 16 | 
             
            OptionParser
         | 
| 10 17 | 
             
              .new do |opts|
         | 
| 11 | 
            -
                opts.banner = 'Usage:  | 
| 18 | 
            +
                opts.banner = 'Usage: code [options]'
         | 
| 12 19 |  | 
| 13 20 | 
             
                opts.on('-v', '--version', 'Version of template') do |_input|
         | 
| 14 21 | 
             
                  puts Code::Version
         | 
| @@ -17,7 +24,7 @@ OptionParser | |
| 17 24 |  | 
| 18 25 | 
             
                opts.on(
         | 
| 19 26 | 
             
                  '-i INPUT',
         | 
| 20 | 
            -
                  '--input | 
| 27 | 
            +
                  '--input INPUT',
         | 
| 21 28 | 
             
                  'Input in the code language (String or File)'
         | 
| 22 29 | 
             
                ) do |input|
         | 
| 23 30 | 
             
                  input = File.read(input) if File.exist?(input)
         | 
| @@ -27,7 +34,7 @@ OptionParser | |
| 27 34 |  | 
| 28 35 | 
             
                opts.on(
         | 
| 29 36 | 
             
                  '-c CONTEXT',
         | 
| 30 | 
            -
                  '--context | 
| 37 | 
            +
                  '--context CONTEXT',
         | 
| 31 38 | 
             
                  'Context in the code language (String or File)'
         | 
| 32 39 | 
             
                ) do |context|
         | 
| 33 40 | 
             
                  context = File.read(context) if File.exist?(context)
         | 
| @@ -41,7 +48,7 @@ OptionParser | |
| 41 48 |  | 
| 42 49 | 
             
                opts.on(
         | 
| 43 50 | 
             
                  '-t TIMEOUT',
         | 
| 44 | 
            -
                  '--timeout | 
| 51 | 
            +
                  '--timeout TIMEOUT',
         | 
| 45 52 | 
             
                  'Set timeout in seconds'
         | 
| 46 53 | 
             
                ) { |timeout| options[:timeout] = timeout.to_f }
         | 
| 47 54 |  | 
| @@ -61,19 +68,23 @@ OptionParser | |
| 61 68 | 
             
              end
         | 
| 62 69 | 
             
              .parse!
         | 
| 63 70 |  | 
| 64 | 
            -
            input = options.fetch(:input, '')
         | 
| 65 | 
            -
            context = options.fetch(:context, '')
         | 
| 66 | 
            -
             | 
| 67 71 | 
             
            RubyProf.start if options[:profile]
         | 
| 68 72 |  | 
| 69 73 | 
             
            if options[:parse]
         | 
| 70 | 
            -
              pp Code::Parser.parse(input).to_raw
         | 
| 74 | 
            +
              pp Code::Parser.parse(options[:input]).to_raw
         | 
| 71 75 | 
             
            else
         | 
| 72 | 
            -
              print Code.evaluate( | 
| 76 | 
            +
              print Code.evaluate(
         | 
| 77 | 
            +
                options[:input],
         | 
| 78 | 
            +
                options[:context],
         | 
| 79 | 
            +
                output: $stdout,
         | 
| 80 | 
            +
                error: $stderr,
         | 
| 81 | 
            +
                timeout: options[:timeout]
         | 
| 82 | 
            +
              )
         | 
| 73 83 | 
             
            end
         | 
| 74 84 |  | 
| 75 85 | 
             
            if options[:profile]
         | 
| 76 86 | 
             
              result = RubyProf.stop
         | 
| 87 | 
            +
             | 
| 77 88 | 
             
              if options[:profiler] == 'text'
         | 
| 78 89 | 
             
                printer = RubyProf::FlatPrinter.new(result)
         | 
| 79 90 | 
             
                printer.print($stdout)
         | 
    
        data/lib/code/parser.rb
    CHANGED
    
    
    
        data/lib/code/version.rb
    CHANGED
    
    
    
        data/spec/code_spec.rb
    CHANGED