Skip to content

Commit

Permalink
Merge branch 'main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp authored Nov 21, 2022
2 parents 43b65af + b208836 commit 1b91b71
Show file tree
Hide file tree
Showing 62 changed files with 563 additions and 543 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

on:
push:
branches:
- main

pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
ruby: [1.9, '2.0', 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, jruby-9.1, jruby-9.2]
gemfile: [no-deps, json-latest, json-old, json-pure]
exclude:
- ruby: '3.0'
gemfile: json-old
- ruby: 3.1
gemfile: json-old
- ruby: 1.9
gemfile: json-latest
- ruby: 1.9
gemfile: json-pure

steps:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

- uses: actions/checkout@v2

- name: Install gems
run: |
bundle install --gemfile=gemfiles/${{ matrix.gemfile }}.gemfile --without docs release benchmark
- name: Unit Tests
run: BUNDLE_GEMFILE=gemfiles/${{ matrix.gemfile }}.gemfile bundle exec rake test:unit

- name: Compliance Tests
run: BUNDLE_GEMFILE=gemfiles/${{ matrix.gemfile }}.gemfile bundle exec rake test:compliance
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tasks/release"]
path = tasks/release
url = https://github.com/aws/aws-sdk-ruby-release-tools.git
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion .yardopts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
--title 'jmespath.rb'
--output-dir docs
--markup markdown
--markup-provider rdiscount
--hide-api private
Expand Down
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
Unreleased Changes
1.6.1 (2022-03-07)
------------------

* Issue - Use `JSON.parse` instead of `JSON.load`.

1.6.0 (2022-02-14)
------------------

* Feature - Add support for string comparisons.

1.5.0 (2022-01-10)
------------------

* Support implicitly convertible objects/duck-type values responding to `to_hash` and `to_ary`.

[See related GitHub pull request #51](https://github.com/jmespath/jmespath.rb/pull/51).

1.4.0 (2018-04-04)
------------------

Expand Down Expand Up @@ -218,4 +232,3 @@ Unreleased Changes
------------------

* Passing all of the JMESPath compliance tests.

1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://rubygems.org'

gem 'rake', require: false
Expand Down
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true
$GEM_ROOT = File.dirname(__FILE__)

$: << File.join($GEM_ROOT, 'lib')
$LOAD_PATH << File.join($GEM_ROOT, 'lib')

$VERSION = ENV['VERSION'] || File.read(File.join($GEM_ROOT, 'VERSION'))
$GITHUB_ACCESS_TOKEN = ENV['JMESPATH_GITHUB_ACCESS_TOKEN']
Expand Down
5 changes: 5 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Reporting a Vulnerability

If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security
via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/) or directly via email to [email protected].
Please do **not** create a public GitHub issue.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.0
1.6.1
5 changes: 3 additions & 2 deletions bin/jmespath.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'jmespath'
require 'json'

expression = ARGV[0]
json = JSON.load(STDIN.read)
json = JSON.parse(STDIN.read)

$stdout.puts(JSON.dump(JMESPath.search(expression, json)))
1 change: 1 addition & 0 deletions gemfiles/json-latest.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
eval_gemfile(File.expand_path('../../Gemfile', __FILE__))

gem 'json'
1 change: 1 addition & 0 deletions gemfiles/json-old.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
eval_gemfile(File.expand_path('../../Gemfile', __FILE__))

gem 'json', '< 2.0'
1 change: 1 addition & 0 deletions gemfiles/json-pure.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
eval_gemfile(File.expand_path('../../Gemfile', __FILE__))

gem 'json_pure', require: 'json/pure'
1 change: 1 addition & 0 deletions gemfiles/no-deps.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
eval_gemfile(File.expand_path('../../Gemfile', __FILE__))

# no dependency on `json` gem
3 changes: 2 additions & 1 deletion jmespath.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Gem::Specification.new do |spec|
spec.name = 'jmespath'
spec.version = File.read(File.expand_path('../VERSION', __FILE__)).strip
Expand All @@ -9,5 +10,5 @@ Gem::Specification.new do |spec|
spec.license = 'Apache-2.0'
spec.require_paths = ['lib']
spec.executables = Dir['bin/**'].map &File.method(:basename)
spec.files = Dir['lib/**/*.rb'] + ['LICENSE.txt']
spec.files = Dir['lib/**/*.rb'] + %w(LICENSE.txt VERSION)
end
14 changes: 6 additions & 8 deletions lib/jmespath.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true
require 'json'
require 'stringio'
require 'pathname'

module JMESPath

require 'jmespath/caching_parser'
require 'jmespath/errors'
require 'jmespath/lexer'
Expand All @@ -16,26 +16,24 @@ module JMESPath
require 'jmespath/version'

class << self

# @param [String] expression A valid
# [JMESPath](https://github.com/boto/jmespath) expression.
# @param [Hash] data
# @return [Mixed,nil] Returns the matched values. Returns `nil` if the
# expression does not resolve inside `data`.
def search(expression, data, runtime_options = {})
data = case data
when Hash, Struct then data # check for most common case first
when Pathname then load_json(data)
when IO, StringIO then JSON.load(data.read)
else data
when Hash, Struct then data # check for most common case first
when Pathname then load_json(data)
when IO, StringIO then JSON.parse(data.read)
else data
end
Runtime.new(runtime_options).search(expression, data)
end

# @api private
def load_json(path)
JSON.load(File.open(path, 'r', encoding: 'UTF-8') { |f| f.read })
JSON.parse(File.open(path, 'r', encoding: 'UTF-8', &:read))
end

end
end
3 changes: 1 addition & 2 deletions lib/jmespath/caching_parser.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true
require 'thread'

module JMESPath
class CachingParser

def initialize(options = {})
@parser = options[:parser] || Parser.new(options)
@mutex = Mutex.new
Expand All @@ -25,6 +25,5 @@ def cache_expression(expression)
@cache[expression] = @parser.parse(expression)
end
end

end
end
4 changes: 2 additions & 2 deletions lib/jmespath/errors.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

module JMESPath
module Errors

class Error < StandardError; end

class RuntimeError < Error; end
Expand All @@ -14,6 +15,5 @@ class InvalidValueError < Error; end
class InvalidArityError < Error; end

class UnknownFunctionError < Error; end

end
end
Loading

0 comments on commit 1b91b71

Please sign in to comment.