glob 0.2.0 → 0.2.1

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: 1e44b2144da5a2fe785364209c7b4bce46a0e19768fe287b41cc8d8a7283e215
4
- data.tar.gz: 774e63f4cafa984899b85599200de72785c7c2fa44a80c30ed11923495501ed6
3
+ metadata.gz: c0e77de6e0858513911147e0f12aa486639c9b136943067b23b2c43ee0106a6e
4
+ data.tar.gz: 0e4ad98905f43a9aa30aecb71c2092e259c4b4575ecd005175c43f204cfbac36
5
5
  SHA512:
6
- metadata.gz: b52d46a9740468309250ceaadaae156db7b99eb5709a64bc36a66211a49ed37a4f7beeecce000fb4075c488651075e2f462291792b5629b441580902772d4818
7
- data.tar.gz: 91046b7420418420fd507a9f09cc44f6dc50080011c81a5491af01276cecda296f6155ae4321156c294c6365be9fded1cbbb0a32e59e454857e24f923aef9f71
6
+ metadata.gz: 43feeab757c719fc13ccfe23731a01ca9ef3fd76ae46e839889e085591c161cd8d6ecc53d3757948b8d3d2d69ea00f8f53052b3c3bb7648d02c0022c2421ae63
7
+ data.tar.gz: 2d1ee931681b2c5c0dd5b626ed5ef86de36b99efe7b550c33cdd3390d4e715c005a4f8b67a93db1149ec35185d73e1fcc02b47b4a7b77920fdea788c99f8447f
@@ -0,0 +1,4 @@
1
+ # You can read more about CODEOWNERS at
2
+ # https://help.github.com/github/creating-cloning-and-archiving-repositories/about-code-owners
3
+
4
+ * @fnando
data/.github/FUNDING.yml CHANGED
@@ -1,2 +1,4 @@
1
- ---
2
- custom: ["https://www.paypal.me/nandovieira/🍕"]
1
+ # These are supported funding model platforms
2
+
3
+ github: [fnando]
4
+ custom: ["https://paypal.me/nandovieira/🍕"]
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: "🐛 Bug Report"
3
+ about: Report a reproducible bug or regression.
4
+ title: 'Bug: '
5
+ labels: 'Status: Unconfirmed'
6
+
7
+ ---
8
+
9
+ <!--
10
+ - Please provide a clear and concise description of what the bug is.
11
+ - If possible, add an example reproducing your issue.
12
+ - Please test using the latest version of glob
13
+ to make sure your issue has not already been fixed.
14
+ -->
15
+
16
+ ## Description
17
+
18
+ [Add bug description here]
19
+
20
+ ## How to reproduce
21
+
22
+ [Add steps on how to reproduce this issue]
23
+
24
+ ## What do you expect
25
+
26
+ [Describe what do you expect to happen]
27
+
28
+ ## What happened instead
29
+
30
+ [Describe the actual results]
31
+
32
+ ## Software:
33
+
34
+ - Gem version: [Add gem version here]
35
+ - Ruby version: [Add version here]
36
+
37
+ ## Full backtrace
38
+
39
+ ```text
40
+ [Paste full backtrace here]
41
+ ```
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: "💡 Feature request"
3
+ about: Have an idea that may be useful? Make a suggestion!
4
+ title: 'Feature Request: '
5
+ labels: 'Feature request'
6
+
7
+ ---
8
+
9
+ ## Description
10
+
11
+ _A clear and concise description of what the problem is._
12
+
13
+ ## Describe the solution
14
+
15
+ _A clear and concise description of what you want to happen._
16
+
17
+ ## Alternatives you considered
18
+
19
+ _A clear and concise description of any alternative solutions or features you've considered._
20
+
21
+ ## Additional context
22
+
23
+ _Add any other context, screenshots, links, etc about the feature request here._
@@ -0,0 +1,38 @@
1
+ <!--
2
+ If you're making a doc PR or something tiny where the below is irrelevant,
3
+ delete this template and use a short description, but in your description aim to
4
+ include both what the change is, and why it is being made, with enough context
5
+ for anyone to understand.
6
+ -->
7
+
8
+ <details>
9
+ <summary>PR Checklist</summary>
10
+
11
+ ### PR Structure
12
+
13
+ - [ ] This PR has reasonably narrow scope (if not, break it down into smaller
14
+ PRs).
15
+ - [ ] This PR avoids mixing refactoring changes with feature changes (split into
16
+ two PRs otherwise).
17
+ - [ ] This PR's title starts is concise and descriptive.
18
+
19
+ ### Thoroughness
20
+
21
+ - [ ] This PR adds tests for the most critical parts of the new functionality or
22
+ fixes.
23
+ - [ ] I've updated any docs, `.md` files, etc… affected by this change.
24
+
25
+ </details>
26
+
27
+ ### What
28
+
29
+ [TODO: Short statement about what is changing.]
30
+
31
+ ### Why
32
+
33
+ [TODO: Why this change is being made. Include any context required to understand
34
+ the why.]
35
+
36
+ ### Known limitations
37
+
38
+ [TODO or N/A]
@@ -0,0 +1,15 @@
1
+ ---
2
+ # Documentation:
3
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
4
+
5
+ version: 2
6
+ updates:
7
+ - package-ecosystem: "github-actions"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "daily"
11
+
12
+ - package-ecosystem: "bundler"
13
+ directory: "/"
14
+ schedule:
15
+ interval: "daily"
@@ -0,0 +1,53 @@
1
+ ---
2
+ name: ruby-tests
3
+
4
+ on:
5
+ pull_request_target:
6
+ push:
7
+ branches:
8
+ - main
9
+ workflow_dispatch:
10
+ inputs: {}
11
+
12
+ jobs:
13
+ build:
14
+ name: Tests with Ruby ${{ matrix.ruby }} and ${{ matrix.gemfile }}
15
+ runs-on: "ubuntu-latest"
16
+ if: |
17
+ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target' ||
18
+ github.actor != 'dependabot[bot]'
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ ruby: ["2.7", "3.0", "3.1"]
23
+ gemfile:
24
+ - Gemfile
25
+
26
+ steps:
27
+ - uses: actions/checkout@v2.4.0
28
+
29
+ - uses: actions/cache@v2
30
+ with:
31
+ path: vendor/bundle
32
+ key: >
33
+ ${{ runner.os }}-${{ matrix.ruby }}-gems-${{
34
+ hashFiles(matrix.gemfile) }}
35
+
36
+ - name: Set up Ruby
37
+ uses: ruby/setup-ruby@v1
38
+ with:
39
+ ruby-version: ${{ matrix.ruby }}
40
+
41
+ - name: Install gem dependencies
42
+ env:
43
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
44
+ run: |
45
+ gem install bundler
46
+ bundle config path vendor/bundle
47
+ bundle update --jobs 4 --retry 3
48
+
49
+ - name: Run Tests
50
+ env:
51
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
52
+ run: |
53
+ bundle exec rake
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
data/.rubocop.yml CHANGED
@@ -3,13 +3,8 @@ inherit_gem:
3
3
  rubocop-fnando: .rubocop.yml
4
4
 
5
5
  AllCops:
6
- TargetRubyVersion: 2.6
7
-
8
- Metrics/BlockLength:
9
- Exclude:
10
- - test/**/*_test.rb
11
- - glob.gemspec
12
-
13
- Metrics/ClassLength:
6
+ TargetRubyVersion: 2.7
7
+ NewCops: enable
14
8
  Exclude:
15
- - test/**/*_test.rb
9
+ - vendor/**/*
10
+ - gemfiles/**/*
data/CHANGELOG.md CHANGED
@@ -1,9 +1,24 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ <!--
4
+ Prefix your message with one of the following:
4
5
 
5
- - Allow rejecting patterns like `!*.activerecord`.
6
- - New API.
6
+ - [Added] for new features.
7
+ - [Changed] for changes in existing functionality.
8
+ - [Deprecated] for soon-to-be removed features.
9
+ - [Removed] for now removed features.
10
+ - [Fixed] for any bug fixes.
11
+ - [Security] in case of vulnerabilities.
12
+ -->
13
+
14
+ ## v0.2.1 - 2022-01-13
15
+
16
+ - [Changed] .gem package now include tests files.
17
+
18
+ ## v0.2.0
19
+
20
+ - [Added] Allow rejecting patterns like `!*.activerecord`.
21
+ - [Changed] New API.
7
22
 
8
23
  ## v0.1.0
9
24
 
data/CODE_OF_CONDUCT.md CHANGED
@@ -68,7 +68,7 @@ members of the project's leadership.
68
68
  ## Attribution
69
69
 
70
70
  This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
72
 
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,79 @@
1
+ # Contributing to glob
2
+
3
+ 👍🎉 First off, thanks for taking the time to contribute! 🎉👍
4
+
5
+ The following is a set of guidelines for contributing to this project. These are
6
+ mostly guidelines, not rules. Use your best judgment, and feel free to propose
7
+ changes to this document in a pull request.
8
+
9
+ ## Code of Conduct
10
+
11
+ Everyone interacting in this project's codebases, issue trackers, chat rooms and
12
+ mailing lists is expected to follow the [code of conduct](https://github.com/fnando/glob/blob/main/CODE_OF_CONDUCT.md).
13
+
14
+ ## Reporting bugs
15
+
16
+ This section guides you through submitting a bug report. Following these
17
+ guidelines helps maintainers and the community understand your report, reproduce
18
+ the behavior, and find related reports.
19
+
20
+ - Before creating bug reports, please check the open issues; somebody may
21
+ already have submitted something similar, and you may not need to create a new
22
+ one.
23
+ - When you are creating a bug report, please include as many details as
24
+ possible, with an example reproducing the issue.
25
+
26
+ ## Contributing with code
27
+
28
+ Before making any radicals changes, please make sure you discuss your intention
29
+ by [opening an issue on Github](https://github.com/fnando/glob/issues).
30
+
31
+ When you're ready to make your pull request, follow checklist below to make sure
32
+ your contribution is according to how this project works.
33
+
34
+ 1. [Fork](https://help.github.com/forking/) glob
35
+ 2. Create a topic branch - `git checkout -b my_branch`
36
+ 3. Make your changes using [descriptive commit messages](#commit-messages)
37
+ 4. Update CHANGELOG.md describing your changes by adding an entry to the
38
+ "Unreleased" section. If this section is not available, create one right
39
+ before the last version.
40
+ 5. Push to your branch - `git push origin my_branch`
41
+ 6. [Create a pull request](https://help.github.com/articles/creating-a-pull-request)
42
+ 7. That's it!
43
+
44
+ ## Styleguides
45
+
46
+ ### Commit messages
47
+
48
+ - Use the present tense ("Add feature" not "Added feature")
49
+ - Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
50
+ - Limit the first line to 72 characters or less
51
+ - Reference issues and pull requests liberally after the first line
52
+
53
+ ### Changelog
54
+
55
+ - Add a message describing your changes to the "Unreleased" section. The
56
+ changelog message should follow the same style as the commit message.
57
+ - Prefix your message with one of the following:
58
+ - `[Added]` for new features.
59
+ - `[Changed]` for changes in existing functionality.
60
+ - `[Deprecated]` for soon-to-be removed features.
61
+ - `[Removed]` for now removed features.
62
+ - `[Fixed]` for any bug fixes.
63
+ - `[Security]` in case of vulnerabilities.
64
+
65
+ ### Ruby code
66
+
67
+ - This project uses [Rubocop](https://rubocop.org) to enforce code style. Before
68
+ submitting your changes, make sure your tests are passing and code conforms to
69
+ the expected style by running `rake`.
70
+ - Do not change the library version. This will be done by the maintainer
71
+ whenever a new version is about to be released.
72
+
73
+ ### JavaScript code
74
+
75
+ - This project uses [ESLint](https://eslint.org) to enforce code style. Before
76
+ submitting your changes, make sure your tests are passing and code conforms to
77
+ the expected style by running `yarn test:ci`.
78
+ - Do not change the library version. This will be done by the maintainer
79
+ whenever a new version is about to be released.
data/Gemfile CHANGED
@@ -2,5 +2,4 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- # Specify your gem's dependencies in glob.gemspec
6
5
  gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ # The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Nando Vieira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,34 +1,36 @@
1
- # Glob
1
+ # glob
2
2
 
3
- [![](https://github.com/fnando/glob/workflows/tests/badge.svg)](https://github.com/fnando/glob/actions?query=workflow%3Atests)
3
+ [![Tests](https://github.com/fnando/glob/workflows/ruby-tests/badge.svg)](https://github.com/fnando/glob)
4
+ [![Code Climate](https://codeclimate.com/github/fnando/glob/badges/gpa.svg)](https://codeclimate.com/github/fnando/glob)
5
+ [![Gem](https://img.shields.io/gem/v/glob.svg)](https://rubygems.org/gems/glob)
6
+ [![Gem](https://img.shields.io/gem/dt/glob.svg)](https://rubygems.org/gems/glob)
4
7
 
5
- Create a list of hash paths that match a given pattern. You can also generate
6
- a hash with only the matching paths.
8
+ Create a list of hash paths that match a given pattern. You can also generate a
9
+ hash with only the matching paths.
7
10
 
8
11
  ## Installation
9
12
 
10
- Add this line to your application's Gemfile:
13
+ ```bash
14
+ gem install glob
15
+ ```
16
+
17
+ Or add the following line to your project's Gemfile:
11
18
 
12
19
  ```ruby
13
20
  gem "glob"
14
21
  ```
15
22
 
16
- And then execute:
17
-
18
- $ bundle
19
-
20
- Or install it yourself as:
21
-
22
- $ gem install glob
23
-
24
23
  ## Usage
25
24
 
26
25
  There are two types of paths: `include` and `exclude`.
27
26
 
28
27
  - The `include` path adds that node to the new hash.
29
- - The `exclude` path is the one started by `!`, and will prevent that path from being added.
28
+ - The `exclude` path is the one started by `!`, and will prevent that path from
29
+ being added.
30
30
 
31
- The latest rules have more precedence; that means that if you have the rule `*.messages.*`, then add a following rule as `!*.messages.bye`, all `*.messages.*` but `*.messages.bye` will be included.
31
+ The latest rules have more precedence; that means that if you have the rule
32
+ `*.messages.*`, then add a following rule as `!*.messages.bye`, all
33
+ `*.messages.*` but `*.messages.bye` will be included.
32
34
 
33
35
  ```ruby
34
36
  glob = Glob.new(
@@ -67,20 +69,27 @@ glob.to_h
67
69
 
68
70
  Notice that the return result will have symbolized keys.
69
71
 
70
- ## Development
72
+ ## Maintainer
73
+
74
+ - [Nando Vieira](https://github.com/fnando)
71
75
 
72
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
76
+ ## Contributors
73
77
 
74
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
78
+ - https://github.com/fnando/glob/contributors
75
79
 
76
80
  ## Contributing
77
81
 
78
- Bug reports and pull requests are welcome on GitHub at https://github.com/fnando/glob. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
82
+ For more details about how to contribute, please read
83
+ https://github.com/fnando/glob/blob/main/CONTRIBUTING.md.
79
84
 
80
85
  ## License
81
86
 
82
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
87
+ The gem is available as open source under the terms of the
88
+ [MIT License](https://opensource.org/licenses/MIT). A copy of the license can be
89
+ found at https://github.com/fnando/glob/blob/main/LICENSE.md.
83
90
 
84
91
  ## Code of Conduct
85
92
 
86
- Everyone interacting in the Glob projects codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fnando/glob/blob/master/CODE_OF_CONDUCT.md).
93
+ Everyone interacting in the glob project's codebases, issue trackers, chat rooms
94
+ and mailing lists is expected to follow the
95
+ [code of conduct](https://github.com/fnando/glob/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
  require "rake/testtask"
5
+ require "rubocop/rake_task"
5
6
 
6
7
  Rake::TestTask.new(:test) do |t|
7
8
  t.libs << "test"
@@ -9,4 +10,6 @@ Rake::TestTask.new(:test) do |t|
9
10
  t.test_files = FileList["test/**/*_test.rb"]
10
11
  end
11
12
 
12
- task default: :test
13
+ RuboCop::RakeTask.new
14
+
15
+ task default: %i[test rubocop]
data/bin/console CHANGED
@@ -7,9 +7,10 @@ require "glob"
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
9
9
 
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require "irb"
15
- IRB.start(__FILE__)
10
+ begin
11
+ require "pry"
12
+ Pry.start
13
+ rescue LoadError
14
+ require "irb"
15
+ IRB.start(__FILE__)
16
+ end
data/bin/setup CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+
2
3
  set -euo pipefail
4
+
3
5
  IFS=$'\n\t'
4
6
  set -vx
5
7
 
data/glob.gemspec CHANGED
@@ -1,37 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "./lib/glob/version"
3
+ require_relative "./lib/glob/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "glob"
7
- spec.version = Glob::VERSION
8
- spec.authors = ["Nando Vieira"]
9
- spec.email = ["me@fnando.com"]
10
-
11
- spec.summary = [
12
- "Create a list of hash paths that match a given pattern.",
13
- "You can also generate a hash with only the matching paths."
14
- ].join(" ")
15
- spec.description = spec.summary
16
- spec.homepage = "https://github.com/fnando/glob"
17
- spec.license = "MIT"
6
+ spec.name = "glob"
7
+ spec.version = Glob::VERSION
8
+ spec.authors = ["Nando Vieira"]
9
+ spec.email = ["me@fnando.com"]
18
10
 
11
+ spec.summary = "Create a list of hash paths that match a given " \
12
+ "pattern. You can also generate a hash with only the " \
13
+ "matching paths."
14
+ spec.description = spec.summary
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
17
+ spec.metadata["rubygems_mfa_required"] = "true"
18
+
19
+ github_url = "https://github.com/fnando/glob"
20
+ github_tree_url = "#{github_url}/tree/v#{spec.version}"
21
+
22
+ spec.homepage = github_url
19
23
  spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = "https://github.com/fnando/glob"
21
- spec.metadata["changelog_uri"] = "https://github.com/fnando/glob"
24
+ spec.metadata["bug_tracker_uri"] = "#{github_url}/issues"
25
+ spec.metadata["source_code_uri"] = github_tree_url
26
+ spec.metadata["changelog_uri"] = "#{github_tree_url}/CHANGELOG.md"
27
+ spec.metadata["documentation_uri"] = "#{github_tree_url}/README.md"
28
+ spec.metadata["license_uri"] = "#{github_tree_url}/LICENSE.md"
22
29
 
23
30
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
- `git ls-files -z`
25
- .split("\x0")
26
- .reject {|f| f.match(%r{^(test|spec|features)/}) }
31
+ `git ls-files -z`.split("\x0")
27
32
  end
33
+
28
34
  spec.bindir = "exe"
29
35
  spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
30
36
  spec.require_paths = ["lib"]
31
37
 
32
- spec.add_development_dependency "bundler"
33
38
  spec.add_development_dependency "minitest"
34
39
  spec.add_development_dependency "minitest-utils"
40
+ spec.add_development_dependency "pry-meta"
35
41
  spec.add_development_dependency "rake"
36
42
  spec.add_development_dependency "rubocop"
37
43
  spec.add_development_dependency "rubocop-fnando"
data/lib/glob/query.rb CHANGED
@@ -27,7 +27,7 @@ module Glob
27
27
 
28
28
  def paths
29
29
  matches = map.map do |path|
30
- results = matchers.select {|matcher| matcher.match?(path) }
30
+ results = matchers.select {|matcher| matcher.match?(path) } # rubocop:disable Style/SelectByRegexp
31
31
  [path, results]
32
32
  end
33
33
 
data/lib/glob/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Glob
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class MapTest < Minitest::Test
6
+ test "generates map for hash" do
7
+ map = Glob::Map.call(
8
+ user: {
9
+ email: "EMAIL",
10
+ addresses: [
11
+ {
12
+ description: "DESCRIPTION",
13
+ city: "CITY",
14
+ state: "STATE"
15
+ }
16
+ ],
17
+ preferences: {
18
+ theme: "dark"
19
+ }
20
+ },
21
+
22
+ options: {
23
+ notifications: {
24
+ system: true,
25
+ marketing: true
26
+ }
27
+ }
28
+ )
29
+
30
+ assert_equal [
31
+ "options.notifications.marketing",
32
+ "options.notifications.system",
33
+ "user.addresses",
34
+ "user.email",
35
+ "user.preferences.theme"
36
+ ], map
37
+ end
38
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class SymbolizeKeysTest < Minitest::Test
6
+ test "symbolizes hash" do
7
+ input = {"a" => {"b" => 1}}
8
+ expected = {a: {b: 1}}
9
+ actual = Glob::SymbolizeKeys.call(input)
10
+
11
+ assert_equal expected, actual
12
+ end
13
+
14
+ test "symbolizes arrays" do
15
+ input = [{"a" => {"b" => [1, 2, 3]}}]
16
+ expected = [{a: {b: [1, 2, 3]}}]
17
+ actual = Glob::SymbolizeKeys.call(input)
18
+
19
+ assert_equal expected, actual
20
+ end
21
+ end
data/test/glob_test.rb ADDED
@@ -0,0 +1,192 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class GlobTest < Minitest::Test
6
+ test "with rejecting filter" do
7
+ glob = Glob.new(
8
+ en: {
9
+ messages: {
10
+ hello: "Hello!",
11
+ bye: "Bye!"
12
+ }
13
+ },
14
+ pt: {
15
+ messages: {
16
+ hello: "Olá!",
17
+ bye: "Tchau!"
18
+ }
19
+ }
20
+ )
21
+
22
+ glob << "*.messages.*"
23
+ glob << "!*.messages.bye"
24
+
25
+ expected = {
26
+ en: {
27
+ messages: {
28
+ hello: "Hello!"
29
+ }
30
+ },
31
+ pt: {
32
+ messages: {
33
+ hello: "Olá!"
34
+ }
35
+ }
36
+ }
37
+
38
+ assert_equal ["en.messages.hello", "pt.messages.hello"], glob.paths
39
+ assert_equal expected, glob.to_h
40
+ assert_equal expected, glob.to_hash
41
+ end
42
+
43
+ test "with overlapping filters" do
44
+ glob = Glob.new(
45
+ en: {
46
+ messages: {
47
+ hello: "Hello!",
48
+ bye: "Bye!"
49
+ }
50
+ },
51
+ pt: {
52
+ messages: {
53
+ hello: "Olá!",
54
+ bye: "Tchau!"
55
+ }
56
+ }
57
+ )
58
+
59
+ glob << "*.messages.*"
60
+ glob << "!*.messages.bye"
61
+ glob << "en.messages.bye"
62
+
63
+ expected = {
64
+ en: {
65
+ messages: {
66
+ bye: "Bye!",
67
+ hello: "Hello!"
68
+ }
69
+ },
70
+ pt: {
71
+ messages: {
72
+ hello: "Olá!"
73
+ }
74
+ }
75
+ }
76
+
77
+ assert_equal [
78
+ "en.messages.bye",
79
+ "en.messages.hello",
80
+ "pt.messages.hello"
81
+ ], glob.paths
82
+ assert_equal expected, glob.to_h
83
+ assert_equal expected, glob.to_hash
84
+ end
85
+
86
+ test "with last component as star" do
87
+ glob = Glob.new(
88
+ user: {name: "USER", email: "EMAIL"},
89
+ repo: {name: "REPO"}
90
+ )
91
+
92
+ expected = {user: {name: "USER", email: "EMAIL"}}
93
+ glob << "user.*"
94
+
95
+ assert_equal ["user.email", "user.name"], glob.paths
96
+ assert_equal expected, glob.to_hash
97
+ end
98
+
99
+ test "with star as the initial component" do
100
+ glob = Glob.new(
101
+ user: {name: "USER", email: "EMAIL"},
102
+ repo: {name: "REPO"}
103
+ )
104
+
105
+ expected = {user: {name: "USER"}, repo: {name: "REPO"}}
106
+ glob << "*.name"
107
+
108
+ assert_equal ["repo.name", "user.name"], glob.paths
109
+ assert_equal expected, glob.to_hash
110
+ end
111
+
112
+ test "with star as the middle component" do
113
+ glob = Glob.new(
114
+ config: {
115
+ user: {name: "USER", email: "EMAIL"},
116
+ site: {name: "SITE", host: "HOST"}
117
+ }
118
+ )
119
+
120
+ expected = {config: {user: {name: "USER"}, site: {name: "SITE"}}}
121
+ glob << "config.*.name"
122
+
123
+ assert_equal ["config.site.name", "config.user.name"], glob.paths
124
+ assert_equal expected, glob.to_hash
125
+ end
126
+
127
+ test "with just a star" do
128
+ expected = {
129
+ config: {
130
+ user: {name: "USER", email: "EMAIL"},
131
+ site: {name: "SITE", host: "HOST"}
132
+ }
133
+ }
134
+ glob = Glob.new(expected)
135
+ glob << "*"
136
+
137
+ assert_equal [
138
+ "config.site.host",
139
+ "config.site.name",
140
+ "config.user.email",
141
+ "config.user.name"
142
+ ], glob.paths
143
+ assert_equal expected, glob.to_hash
144
+ end
145
+
146
+ test "with mixed stars" do
147
+ glob = Glob.new(
148
+ config: {
149
+ user: {name: "USER", email: "EMAIL"},
150
+ site: {name: "SITE", host: "HOST"}
151
+ }
152
+ )
153
+ glob << "*.site.*"
154
+
155
+ expected = {
156
+ config: {
157
+ site: {name: "SITE", host: "HOST"}
158
+ }
159
+ }
160
+
161
+ assert_equal [
162
+ "config.site.host",
163
+ "config.site.name"
164
+ ], glob.paths
165
+ assert_equal expected, glob.to_hash
166
+ end
167
+
168
+ test "filter includes everything by default" do
169
+ data = {
170
+ config: {
171
+ user: {name: "USER", email: "EMAIL"},
172
+ site: {name: "SITE", host: "HOST"}
173
+ }
174
+ }
175
+ actual = Glob.filter(data)
176
+
177
+ assert_equal data, actual
178
+ end
179
+
180
+ test "filter using specified filters" do
181
+ data = {
182
+ config: {
183
+ user: {name: "USER", email: "EMAIL"},
184
+ site: {name: "SITE", host: "HOST"}
185
+ }
186
+ }
187
+ expected = {config: {user: {name: "USER"}}}
188
+ actual = Glob.filter(data, ["config.user.name"])
189
+
190
+ assert_equal expected, actual
191
+ end
192
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "simplecov"
4
+ SimpleCov.start
5
+
6
+ require "bundler/setup"
7
+ require "glob"
8
+
9
+ require "minitest/utils"
10
+ require "minitest/autorun"
11
+
12
+ Dir["#{__dir__}/support/**/*.rb"].sort.each do |file|
13
+ require file
14
+ end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-15 00:00:00.000000000 Z
11
+ date: 2022-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: minitest
28
+ name: minitest-utils
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: minitest-utils
42
+ name: pry-meta
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -116,16 +116,20 @@ executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
+ - ".github/CODEOWNERS"
119
120
  - ".github/FUNDING.yml"
120
- - ".github/workflows/tests.yml"
121
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
122
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
123
+ - ".github/PULL_REQUEST_TEMPLATE.md"
124
+ - ".github/dependabot.yml"
125
+ - ".github/workflows/ruby-tests.yml"
121
126
  - ".gitignore"
122
127
  - ".rubocop.yml"
123
- - ".travis.yml"
124
128
  - CHANGELOG.md
125
129
  - CODE_OF_CONDUCT.md
130
+ - CONTRIBUTING.md
126
131
  - Gemfile
127
- - Gemfile.lock
128
- - LICENSE.txt
132
+ - LICENSE.md
129
133
  - README.md
130
134
  - Rakefile
131
135
  - bin/console
@@ -137,14 +141,22 @@ files:
137
141
  - lib/glob/query.rb
138
142
  - lib/glob/symbolize_keys.rb
139
143
  - lib/glob/version.rb
144
+ - test/glob/map_test.rb
145
+ - test/glob/symbolize_keys_test.rb
146
+ - test/glob_test.rb
147
+ - test/test_helper.rb
140
148
  homepage: https://github.com/fnando/glob
141
149
  licenses:
142
150
  - MIT
143
151
  metadata:
152
+ rubygems_mfa_required: 'true'
144
153
  homepage_uri: https://github.com/fnando/glob
145
- source_code_uri: https://github.com/fnando/glob
146
- changelog_uri: https://github.com/fnando/glob
147
- post_install_message:
154
+ bug_tracker_uri: https://github.com/fnando/glob/issues
155
+ source_code_uri: https://github.com/fnando/glob/tree/v0.2.1
156
+ changelog_uri: https://github.com/fnando/glob/tree/v0.2.1/CHANGELOG.md
157
+ documentation_uri: https://github.com/fnando/glob/tree/v0.2.1/README.md
158
+ license_uri: https://github.com/fnando/glob/tree/v0.2.1/LICENSE.md
159
+ post_install_message:
148
160
  rdoc_options: []
149
161
  require_paths:
150
162
  - lib
@@ -152,15 +164,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
164
  requirements:
153
165
  - - ">="
154
166
  - !ruby/object:Gem::Version
155
- version: '0'
167
+ version: 2.7.0
156
168
  required_rubygems_version: !ruby/object:Gem::Requirement
157
169
  requirements:
158
170
  - - ">="
159
171
  - !ruby/object:Gem::Version
160
172
  version: '0'
161
173
  requirements: []
162
- rubygems_version: 3.0.3
163
- signing_key:
174
+ rubygems_version: 3.3.3
175
+ signing_key:
164
176
  specification_version: 4
165
177
  summary: Create a list of hash paths that match a given pattern. You can also generate
166
178
  a hash with only the matching paths.
@@ -1,47 +0,0 @@
1
- ---
2
- name: tests
3
-
4
- on: [push]
5
-
6
- jobs:
7
- build:
8
- runs-on: ubuntu-latest
9
-
10
- steps:
11
- - name: Clone repo
12
- uses: actions/checkout@v1
13
-
14
- - name: Ruby cache
15
- uses: actions/cache@v1
16
- id: cache
17
- with:
18
- path: ~/local/rubies
19
- key: ruby-2.6.5
20
-
21
- - name: Rubygems cache
22
- uses: actions/cache@v1
23
- with:
24
- path: vendor/bundle
25
- key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
26
- restore-keys: ${{ runner.os }}-gem-
27
-
28
- - name: Install ruby
29
- uses: clupprich/ruby-build-action@master
30
- id: ruby
31
- with:
32
- ruby-version: 2.6.5
33
- cache-available: ${{ steps.cache.outputs.cache-hit == 'true' }}
34
-
35
- - name: Bundle install
36
- run: |
37
- gem install bundler
38
- bundle config path vendor/bundle
39
- bundle install --jobs 4 --retry 3
40
-
41
- - name: Run ruby tests
42
- run: |
43
- bundle exec rake
44
-
45
- - name: Run lint
46
- run: |
47
- bundle exec rubocop
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.5
7
- before_install: gem install bundler -v 2.0.2
data/Gemfile.lock DELETED
@@ -1,51 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- glob (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.4.0)
10
- docile (1.3.2)
11
- jaro_winkler (1.5.4)
12
- json (2.3.0)
13
- minitest (5.13.0)
14
- minitest-utils (0.4.6)
15
- minitest
16
- parallel (1.19.1)
17
- parser (2.6.5.0)
18
- ast (~> 2.4.0)
19
- rainbow (3.0.0)
20
- rake (13.0.1)
21
- rubocop (0.77.0)
22
- jaro_winkler (~> 1.5.1)
23
- parallel (~> 1.10)
24
- parser (>= 2.6)
25
- rainbow (>= 2.2.2, < 4.0)
26
- ruby-progressbar (~> 1.7)
27
- unicode-display_width (>= 1.4.0, < 1.7)
28
- rubocop-fnando (0.0.3)
29
- ruby-progressbar (1.10.1)
30
- simplecov (0.17.1)
31
- docile (~> 1.1)
32
- json (>= 1.8, < 3)
33
- simplecov-html (~> 0.10.0)
34
- simplecov-html (0.10.2)
35
- unicode-display_width (1.6.0)
36
-
37
- PLATFORMS
38
- ruby
39
-
40
- DEPENDENCIES
41
- bundler
42
- glob!
43
- minitest
44
- minitest-utils
45
- rake
46
- rubocop
47
- rubocop-fnando
48
- simplecov
49
-
50
- BUNDLED WITH
51
- 2.0.2
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2019 Nando Vieira
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.