jgrep 1.5.4 → 1.6.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/.github/dependabot.yml +17 -0
- data/.github/labeler.yml +5 -0
- data/.github/release.yml +41 -0
- data/.github/workflows/labeler.yml +17 -0
- data/.github/workflows/release.yml +106 -0
- data/.github/workflows/test.yml +66 -0
- data/CHANGELOG.md +117 -0
- data/{README.markdown → README.md} +22 -15
- data/Rakefile +17 -5
- data/lib/jgrep.rb +33 -5
- data/lib/parser/version.rb +5 -0
- data/spec/spec_helper.rb +1 -1
- metadata +74 -20
- data/CHANGELOG.markdown +0 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 06554a2c3f1b5de67b6f0881fb0770e0d58a6485ac1f9e8c963fde205f4ee00e
|
|
4
|
+
data.tar.gz: d6de6c85c5681f9150e35677b5e954654c13ef94c60da1371060a22a7c0a727d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: db91b159588a4874e906fdc1b050fe562656c8c50f5f81e1b077d166c2fe637133cdda42ba920e12ba376f0374d279e323eecec4b7ddc12b3fb04d8a6dd65e7d
|
|
7
|
+
data.tar.gz: a49cf67fbe3920fe253040aa86093b2c3466ca8f037d1400102da164f691f92c04549efaf7fbc9617377f6e1f32a406bf59b5c1d5b6a8f421952f981ffb8790b
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
# raise PRs for gem updates
|
|
4
|
+
- package-ecosystem: bundler
|
|
5
|
+
directory: "/"
|
|
6
|
+
schedule:
|
|
7
|
+
interval: daily
|
|
8
|
+
time: "13:00"
|
|
9
|
+
open-pull-requests-limit: 10
|
|
10
|
+
|
|
11
|
+
# Maintain dependencies for GitHub Actions
|
|
12
|
+
- package-ecosystem: github-actions
|
|
13
|
+
directory: "/"
|
|
14
|
+
schedule:
|
|
15
|
+
interval: daily
|
|
16
|
+
time: "13:00"
|
|
17
|
+
open-pull-requests-limit: 10
|
data/.github/labeler.yml
ADDED
data/.github/release.yml
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
|
|
3
|
+
|
|
4
|
+
changelog:
|
|
5
|
+
exclude:
|
|
6
|
+
labels:
|
|
7
|
+
- duplicate
|
|
8
|
+
- invalid
|
|
9
|
+
- modulesync
|
|
10
|
+
- question
|
|
11
|
+
- skip-changelog
|
|
12
|
+
- wont-fix
|
|
13
|
+
- wontfix
|
|
14
|
+
- github_actions
|
|
15
|
+
|
|
16
|
+
categories:
|
|
17
|
+
- title: Breaking Changes 🛠
|
|
18
|
+
labels:
|
|
19
|
+
- backwards-incompatible
|
|
20
|
+
|
|
21
|
+
- title: New Features 🎉
|
|
22
|
+
labels:
|
|
23
|
+
- enhancement
|
|
24
|
+
|
|
25
|
+
- title: Bug Fixes 🐛
|
|
26
|
+
labels:
|
|
27
|
+
- bug
|
|
28
|
+
- bugfix
|
|
29
|
+
|
|
30
|
+
- title: Documentation Updates 📚
|
|
31
|
+
labels:
|
|
32
|
+
- documentation
|
|
33
|
+
- docs
|
|
34
|
+
|
|
35
|
+
- title: Dependency Updates ⬆️
|
|
36
|
+
labels:
|
|
37
|
+
- dependencies
|
|
38
|
+
|
|
39
|
+
- title: Other Changes
|
|
40
|
+
labels:
|
|
41
|
+
- "*"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 🏷️ Pull Request Labeler
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
- pull_request_target
|
|
6
|
+
|
|
7
|
+
permissions: {}
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
labeler:
|
|
11
|
+
name: Labeler
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
if: github.repository_owner == 'voxpupuli' || github.repository_owner == 'OpenVoxProject'
|
|
14
|
+
permissions:
|
|
15
|
+
pull-requests: write
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/labeler@bf12e9b00b37c5c0ca2b87b79b2daf7891dbda13 # v7.0.0
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Gem Release
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
tags:
|
|
7
|
+
- '*'
|
|
8
|
+
|
|
9
|
+
permissions: {}
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build-release:
|
|
13
|
+
# Prevent releases from forked repositories
|
|
14
|
+
if: github.repository_owner == 'voxpupuli'
|
|
15
|
+
name: Build the gem
|
|
16
|
+
runs-on: ubuntu-24.04
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
19
|
+
- name: Install Ruby
|
|
20
|
+
uses: ruby/setup-ruby@651ff0d62c5c79bed6d53ec518387aae20e72c1a # v1.329.0
|
|
21
|
+
with:
|
|
22
|
+
ruby-version: 'ruby'
|
|
23
|
+
- name: Build gem
|
|
24
|
+
shell: bash
|
|
25
|
+
run: gem build --verbose *.gemspec
|
|
26
|
+
- name: Upload gem to GitHub cache
|
|
27
|
+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
28
|
+
with:
|
|
29
|
+
name: gem-artifact
|
|
30
|
+
path: '*.gem'
|
|
31
|
+
retention-days: 1
|
|
32
|
+
compression-level: 0
|
|
33
|
+
|
|
34
|
+
create-github-release:
|
|
35
|
+
needs: build-release
|
|
36
|
+
name: Create GitHub release
|
|
37
|
+
runs-on: ubuntu-24.04
|
|
38
|
+
permissions:
|
|
39
|
+
contents: write # clone repo and create release
|
|
40
|
+
steps:
|
|
41
|
+
- name: Download gem from GitHub cache
|
|
42
|
+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
43
|
+
with:
|
|
44
|
+
name: gem-artifact
|
|
45
|
+
- name: Create Release
|
|
46
|
+
shell: bash
|
|
47
|
+
env:
|
|
48
|
+
GH_TOKEN: ${{ github.token }}
|
|
49
|
+
run: gh release create --repo ${{ github.repository }} ${{ github.ref_name }} --generate-notes *.gem
|
|
50
|
+
|
|
51
|
+
release-to-github:
|
|
52
|
+
needs: build-release
|
|
53
|
+
name: Release to GitHub
|
|
54
|
+
runs-on: ubuntu-24.04
|
|
55
|
+
permissions:
|
|
56
|
+
packages: write # publish to rubygems.pkg.github.com
|
|
57
|
+
steps:
|
|
58
|
+
- name: Download gem from GitHub cache
|
|
59
|
+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
60
|
+
with:
|
|
61
|
+
name: gem-artifact
|
|
62
|
+
- name: Publish gem to GitHub packages
|
|
63
|
+
run: gem push --host https://rubygems.pkg.github.com/${{ github.repository_owner }} *.gem
|
|
64
|
+
env:
|
|
65
|
+
GEM_HOST_API_KEY: ${{ secrets.GITHUB_TOKEN }}
|
|
66
|
+
|
|
67
|
+
release-to-rubygems:
|
|
68
|
+
needs: build-release
|
|
69
|
+
name: Release gem to rubygems.org
|
|
70
|
+
runs-on: ubuntu-24.04
|
|
71
|
+
environment: release # recommended by rubygems.org
|
|
72
|
+
permissions:
|
|
73
|
+
id-token: write # rubygems.org authentication
|
|
74
|
+
steps:
|
|
75
|
+
- name: Download gem from GitHub cache
|
|
76
|
+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
77
|
+
with:
|
|
78
|
+
name: gem-artifact
|
|
79
|
+
- uses: rubygems/configure-rubygems-credentials@dc5a8d8553e6ee01fc26761a49e99e733d17954a # v2.1.0
|
|
80
|
+
- name: Publish gem to rubygems.org
|
|
81
|
+
shell: bash
|
|
82
|
+
run: gem push *.gem
|
|
83
|
+
|
|
84
|
+
release-verification:
|
|
85
|
+
name: Check that all releases are done
|
|
86
|
+
runs-on: ubuntu-24.04
|
|
87
|
+
permissions:
|
|
88
|
+
contents: read # minimal permissions that we have to grant
|
|
89
|
+
needs:
|
|
90
|
+
- create-github-release
|
|
91
|
+
- release-to-github
|
|
92
|
+
- release-to-rubygems
|
|
93
|
+
steps:
|
|
94
|
+
- name: Download gem from GitHub cache
|
|
95
|
+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
96
|
+
with:
|
|
97
|
+
name: gem-artifact
|
|
98
|
+
- name: Install Ruby
|
|
99
|
+
uses: ruby/setup-ruby@651ff0d62c5c79bed6d53ec518387aae20e72c1a # v1.329.0
|
|
100
|
+
with:
|
|
101
|
+
ruby-version: 'ruby'
|
|
102
|
+
- name: Wait for release to propagate
|
|
103
|
+
shell: bash
|
|
104
|
+
run: |
|
|
105
|
+
gem install rubygems-await
|
|
106
|
+
gem await *.gem
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Test
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
pull_request: {}
|
|
6
|
+
push:
|
|
7
|
+
branches:
|
|
8
|
+
- main
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
name: Ruby ${{ matrix.ruby }}
|
|
16
|
+
runs-on: ubuntu-24.04
|
|
17
|
+
strategy:
|
|
18
|
+
fail-fast: false
|
|
19
|
+
matrix:
|
|
20
|
+
ruby:
|
|
21
|
+
- '3.3'
|
|
22
|
+
- '3.4'
|
|
23
|
+
- '4.0'
|
|
24
|
+
steps:
|
|
25
|
+
- name: Check out repository
|
|
26
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
27
|
+
|
|
28
|
+
- name: Set up Ruby
|
|
29
|
+
uses: ruby/setup-ruby@651ff0d62c5c79bed6d53ec518387aae20e72c1a # v1.329.0
|
|
30
|
+
with:
|
|
31
|
+
ruby-version: ${{ matrix.ruby }}
|
|
32
|
+
bundler-cache: true
|
|
33
|
+
|
|
34
|
+
- name: Run specs
|
|
35
|
+
run: bundle exec rake spec
|
|
36
|
+
|
|
37
|
+
- name: Run rubocop
|
|
38
|
+
run: bundle exec rake rubocop
|
|
39
|
+
|
|
40
|
+
tests:
|
|
41
|
+
if: always()
|
|
42
|
+
needs:
|
|
43
|
+
- test
|
|
44
|
+
runs-on: ubuntu-24.04
|
|
45
|
+
name: Test suite
|
|
46
|
+
steps:
|
|
47
|
+
- name: Decide whether the needed jobs succeeded or failed
|
|
48
|
+
uses: re-actors/alls-green@release/v1
|
|
49
|
+
with:
|
|
50
|
+
jobs: ${{ toJSON(needs) }}
|
|
51
|
+
|
|
52
|
+
dependabot:
|
|
53
|
+
name: Dependabot auto-merge
|
|
54
|
+
if: github.event_name == 'pull_request' && (github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'renovate[bot]')
|
|
55
|
+
needs:
|
|
56
|
+
- tests
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
permissions:
|
|
59
|
+
contents: write
|
|
60
|
+
pull-requests: write
|
|
61
|
+
steps:
|
|
62
|
+
- name: Enable auto-merge for Dependabot PR
|
|
63
|
+
env:
|
|
64
|
+
GH_TOKEN: ${{ github.token }}
|
|
65
|
+
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
66
|
+
run: gh pr merge --auto --merge "$PR_URL"
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [1.6.0](https://github.com/voxpupuli/JSON-Grep/tree/1.6.0) (2026-10-14)
|
|
6
|
+
|
|
7
|
+
[Full Changelog](https://github.com/voxpupuli/JSON-Grep/compare/1.5.4...1.6.0)
|
|
8
|
+
|
|
9
|
+
**Implemented enhancements:**
|
|
10
|
+
|
|
11
|
+
- feat: add voxpupuli-rubocop [\#62](https://github.com/voxpupuli/JSON-Grep/pull/62) ([rwaffen](https://github.com/rwaffen))
|
|
12
|
+
- feat: make it work with json 3 [\#61](https://github.com/voxpupuli/JSON-Grep/pull/61) ([rwaffen](https://github.com/rwaffen))
|
|
13
|
+
- feat: change to github changelog generator [\#60](https://github.com/voxpupuli/JSON-Grep/pull/60) ([rwaffen](https://github.com/rwaffen))
|
|
14
|
+
|
|
15
|
+
**Fixed bugs:**
|
|
16
|
+
|
|
17
|
+
- fix: cleanup gemspec after transfer; make it work with ruby 4 [\#59](https://github.com/voxpupuli/JSON-Grep/pull/59) ([rwaffen](https://github.com/rwaffen))
|
|
18
|
+
|
|
19
|
+
**Merged pull requests:**
|
|
20
|
+
|
|
21
|
+
- Update voxpupuli-rubocop requirement from ~\> 5.2.0 to ~\> 5.3.0 [\#67](https://github.com/voxpupuli/JSON-Grep/pull/67) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
22
|
+
- docs: update readme and add transfer notice [\#58](https://github.com/voxpupuli/JSON-Grep/pull/58) ([rwaffen](https://github.com/rwaffen))
|
|
23
|
+
- Provide basic documentation using yardoc tags [\#53](https://github.com/voxpupuli/JSON-Grep/pull/53) ([ekohl](https://github.com/ekohl))
|
|
24
|
+
- Update README.markdown: or example [\#52](https://github.com/voxpupuli/JSON-Grep/pull/52) ([skx](https://github.com/skx))
|
|
25
|
+
- Make spec\_helper load jgrep without a relative path [\#51](https://github.com/voxpupuli/JSON-Grep/pull/51) ([lelutin](https://github.com/lelutin))
|
|
26
|
+
|
|
27
|
+
## [1.5.4](https://github.com/voxpupuli/JSON-Grep/tree/1.5.4) (2020-09-10)
|
|
28
|
+
|
|
29
|
+
[Full Changelog](https://github.com/voxpupuli/JSON-Grep/compare/1.5.3...1.5.4)
|
|
30
|
+
|
|
31
|
+
**Closed issues:**
|
|
32
|
+
|
|
33
|
+
- Ruby 2.7 support [\#46](https://github.com/voxpupuli/JSON-Grep/issues/46)
|
|
34
|
+
|
|
35
|
+
**Merged pull requests:**
|
|
36
|
+
|
|
37
|
+
- Release 1.5.4 [\#50](https://github.com/voxpupuli/JSON-Grep/pull/50) ([ploubser](https://github.com/ploubser))
|
|
38
|
+
- Release 1.5.3 [\#49](https://github.com/voxpupuli/JSON-Grep/pull/49) ([ploubser](https://github.com/ploubser))
|
|
39
|
+
- Bump rake version in Gemfile [\#48](https://github.com/voxpupuli/JSON-Grep/pull/48) ([ploubser](https://github.com/ploubser))
|
|
40
|
+
- Fix Ruby 2.7.0 deprecation warnings [\#47](https://github.com/voxpupuli/JSON-Grep/pull/47) ([ploubser](https://github.com/ploubser))
|
|
41
|
+
|
|
42
|
+
## [1.5.3](https://github.com/voxpupuli/JSON-Grep/tree/1.5.3) (2020-08-10)
|
|
43
|
+
|
|
44
|
+
[Full Changelog](https://github.com/voxpupuli/JSON-Grep/compare/1.5.0...1.5.3)
|
|
45
|
+
|
|
46
|
+
**Closed issues:**
|
|
47
|
+
|
|
48
|
+
- unused methods [\#40](https://github.com/voxpupuli/JSON-Grep/issues/40)
|
|
49
|
+
|
|
50
|
+
**Merged pull requests:**
|
|
51
|
+
|
|
52
|
+
- Release 1.5.2 [\#45](https://github.com/voxpupuli/JSON-Grep/pull/45) ([ploubser](https://github.com/ploubser))
|
|
53
|
+
- Escape period in JGrep.format float regex [\#44](https://github.com/voxpupuli/JSON-Grep/pull/44) ([rodjek](https://github.com/rodjek))
|
|
54
|
+
- Release 1.5.1 [\#43](https://github.com/voxpupuli/JSON-Grep/pull/43) ([ploubser](https://github.com/ploubser))
|
|
55
|
+
- Handle escaped parens when tokenising statements [\#42](https://github.com/voxpupuli/JSON-Grep/pull/42) ([rodjek](https://github.com/rodjek))
|
|
56
|
+
|
|
57
|
+
## [1.5.0](https://github.com/voxpupuli/JSON-Grep/tree/1.5.0) (2017-08-09)
|
|
58
|
+
|
|
59
|
+
[Full Changelog](https://github.com/voxpupuli/JSON-Grep/compare/1.4.1...1.5.0)
|
|
60
|
+
|
|
61
|
+
**Closed issues:**
|
|
62
|
+
|
|
63
|
+
- utility to validate an expression is valid [\#31](https://github.com/voxpupuli/JSON-Grep/issues/31)
|
|
64
|
+
- remove json dependency for ruby \> 1.8 [\#30](https://github.com/voxpupuli/JSON-Grep/issues/30)
|
|
65
|
+
|
|
66
|
+
**Merged pull requests:**
|
|
67
|
+
|
|
68
|
+
- Remove some apaprently dead code [\#41](https://github.com/voxpupuli/JSON-Grep/pull/41) ([ripienaar](https://github.com/ripienaar))
|
|
69
|
+
- Bin cleanup [\#39](https://github.com/voxpupuli/JSON-Grep/pull/39) ([ripienaar](https://github.com/ripienaar))
|
|
70
|
+
- fix readme markup [\#38](https://github.com/voxpupuli/JSON-Grep/pull/38) ([ripienaar](https://github.com/ripienaar))
|
|
71
|
+
- Rubocop for specs [\#37](https://github.com/voxpupuli/JSON-Grep/pull/37) ([ripienaar](https://github.com/ripienaar))
|
|
72
|
+
- Convert specs to RSpec 3.6.0 syntax [\#36](https://github.com/voxpupuli/JSON-Grep/pull/36) ([ripienaar](https://github.com/ripienaar))
|
|
73
|
+
- Basic rubocop setup on lib/ spec maybe later [\#35](https://github.com/voxpupuli/JSON-Grep/pull/35) ([ripienaar](https://github.com/ripienaar))
|
|
74
|
+
- Remove json dependency as modern ruby satisfies this magically [\#34](https://github.com/voxpupuli/JSON-Grep/pull/34) ([ripienaar](https://github.com/ripienaar))
|
|
75
|
+
- Add utility to validate expressions [\#33](https://github.com/voxpupuli/JSON-Grep/pull/33) ([ripienaar](https://github.com/ripienaar))
|
|
76
|
+
- Retabs the code for more modern Ruby style [\#32](https://github.com/voxpupuli/JSON-Grep/pull/32) ([ripienaar](https://github.com/ripienaar))
|
|
77
|
+
|
|
78
|
+
## [1.4.1](https://github.com/voxpupuli/JSON-Grep/tree/1.4.1) (2016-05-17)
|
|
79
|
+
|
|
80
|
+
[Full Changelog](https://github.com/voxpupuli/JSON-Grep/compare/1.4.0...1.4.1)
|
|
81
|
+
|
|
82
|
+
**Merged pull requests:**
|
|
83
|
+
|
|
84
|
+
- Exit with 1 when no records found [\#29](https://github.com/voxpupuli/JSON-Grep/pull/29) ([mcanevet](https://github.com/mcanevet))
|
|
85
|
+
|
|
86
|
+
## [1.4.0](https://github.com/voxpupuli/JSON-Grep/tree/1.4.0) (2015-11-25)
|
|
87
|
+
|
|
88
|
+
[Full Changelog](https://github.com/voxpupuli/JSON-Grep/compare/0058cb91f93dd2b31a2caf5153bf3ccedd604296...1.4.0)
|
|
89
|
+
|
|
90
|
+
**Closed issues:**
|
|
91
|
+
|
|
92
|
+
- STDIN detection logic prevents programmatic execution [\#24](https://github.com/voxpupuli/JSON-Grep/issues/24)
|
|
93
|
+
- Extract specific matching document from array of matching documents [\#22](https://github.com/voxpupuli/JSON-Grep/issues/22)
|
|
94
|
+
- Where did the -n option go? [\#19](https://github.com/voxpupuli/JSON-Grep/issues/19)
|
|
95
|
+
- should not exit on json parse errors [\#14](https://github.com/voxpupuli/JSON-Grep/issues/14)
|
|
96
|
+
- Missing dependency for "json" gem [\#9](https://github.com/voxpupuli/JSON-Grep/issues/9)
|
|
97
|
+
- Feature request: regex or wildcard matching on fields [\#8](https://github.com/voxpupuli/JSON-Grep/issues/8)
|
|
98
|
+
- Should take a starting position as argument [\#6](https://github.com/voxpupuli/JSON-Grep/issues/6)
|
|
99
|
+
- Sub documents thats not hashes [\#4](https://github.com/voxpupuli/JSON-Grep/issues/4)
|
|
100
|
+
- Short hand to check presence of a key [\#3](https://github.com/voxpupuli/JSON-Grep/issues/3)
|
|
101
|
+
- Support matching on null [\#2](https://github.com/voxpupuli/JSON-Grep/issues/2)
|
|
102
|
+
- nagative matching [\#1](https://github.com/voxpupuli/JSON-Grep/issues/1)
|
|
103
|
+
|
|
104
|
+
**Merged pull requests:**
|
|
105
|
+
|
|
106
|
+
- Merge 1.3.3 and enable Travis CI [\#27](https://github.com/voxpupuli/JSON-Grep/pull/27) ([domcleal](https://github.com/domcleal))
|
|
107
|
+
- Filter performance optimisations [\#26](https://github.com/voxpupuli/JSON-Grep/pull/26) ([domcleal](https://github.com/domcleal))
|
|
108
|
+
- Support matching boolean values. [\#20](https://github.com/voxpupuli/JSON-Grep/pull/20) ([bladealslayer](https://github.com/bladealslayer))
|
|
109
|
+
- clarify that you need to use a space when specifying multiple fields for s flag [\#15](https://github.com/voxpupuli/JSON-Grep/pull/15) ([jkoppe](https://github.com/jkoppe))
|
|
110
|
+
- Allow the -s argument to be supplied multiple times or singly as a space seperated list [\#13](https://github.com/voxpupuli/JSON-Grep/pull/13) ([ripienaar](https://github.com/ripienaar))
|
|
111
|
+
- Add -q / --quiet silent mode and exit codes [\#11](https://github.com/voxpupuli/JSON-Grep/pull/11) ([zsprackett](https://github.com/zsprackett))
|
|
112
|
+
- Add support for starting in a sub document making it easier to integrate [\#7](https://github.com/voxpupuli/JSON-Grep/pull/7) ([ripienaar](https://github.com/ripienaar))
|
|
113
|
+
- Some README formatting cleanups. [\#5](https://github.com/voxpupuli/JSON-Grep/pull/5) ([kbarber](https://github.com/kbarber))
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
JGrep
|
|
1
|
+
# JGrep
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
... is a command line tool and API for parsing JSON documents based on logical expressions.
|
|
4
|
+
|
|
5
|
+
## Installation:
|
|
4
6
|
|
|
5
7
|
jgrep is available as a gem:
|
|
6
8
|
|
|
7
9
|
gem install jgrep
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
## JGrep binary usage
|
|
10
12
|
|
|
11
13
|
jgrep [expression] -i foo.json
|
|
12
14
|
|
|
@@ -14,7 +16,7 @@ or
|
|
|
14
16
|
|
|
15
17
|
cat "foo.json" | jgrep [expression]
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
## Flags
|
|
18
20
|
|
|
19
21
|
-s, --simple [FIELDS] : Greps the JSON and only returns the value of the field(s) specified
|
|
20
22
|
-c, --compat : Returns the JSON in its non-pretty flat form
|
|
@@ -26,7 +28,7 @@ or
|
|
|
26
28
|
--start FIELD : Starts the grep at a specific key in the document
|
|
27
29
|
--slice [RANGE] : A range of the form 'n' or 'n..m', indicating which documents to extract from the final output
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
## Expressions
|
|
30
32
|
|
|
31
33
|
JGrep uses the following logical symbols to define expressions.
|
|
32
34
|
|
|
@@ -36,7 +38,7 @@ JGrep uses the following logical symbols to define expressions.
|
|
|
36
38
|
Evaluates to true if both statements are true
|
|
37
39
|
|
|
38
40
|
'or' :
|
|
39
|
-
- [statement]
|
|
41
|
+
- [statement] or [statement]
|
|
40
42
|
|
|
41
43
|
Evaluates true if either statement is true
|
|
42
44
|
|
|
@@ -62,7 +64,7 @@ JGrep uses the following logical symbols to define expressions.
|
|
|
62
64
|
|
|
63
65
|
Performs the operations inside the perentheses first.
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
## Statements
|
|
66
68
|
|
|
67
69
|
A statement is defined as some value in a json document compared to another value.
|
|
68
70
|
Available comparison operators are '=', '<', '>', '<=', '>='
|
|
@@ -73,7 +75,7 @@ Examples:
|
|
|
73
75
|
foo.bar>0
|
|
74
76
|
foo.bar<=1.3
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
## Complex expressions
|
|
77
79
|
|
|
78
80
|
Given a json document, {"foo":1, "bar":null}, the following are examples of valid expressions
|
|
79
81
|
|
|
@@ -95,12 +97,12 @@ Examples:
|
|
|
95
97
|
|
|
96
98
|
... returns true
|
|
97
99
|
|
|
98
|
-
|
|
100
|
+
## CLI missing an expression
|
|
99
101
|
|
|
100
102
|
If JGrep is executed without a set expression, it will return an unmodified JSON document. The
|
|
101
103
|
-s flag can still be applied to the result.
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
## In document comparison
|
|
104
106
|
|
|
105
107
|
If a document contains an array, the '[' and ']' operators can be used to define a comparison where
|
|
106
108
|
statements are checked for truth on a per element basis which will then be combined.
|
|
@@ -152,7 +154,7 @@ will return
|
|
|
152
154
|
|
|
153
155
|
**Note**: In document comparison cannot be nested.
|
|
154
156
|
|
|
155
|
-
|
|
157
|
+
## The -s flag
|
|
156
158
|
|
|
157
159
|
The s flag simplifies the output returned by JGrep. Given a JSON document
|
|
158
160
|
|
|
@@ -190,7 +192,7 @@ will output
|
|
|
190
192
|
}
|
|
191
193
|
]
|
|
192
194
|
|
|
193
|
-
|
|
195
|
+
## The --start flag
|
|
194
196
|
|
|
195
197
|
Some documents do not comply to our expected format, they might have an array embedded deep in a field. The --start
|
|
196
198
|
flag lets you pick a starting point for the grep.
|
|
@@ -211,7 +213,7 @@ $ cat my.json | jgrep --start results name=Jack -s surname
|
|
|
211
213
|
Smith
|
|
212
214
|
</pre>
|
|
213
215
|
|
|
214
|
-
|
|
216
|
+
## The --slice flag
|
|
215
217
|
|
|
216
218
|
Allows the user to provide an int or range to slice an array of
|
|
217
219
|
results with, in particular so a single element can be extracted, e.g.
|
|
@@ -224,13 +226,13 @@ results with, in particular so a single element can be extracted, e.g.
|
|
|
224
226
|
}
|
|
225
227
|
}
|
|
226
228
|
|
|
227
|
-
|
|
229
|
+
## The --stream flag
|
|
228
230
|
|
|
229
231
|
With the --stream or -n flag, jgrep will process multiple JSON inputs (newline
|
|
230
232
|
separated) until standard input is closed. Each JSON input will be processed
|
|
231
233
|
as usual, but the output immediately printed.
|
|
232
234
|
|
|
233
|
-
|
|
235
|
+
## JGrep Gem usage
|
|
234
236
|
|
|
235
237
|
require 'jgrep'
|
|
236
238
|
|
|
@@ -243,3 +245,8 @@ as usual, but the output immediately printed.
|
|
|
243
245
|
|
|
244
246
|
JGrep::jgrep(json, expression, sflags)
|
|
245
247
|
|
|
248
|
+
## Transfer Notice
|
|
249
|
+
|
|
250
|
+
This project was originally authored by [Pieter Loubser](https://github.com/ploubser).
|
|
251
|
+
The maintainer preferred that Vox Pupuli take ownership of the project for future improvement and maintenance.
|
|
252
|
+
Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of ploubser/JSON-Grep.
|
data/Rakefile
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
require 'rspec/core/rake_task'
|
|
2
|
+
require 'voxpupuli/rubocop/rake'
|
|
2
3
|
|
|
3
4
|
RSpec::Core::RakeTask.new(:spec)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
task :
|
|
7
|
-
sh("rubocop -f progress -f offenses lib spec bin")
|
|
8
|
-
end
|
|
6
|
+
task test: %i[spec rubocop]
|
|
7
|
+
task default: %i[test]
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
begin
|
|
10
|
+
require 'rubygems'
|
|
11
|
+
require 'github_changelog_generator/task'
|
|
12
|
+
rescue LoadError
|
|
13
|
+
# github_changelog_generator isn't available, so we won't define a rake task with it
|
|
14
|
+
else
|
|
15
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
|
16
|
+
config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file."
|
|
17
|
+
config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog modulesync github_actions]
|
|
18
|
+
config.user = 'voxpupuli'
|
|
19
|
+
config.project = 'JSON-Grep'
|
|
20
|
+
config.future_release = Gem::Specification.load('jgrep.gemspec').version
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/jgrep.rb
CHANGED
|
@@ -7,23 +7,31 @@ module JGrep
|
|
|
7
7
|
@verbose = false
|
|
8
8
|
@flatten = false
|
|
9
9
|
|
|
10
|
+
# @return [nil]
|
|
10
11
|
def self.verbose_on
|
|
11
12
|
@verbose = true
|
|
12
13
|
end
|
|
13
14
|
|
|
15
|
+
# @return [nil]
|
|
14
16
|
def self.flatten_on
|
|
15
17
|
@flatten = true
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
# Parse json and return documents that match the logical expression
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
21
|
+
#
|
|
22
|
+
# @param json [String]
|
|
23
|
+
# The data to grep through.
|
|
24
|
+
# @param expression [String]
|
|
25
|
+
# The expression to filter the data.
|
|
26
|
+
# @param filters
|
|
27
|
+
# Define output by limiting it to only returning the listed keys.
|
|
28
|
+
# @param start
|
|
29
|
+
# Allows you to move the pointer indicating where parsing starts.
|
|
30
|
+
# Default is the first key in the document hierarchy
|
|
22
31
|
def self.jgrep(json, expression, filters = nil, start = nil)
|
|
23
32
|
errors = ""
|
|
24
33
|
|
|
25
34
|
begin
|
|
26
|
-
JSON.create_id = nil
|
|
27
35
|
json = JSON.parse(json)
|
|
28
36
|
json = [json] if json.is_a?(Hash)
|
|
29
37
|
|
|
@@ -61,7 +69,11 @@ module JGrep
|
|
|
61
69
|
end
|
|
62
70
|
end
|
|
63
71
|
|
|
64
|
-
# Validates an expression
|
|
72
|
+
# Validates an expression
|
|
73
|
+
# @param expression [String]
|
|
74
|
+
# The expression to validate
|
|
75
|
+
# @return [true] when no errors are found
|
|
76
|
+
# @return [String] The issues found
|
|
65
77
|
def self.validate_expression(expression)
|
|
66
78
|
Parser.new(expression)
|
|
67
79
|
true
|
|
@@ -101,6 +113,8 @@ module JGrep
|
|
|
101
113
|
end
|
|
102
114
|
|
|
103
115
|
# Validates if filters do not match any of the parser's logical tokens
|
|
116
|
+
# @raise [Exception] if any filters do not match any of the parser's logical tokens
|
|
117
|
+
# @return [nil]
|
|
104
118
|
def self.validate_filters(filters)
|
|
105
119
|
if filters.is_a? Array
|
|
106
120
|
filters.each do |filter|
|
|
@@ -116,6 +130,8 @@ module JGrep
|
|
|
116
130
|
end
|
|
117
131
|
|
|
118
132
|
# Correctly format values so we can do the correct type of comparison
|
|
133
|
+
#
|
|
134
|
+
# @return [Array[Any, 2]]
|
|
119
135
|
def self.format(kvalue, value)
|
|
120
136
|
if kvalue.to_s =~ /^\d+$/ && value.to_s =~ /^\d+$/
|
|
121
137
|
[Integer(kvalue), Integer(value)]
|
|
@@ -127,6 +143,9 @@ module JGrep
|
|
|
127
143
|
end
|
|
128
144
|
|
|
129
145
|
# Check if the json key that is defined by statement is defined in the json document
|
|
146
|
+
#
|
|
147
|
+
# @param document [Variant[Hash,Array,nil]]
|
|
148
|
+
# @param statement [String]
|
|
130
149
|
def self.present?(document, statement)
|
|
131
150
|
statement.split(".").each do |key|
|
|
132
151
|
if document.is_a? Hash
|
|
@@ -154,6 +173,9 @@ module JGrep
|
|
|
154
173
|
end
|
|
155
174
|
|
|
156
175
|
# Check if key=value is present in document
|
|
176
|
+
#
|
|
177
|
+
# @param document [Variant[Hash,Array,nil]]
|
|
178
|
+
# @param statement [String]
|
|
157
179
|
def self.has_object?(document, statement)
|
|
158
180
|
key, value = statement.split(/<=|>=|=|<|>/)
|
|
159
181
|
|
|
@@ -197,6 +219,9 @@ module JGrep
|
|
|
197
219
|
end
|
|
198
220
|
|
|
199
221
|
# Check if key=value is present in a sub array
|
|
222
|
+
#
|
|
223
|
+
# @param document [Array[Variant[Hash,Array,nil]]
|
|
224
|
+
# @param statement [String]
|
|
200
225
|
def self.is_object_in_array?(document, statement)
|
|
201
226
|
document.each do |item|
|
|
202
227
|
return true if has_object?(item, statement)
|
|
@@ -291,6 +316,9 @@ module JGrep
|
|
|
291
316
|
end
|
|
292
317
|
|
|
293
318
|
# Digs to a specific path in the json document and returns the value
|
|
319
|
+
#
|
|
320
|
+
# @param json [Variant[Hash,Array,nil]]
|
|
321
|
+
# @param path [String]
|
|
294
322
|
def self.dig_path(json, path)
|
|
295
323
|
index = nil
|
|
296
324
|
path = path.gsub(/^\./, "")
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,48 +1,103 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jgrep
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
8
|
-
- Dominic Cleal
|
|
9
|
-
- R.I. Pienaar
|
|
10
|
-
autorequire:
|
|
7
|
+
- Vox Pupuli
|
|
11
8
|
bindir: bin
|
|
12
9
|
cert_chain: []
|
|
13
|
-
date:
|
|
14
|
-
dependencies:
|
|
10
|
+
date: 2026-10-16 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: rake
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '13.2'
|
|
19
|
+
type: :development
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '13.2'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: rspec
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '3.13'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '3.13'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: mocha
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '3.1'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '3.1'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: voxpupuli-rubocop
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: 5.3.0
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: 5.3.0
|
|
15
68
|
description: Compare a list of json documents to a simple logical language and returns
|
|
16
69
|
matches as output
|
|
17
70
|
email:
|
|
18
|
-
-
|
|
19
|
-
- dominic@cleal.org
|
|
20
|
-
- rip@devco.net
|
|
71
|
+
- voxpupuli@groups.io
|
|
21
72
|
executables:
|
|
22
73
|
- jgrep
|
|
23
74
|
extensions: []
|
|
24
|
-
extra_rdoc_files:
|
|
25
|
-
- CHANGELOG.markdown
|
|
26
|
-
- README.markdown
|
|
75
|
+
extra_rdoc_files: []
|
|
27
76
|
files:
|
|
28
|
-
-
|
|
77
|
+
- ".github/dependabot.yml"
|
|
78
|
+
- ".github/labeler.yml"
|
|
79
|
+
- ".github/release.yml"
|
|
80
|
+
- ".github/workflows/labeler.yml"
|
|
81
|
+
- ".github/workflows/release.yml"
|
|
82
|
+
- ".github/workflows/test.yml"
|
|
83
|
+
- CHANGELOG.md
|
|
29
84
|
- COPYING
|
|
30
|
-
- README.
|
|
85
|
+
- README.md
|
|
31
86
|
- Rakefile
|
|
32
87
|
- bin/jgrep
|
|
33
88
|
- lib/jgrep.rb
|
|
34
89
|
- lib/parser/parser.rb
|
|
35
90
|
- lib/parser/scanner.rb
|
|
91
|
+
- lib/parser/version.rb
|
|
36
92
|
- spec/Rakefile
|
|
37
93
|
- spec/spec_helper.rb
|
|
38
94
|
- spec/unit/jgrep_spec.rb
|
|
39
95
|
- spec/unit/parser_spec.rb
|
|
40
96
|
- spec/unit/scanner_spec.rb
|
|
41
|
-
homepage: https://github.com/
|
|
97
|
+
homepage: https://github.com/voxpupuli/JSON-Grep
|
|
42
98
|
licenses:
|
|
43
99
|
- Apache-2.0
|
|
44
100
|
metadata: {}
|
|
45
|
-
post_install_message:
|
|
46
101
|
rdoc_options: []
|
|
47
102
|
require_paths:
|
|
48
103
|
- lib
|
|
@@ -50,15 +105,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
50
105
|
requirements:
|
|
51
106
|
- - ">="
|
|
52
107
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '
|
|
108
|
+
version: '3.3'
|
|
54
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
110
|
requirements:
|
|
56
111
|
- - ">="
|
|
57
112
|
- !ruby/object:Gem::Version
|
|
58
113
|
version: '0'
|
|
59
114
|
requirements: []
|
|
60
|
-
rubygems_version:
|
|
61
|
-
signing_key:
|
|
115
|
+
rubygems_version: 4.0.20
|
|
62
116
|
specification_version: 4
|
|
63
117
|
summary: Filter JSON documents with a simple logical language
|
|
64
118
|
test_files: []
|
data/CHANGELOG.markdown
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## 1.5.4
|
|
4
|
-
* Include missing fixes for Ruby 2.7.0 deprecations
|
|
5
|
-
|
|
6
|
-
## 1.5.3
|
|
7
|
-
* Fix Ruby 2.7.0 deprecation warnings
|
|
8
|
-
* Bump Rspec version in Gemfile
|
|
9
|
-
|
|
10
|
-
## 1.5.2
|
|
11
|
-
* Fixed an issue where strings like 2012R2 would get parsed as floats
|
|
12
|
-
|
|
13
|
-
## 1.5.1
|
|
14
|
-
* Now handles escaped parens when tokenising statements
|
|
15
|
-
|
|
16
|
-
## 1.5.0
|
|
17
|
-
* Dropped support for Ruby 1.8.3
|
|
18
|
-
* Added support for modern Ruby versions (Tested up to 2.4.0)
|
|
19
|
-
* Added utility method to validate expressions
|
|
20
|
-
|
|
21
|
-
## 1.4.1
|
|
22
|
-
* Fix binary exit code to be 1 when no matches are found (Mickaël Canévet)
|
|
23
|
-
|
|
24
|
-
## 1.4.0
|
|
25
|
-
* Expressions support matching true/false booleans (Boyan Tabakov)
|
|
26
|
-
* `--slice` option added to jgrep to get array elements (Jon McKenzie)
|
|
27
|
-
* `-i` option to read file supported without a TTY (Jon McKenzie)
|
|
28
|
-
* `-n` streaming option from 1.3.2 reinstated
|
|
29
|
-
* Performance fix: string splitting replaced with character access
|
|
30
|
-
* Performance fix: regexes replaced with simpler string methods
|
|
31
|
-
* Tests fixed and enabled on Travis CI
|