Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby 2.0.0 required #11

Closed
jhmartin opened this issue Nov 5, 2015 · 3 comments
Closed

Ruby 2.0.0 required #11

jhmartin opened this issue Nov 5, 2015 · 3 comments

Comments

@jhmartin
Copy link

jhmartin commented Nov 5, 2015

JMESPath 1.1.3 seems to require Ruby 2.0.0 for proper operation.

Under ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux] , I get:

RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/parser.rb:49:in `method_missing': unexpected token 0 (JMESPath::Errors::SyntaxError)
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/parser.rb:60:in `expr'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/parser.rb:145:in `led_comparator'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/parser.rb:62:in `expr'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/parser.rb:161:in `led_filter'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/parser.rb:62:in `expr'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/parser.rb:267:in `parse_multi_select_list'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/parser.rb:117:in `nud_lbracket'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/parser.rb:60:in `expr'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/parser.rb:212:in `led_pipe'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/parser.rb:62:in `expr'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/parser.rb:38:in `parse'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/caching_parser.rb:25:in `block in cache_expression'
    from <internal:prelude>:10:in `synchronize'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/caching_parser.rb:23:in `cache_expression'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/caching_parser.rb:16:in `parse'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath/runtime.rb:51:in `search'
    from RUBYROOT/ruby/gems/1.9.1/gems/jmespath-1.1.3/lib/jmespath.rb:33:in `search'
    from /tmp/a.rb:8:in `<main>'

Input:

{
    "failures": [],
    "services": [
        {
            "clusterArn": "arn:aws:ecs:us-east-1:3:cluster/QA",
            "deployments": [
                {
                    "createdAt": 1446670761.244,
                    "desiredCount": 1,
                    "id": "ecs-svc/9",
                    "pendingCount": 0,
                    "runningCount": 1,
                    "status": "PRIMARY",
                    "taskDefinition": "arn:aws:ecs:us-east-1:3:task-definition/foo:15",
                    "updatedAt": 2.244
                }
            ],
            "desiredCount": 1,
            "events": [
                {
                    "createdAt": 1.651,
                    "id": "0542993e-ab0e-x-86fa-55d544103377",
                    "message": "(service ) has reached a steady state."
                }
            ],
            "loadBalancers": [],
            "pendingCount": 0,
            "runningCount": 1,
            "serviceArn": "arn:aws:ecs:us-east-1:3:service/FOO",
            "serviceName": "FOO",
            "status": "ACTIVE",
            "taskDefinition": "arn:aws:ecs:us-east-1:3:task-definition/FOO:15"
        }
    ]
}

Script:

require 'jmespath'
require 'pp'

pp JMESPath.search('services[0] | [@[?length(deployments)!=`1`], @[?desiredCount!=runningCount]]', Pathname.new('/tmp/a'))

Under ruby 2.0.0p645 (2015-04-13 revision 50299) [x86_64-linux] I get:

[nil, nil]
@trevorrowe
Copy link
Contributor

Thanks for reporting this issue. I've been able to reproduce it locally. It appears that the JSON.load method behaves different between Ruby 1.9.3 and 2.0.0+:

# ruby 2.0.0+
JSON.load("1")
#=> 1

# ruby 1.9.3
JSON.load("1")
#=> raises JSON::ParserError: A JSON text must at least contain two octets!

I'm going to have to see what alternatives there are in Ruby 1.9.3 for extracting JSON values from lexed strings.

@dmoskalik
Copy link

I'm using ruby version 1.87 and it seems like it does not work either. Does it really require ruby 1.9.3?
For me the problem is the splat operator in field.rb:
ChainedField.new([@keys, other.keys])
Any suggestions how to change it to be compatible with ruby 1.8.7?
I had to change also all
function(match:valid_keys)
to:
function({ :match => valid_keys})

@trevorrowe
Copy link
Contributor

@dmoskalik I just pushed a fix for the Ruby 1.9.3 support. I can look at support 1.8.7, but I make no promises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants