enumpath 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cf0161d7c4e4278f7ab3dec41b2bd1e0c3e3afbabc4ea320bfc6f58a9d635ac
4
- data.tar.gz: 4b294f03b8dc9872092aa77aa457f3b7bf8916b62874bcf4770401ff3a38e93d
3
+ metadata.gz: 369ec833e0f348946ea91ec684b9cccbc3e53a5bc7bae96e45b262a0988d8631
4
+ data.tar.gz: d73ff78feb24cb35c16ed43b0a7d3e8772bcfcd65b56a7a9a273341541b1eca6
5
5
  SHA512:
6
- metadata.gz: 724900c6f9277499b34159095e1ffcb6aa0ce05b30435d09c4c3f619338429eb1619dc17650014f40719f01b7def732e2afcb9657840976040ca4a36f34ab5ac
7
- data.tar.gz: ea2d09f726d6ea6f3b212314886d1d041bb4e6d807154846008362dc754f977d8a301aff202f9fc723fadebe749a5d464a73304e4157a5f994ca5ce39da7ddfd
6
+ metadata.gz: cbb24d41e81f8c4673e765e28e9dbea07c3fa41a3745357369fea4430f0c83a6d3cbb3eb942784c4177060ad9fe9ddcad4c0ddfcf87ba4eb6cb1854a33775b84
7
+ data.tar.gz: 785fb0a118331ba56750117c50c85126c3f5846ba1e403b6376b9fdaf2102267e06e54614f3c0b45eafd34a28295690b0d14357c1ad41f22433b5cc903914f8e
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve Enumpath
4
+ title: ''
5
+ labels: ''
6
+ assignees: chrisbloom7
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+ - OS: [e.g. iOS]
28
+ - Browser [e.g. chrome, safari]
29
+ - Version [e.g. 22]
30
+
31
+ **Smartphone (please complete the following information):**
32
+ - Device: [e.g. iPhone6]
33
+ - OS: [e.g. iOS8.1]
34
+ - Browser [e.g. stock browser, safari]
35
+ - Version [e.g. 22]
36
+
37
+ **Additional context**
38
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for Enumpath
4
+ title: ''
5
+ labels: ''
6
+ assignees: chrisbloom7
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,13 @@
1
+ name: Greetings
2
+
3
+ on: [pull_request, issues]
4
+
5
+ jobs:
6
+ greeting:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/first-interaction@v1
10
+ with:
11
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
12
+ # issue-message: 'TODO: Message that will be displayed on users'' first issue'
13
+ pr-message: 'Thanks for being interested in improving Enumpath! We welcome all kinds of contributions. There are a couple of things you should know before contributing to this repository, so be sure to [read our contributing guide](https://github.com/chrisbloom7/enumpath/blob/master/CONTRIBUTING.md) while awaiting feedback.'
@@ -0,0 +1,47 @@
1
+ # pulled from repo
2
+ name: "Rubocop"
3
+
4
+ on:
5
+ push:
6
+ branches: [ master ]
7
+ pull_request:
8
+ # The branches below must be a subset of the branches above
9
+ branches: [ master ]
10
+ schedule:
11
+ - cron: '15 23 * * 6'
12
+
13
+ jobs:
14
+ rubocop:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+
19
+ steps:
20
+ - name: Checkout repository
21
+ uses: actions/checkout@v2
22
+
23
+ # If running on a self-hosted runner, check it meets the requirements
24
+ # listed at https://github.com/ruby/setup-ruby#using-self-hosted-runners
25
+ - name: Set up Ruby
26
+ uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: 2.6
29
+
30
+ # This step is not necessary if you add the gem to your Gemfile
31
+ - name: Install Code Scanning integration
32
+ run: bundle add code-scanning-rubocop --version 0.3.0 --skip-install
33
+
34
+ - name: Install dependencies
35
+ run: bundle install
36
+
37
+ - name: Rubocop run
38
+ run: |
39
+ bash -c "
40
+ bundle exec rubocop --enable-pending-cops --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
41
+ [[ $? -ne 2 ]]
42
+ "
43
+
44
+ - name: Upload Sarif output
45
+ uses: github/codeql-action/upload-sarif@v1
46
+ with:
47
+ sarif_file: rubocop.sarif
@@ -0,0 +1,35 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['2.6', '2.7', '3.0']
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
+ # uses: ruby/setup-ruby@v1
30
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
31
+ with:
32
+ ruby-version: ${{ matrix.ruby-version }}
33
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
+ - name: Run tests
35
+ run: bundle exec rake
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ AllCops:
2
+ DisplayStyleGuide: true
3
+
4
+ Metrics/BlockLength:
5
+ Exclude:
6
+ - 'enumpath.gemspec'
7
+ - '**/*.rake'
8
+ - 'spec/**/*.rb'
9
+
10
+ Layout/LineLength:
11
+ IgnoreCopDirectives: true
12
+ Max: 120
data/CONTRIBUTING.md CHANGED
@@ -1,18 +1,18 @@
1
1
  # Contributing
2
2
 
3
- Thanks for being interested in our project! We welcome [all kinds of contributions](https://opensource.guide/how-to-contribute/). There are a few things you should know before contributing to this repository:
3
+ Thanks for being interested in improving Enumpath! We welcome [all kinds of contributions][how-to-contribute]. There are a couple of things you should know before contributing to this repository:
4
4
 
5
- 1. All contributors must agree to our Contributor License Agreement before any merge requests will be accepted.
6
- 2. Please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
7
- 3. Please note we have a code of conduct, please follow it in all your interactions with the project.
5
+ 1. Unless your changes are related to an existing issue, please first open a new issue to discuss the changes you wish to make.
6
+ 2. Please note we have a [code of conduct](#code-of-conduct), please follow it in all your interactions with the project.
7
+ 3. Code quality is important to us! Please be prepared to to address all code quality comments, whether from a CI tool like Hound or directly from our maintainers, before we can accept your changes.
8
8
 
9
9
  ## Pull Request Process
10
10
 
11
11
  1. Fork the repo.
12
12
  2. Make sure the tests pass before you begin working.
13
- 3. Make your changes, with new passing tests. Follow the [Ruby Style Guide](https://github.com/rubocop-hq/ruby-style-guide).
14
- 4. Push to your fork. Write a [good commit message](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
15
- 5. Submit a [good pull request](https://blog.github.com/2015-01-21-how-to-write-the-perfect-pull-request/).
13
+ 3. Make your changes, with new passing tests. Follow the [Ruby Style Guide][ruby-style-guide].
14
+ 4. Push to your fork using a [good commit message][a-note-about-git-commit-messages].
15
+ 5. Submit a [good pull request][how-to-write-the-perfect-pull-request] from your fork to our project.
16
16
  6. Others will give constructive feedback. This is a time for discussion and improvements, and making the necessary changes will be required before we can merge the contribution.
17
17
 
18
18
  ## Code of Conduct
@@ -72,7 +72,7 @@ further defined and clarified by project maintainers.
72
72
  ### Enforcement
73
73
 
74
74
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
75
- reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
75
+ reported by contacting the project team at [chrisbloom7/enumpath][enumpath-gh]. All
76
76
  complaints will be reviewed and investigated and will result in a response that
77
77
  is deemed necessary and appropriate to the circumstances. The project team is
78
78
  obligated to maintain confidentiality with regard to the reporter of an incident.
@@ -87,5 +87,10 @@ members of the project's leadership.
87
87
  This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
88
88
  available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
89
89
 
90
+ [a-note-about-git-commit-messages]: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
91
+ [enumpath-gh]: https://github.com/chrisbloom7/enumpath
90
92
  [homepage]: https://www.contributor-covenant.org
93
+ [how-to-contribute]: https://opensource.guide/how-to-contribute/
94
+ [how-to-write-the-perfect-pull-request]: https://blog.github.com/2015-01-21-how-to-write-the-perfect-pull-request/
95
+ [ruby-style-guide]: https://github.com/rubocop-hq/ruby-style-guide
91
96
  [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile CHANGED
@@ -1,6 +1,8 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
6
 
5
7
  # Specify your gem's dependencies in enumpath.gemspec
6
8
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enumpath (0.1.1)
4
+ enumpath (0.1.2)
5
5
  mini_cache (~> 1.1.0)
6
6
  to_regexp (~> 0.2.1)
7
7
 
@@ -11,7 +11,7 @@ GEM
11
11
  benchmark-perf (0.2.1)
12
12
  byebug (10.0.2)
13
13
  coderay (1.1.2)
14
- diff-lcs (1.3)
14
+ diff-lcs (1.4.4)
15
15
  method_source (0.9.0)
16
16
  mini_cache (1.1.0)
17
17
  null-logger (0.1.5)
@@ -21,36 +21,41 @@ GEM
21
21
  pry-byebug (3.6.0)
22
22
  byebug (~> 10.0)
23
23
  pry (~> 0.10)
24
- rake (12.3.1)
25
- rspec (3.8.0)
26
- rspec-core (~> 3.8.0)
27
- rspec-expectations (~> 3.8.0)
28
- rspec-mocks (~> 3.8.0)
24
+ rake (12.3.3)
25
+ rspec (3.10.0)
26
+ rspec-core (~> 3.10.0)
27
+ rspec-expectations (~> 3.10.0)
28
+ rspec-mocks (~> 3.10.0)
29
29
  rspec-benchmark (0.3.0)
30
30
  benchmark-perf (~> 0.2.0)
31
31
  rspec (>= 3.0.0, < 4.0.0)
32
- rspec-core (3.8.0)
33
- rspec-support (~> 3.8.0)
34
- rspec-expectations (3.8.1)
32
+ rspec-core (3.10.1)
33
+ rspec-support (~> 3.10.0)
34
+ rspec-expectations (3.10.1)
35
35
  diff-lcs (>= 1.2.0, < 2.0)
36
- rspec-support (~> 3.8.0)
37
- rspec-mocks (3.8.0)
36
+ rspec-support (~> 3.10.0)
37
+ rspec-mocks (3.10.2)
38
38
  diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.8.0)
40
- rspec-support (3.8.0)
39
+ rspec-support (~> 3.10.0)
40
+ rspec-support (3.10.2)
41
+ rspec_junit_formatter (0.4.1)
42
+ rspec-core (>= 2, < 4, != 2.12.0)
41
43
  to_regexp (0.2.1)
44
+ yard (0.9.26)
42
45
 
43
46
  PLATFORMS
44
47
  ruby
45
48
 
46
49
  DEPENDENCIES
47
- bundler (~> 1.16)
50
+ bundler (~> 2.1)
48
51
  enumpath!
49
52
  null-logger (~> 0.1)
50
53
  pry-byebug (~> 3.6)
51
54
  rake (~> 12.3)
52
55
  rspec (~> 3.8)
53
56
  rspec-benchmark (~> 0.3.0)
57
+ rspec_junit_formatter (~> 0.4)
58
+ yard (~> 0.9.26)
54
59
 
55
60
  BUNDLED WITH
56
- 1.16.3
61
+ 2.2.15
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Enumpath
1
+ # Enumpath [![Build Status][ci-image]][ci] [![Gem Version][version-image]][version] [![Reviewed by Hound][hound-badge-image]][hound]
2
2
 
3
3
  A JSONPath-compatible library for safely navigating nested Ruby objects using path expressions.
4
4
 
@@ -51,14 +51,14 @@ Or install it yourself as:
51
51
  Enumpath exposes a simple interface via `Enumpath.apply` that takes a path and an enumerable.
52
52
 
53
53
  ```ruby
54
- party = { food: %w(pizza tacos) }
54
+ party = { food: %w[pizza tacos] }
55
55
  Enumpath.apply('food.0', party) # => ["pizza"]
56
56
  ```
57
57
 
58
58
  The result of `Enumpath.apply` is an array of values that were extracted according to the path. Technically it's an instance of `Enumpath::Results` which is an Array-like object that allows you to chain further calls to `.apply` like this:
59
59
 
60
60
  ```ruby
61
- party = { food: %w(pizza tacos) }
61
+ party = { food: %w[pizza tacos] }
62
62
  results = Enumpath.apply('food.*', party) # => ["pizza", "tacos"]
63
63
  results.apply("[?(@ == 'pizza')]") # => ["pizza"]
64
64
  ```
@@ -66,7 +66,7 @@ results.apply("[?(@ == 'pizza')]") # => ["pizza"]
66
66
  In the event that the path doesn't match anything, an empty results set is returned:
67
67
 
68
68
  ```ruby
69
- party = { food: %w(pizza tacos) }
69
+ party = { food: %w[pizza tacos] }
70
70
  Enumpath.apply("drinks.*", party) # => []
71
71
  ```
72
72
 
@@ -102,10 +102,10 @@ Child operators match on an index, key, member, or property of the enumerable. I
102
102
 
103
103
  ```
104
104
  Car = Struct.new(:color, :transmition, :owners)
105
- hiundai = Car.new('blue', :automatic, [{ name: 'Bill' }, { name: 'Ted' }])
105
+ hyundai = Car.new('blue', :automatic, [{ name: 'Bill' }, { name: 'Ted' }])
106
106
  subaru = Car.new('gold', :standard, [{ name: 'Kate' }])
107
107
  jeep = Car.new('black', :automatic, [])
108
- garages = [{ 'cars' => [hiundai, subaru] }, { 'cars' => [jeep] }]
108
+ garages = [{ 'cars' => [hyundai, subaru] }, { 'cars' => [jeep] }]
109
109
  Enumpath.apply('1', garages) # => [{"cars"=>[#<struct Car color="black", transmition=:automatic, owners=[]>]}]
110
110
  Enumpath.apply('0.cars.-1', garages) # => [#<struct Car color="gold", transmition=:standard, owners=[{:name=>"Kate"}]>]
111
111
  Enumpath.apply('1.cars.0.owners.length', garages) # => [0]
@@ -373,7 +373,7 @@ Enumpath.apply("$..*", store_info)
373
373
  By default, Enumpath returns the values that match the path expression. Like the original JSONPath implementation, Enumpath also supports returning path results instead of values. This can be useful for collecting static paths from dynamic paths.
374
374
 
375
375
  ```ruby
376
- party = { food: %w(pizza tacos) }
376
+ party = { food: %w[pizza tacos] }
377
377
  Enumpath.apply("food.*", party, result_type: :path) # => ["$['food'][0]", "$['food'][1]"]
378
378
  ```
379
379
 
@@ -446,7 +446,7 @@ To save a little bit of time on consecutive calls Enumpath caches the normalized
446
446
 
447
447
  3. The original implementations of JSONPath allowed unchecked evaluation of filter and subscript expressions. Enumpath limits those expressions to a reasonable subset of operations as detailed in the [Operator Reference](#operator-reference) section and uses `public_send` rather than `eval` to resolve expressions as necessary.
448
448
 
449
- 4. The original JSONPath spec did not include support for using logical operators to chain expressions in filter expression operators. This addition was inspired by [Gergely Brautigam's](https://skarlso.github.io/2017/05/28/replace-eval-with-object-send-and-a-parser/) work on [joshbuddy/jsonpath](https://github.com/joshbuddy/jsonpath)
449
+ 4. The original JSONPath spec did not include support for using logical operators to chain expressions in filter expression operators. This addition was inspired by [Gergely Brautigam's][replace-eval-with-object-send-and-a-parser] work on [joshbuddy/jsonpath][jsonpath-gh]
450
450
 
451
451
  ## Requirements
452
452
 
@@ -458,35 +458,49 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
458
458
 
459
459
  ## Contributing
460
460
 
461
- Bug reports and pull requests are welcome on GitHub at [https://github.com/youearnedit/enumpath](). Please read [CONTRIBUTING.md]() for details on our code of conduct, and the process for submitting pull requests to us.
461
+ Bug reports and pull requests are welcome on GitHub at [chrisbloom7/enumpath][enumpath-gh]. Please read [CONTRIBUTING.md]() for details on our code of conduct, and the process for submitting pull requests to us.
462
462
 
463
463
  ## Versioning
464
464
 
465
- We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags](https://github.com/youearnedit/enumpath/tags) on this repository.
465
+ We use [SemVer][semver] for versioning. For the versions available, see the [tags][tags] on this repository.
466
466
 
467
467
  ## Authors
468
468
 
469
- - [Chris Bloom](https://github.com/chrisbloom7) - YouEarnedIt
469
+ - [Chris Bloom][chris-bloom-gh]
470
470
 
471
- See also the list of [contributors](https://github.com/youearnedit/enumpath/graphs/contributors) who participated in this project.
471
+ See also the list of [contributors][contributors] who participated in this project.
472
472
 
473
473
  ## License
474
474
 
475
- Copyright 2018 YouEarnedIt.com
476
-
477
475
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
478
476
 
479
- [www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
477
+ [www.apache.org/licenses/LICENSE-2.0][apache-license-2-0]
480
478
 
481
479
  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
482
480
 
483
481
  ## Acknowledgements
484
482
 
485
- This project is maintained by the Engineering team at [YouEarnedIt](http://youearnedit.com), an employee engagement and performance metrics platform, headquartered in Austin, TX.
483
+ This project originated from an internal project at [YouEarnedIt][youearnedit], an employee engagement and performance metrics platform, headquartered in Austin, TX.
486
484
 
487
485
  Enumpath is based on [Stefan Goessner's JSONPath spec][jsonpath], and was inspired by several similar libraries:
488
486
 
489
- - [nickcharlton/keypath-ruby](https://github.com/nickcharlton/keypath-ruby)
490
- - [joshbuddy/jsonpath](https://github.com/joshbuddy/jsonpath)
491
-
487
+ - [nickcharlton/keypath-ruby][keypath-ruby]
488
+ - [joshbuddy/jsonpath][jsonpath-gh]
489
+
490
+ [apache-license-2-0]: http://www.apache.org/licenses/LICENSE-2.0
491
+ [chris-bloom-gh]: https://github.com/chrisbloom7
492
+ [ci]: https://circleci.com/gh/chrisbloom7/enumpath
493
+ [ci-image]: https://circleci.com/gh/chrisbloom7/enumpath.svg?style=svg
494
+ [contributors]: https://github.com/chrisbloom7/enumpath/graphs/contributors
495
+ [enumpath-gh]: https://github.com/chrisbloom7/enumpath
496
+ [hound]: https://houndci.com
497
+ [hound-badge-image]: https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg
492
498
  [jsonpath]: http://goessner.net/articles/JsonPath/
499
+ [jsonpath-gh]: https://github.com/joshbuddy/jsonpath
500
+ [keypath-ruby]: https://github.com/nickcharlton/keypath-ruby
501
+ [replace-eval-with-object-send-and-a-parser]: https://skarlso.github.io/2017/05/28/replace-eval-with-object-send-and-a-parser/
502
+ [semver]: http://semver.org/
503
+ [tags]: https://github.com/chrisbloom7/enumpath/tags
504
+ [version]: https://badge.fury.io/rb/enumpath
505
+ [version-image]: https://badge.fury.io/rb/enumpath.svg
506
+ [youearnedit]: http://youearnedit.com
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require "yard"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'yard'
4
6
 
5
7
  RSpec::Core::RakeTask.new(:spec)
6
8
 
7
- task :default => :spec
9
+ task default: :spec
8
10
 
9
11
  YARD::Rake::YardocTask.new do |t|
10
12
  t.options = ['--no-private', '-', 'LICENSE']