glob 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45093c60b816f8216b7f61ecf9a87d682ebed8e355812d5f182d951f5573fa50
4
- data.tar.gz: 7cbeef3c989d6b06217a127ef54fca2e04dc0e26f60fb0bca27fdc69a4cc24ed
3
+ metadata.gz: 6ff5ab685a7e249aa924466ecde163739bbaa39021112375b010682b8f3c19ec
4
+ data.tar.gz: 9bd5d1e109640be5b6dc8b68af7f8158c8eb6bd460dcb84e5e07161cd2e21977
5
5
  SHA512:
6
- metadata.gz: d0fa710b8631ec0b85e9d86fb55fb666e82a709946b9209621e7da54cf41c6417056daeeba007b1b977b239e79cb86261f1af9eebe30d00b8e1926cee05f9af2
7
- data.tar.gz: cb099c539ea6b9317ed8622a22c9eddd1bf25ca5ca058eb1b9a5d328aa63924c10ac825c5fcc8c3a63d4c962de1c31109d31fb03fa59412851552a531f41fbb9
6
+ metadata.gz: c2343bfb510ea2f78ba403fab7d0f4eca8caf2ef0e0a5b40076b17ebeca1e45a1bc61da16b7816bd095ba157dcd2cb83f6696789550c500cd31989c07e98addc
7
+ data.tar.gz: 11704b0cc7e4e0e7107f7c4f24f2c9f3885acde420a993f9b47b2a76865998067aa24c9940a16986f6438b2e12820e39b3fbd393035fe1ff8fd299dafc815b16
@@ -19,20 +19,18 @@ jobs:
19
19
  strategy:
20
20
  fail-fast: false
21
21
  matrix:
22
- ruby: ["2.7", "3.0", "3.1"]
22
+ ruby: ["3.4", "3.5", "4.0"]
23
23
  gemfile:
24
24
  - Gemfile
25
25
 
26
26
  steps:
27
- - uses: actions/checkout@v3
27
+ - uses: actions/checkout@v6
28
28
 
29
- - uses: actions/cache@v3
29
+ - uses: actions/cache@v5
30
30
  with:
31
31
  path: vendor/bundle
32
32
  key: >
33
- ${{ runner.os }}-${{ matrix.ruby }}-gems-${{
34
- hashFiles(matrix.gemfile) }}
35
-
33
+ ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles(matrix.gemfile) }}
36
34
  - name: Set up Ruby
37
35
  uses: ruby/setup-ruby@v1
38
36
  with:
data/CHANGELOG.md CHANGED
@@ -11,6 +11,15 @@ Prefix your message with one of the following:
11
11
  - [Security] in case of vulnerabilities.
12
12
  -->
13
13
 
14
+ ## v0.5.0 - 2026-05-31
15
+
16
+ - [Added] Add `Glob::Object#match?`, so you can check things like
17
+ `glob.match?("a.*")`.
18
+
19
+ ## v0.4.1 - 2024-01-03
20
+
21
+ - [Fixed] Fix partial matching when not using `*`.
22
+
14
23
  ## v0.4.0 - 2022-12-05
15
24
 
16
25
  - [Changed] `Glob::Query` has been renamed to `Glob::Object`.
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # glob
2
2
 
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)
3
+ [![ruby-tests](https://github.com/fnando/glob/actions/workflows/ruby-tests.yml/badge.svg)](https://github.com/fnando/glob/actions/workflows/ruby-tests.yml)
5
4
  [![Gem](https://img.shields.io/gem/v/glob.svg)](https://rubygems.org/gems/glob)
6
5
  [![Gem](https://img.shields.io/gem/dt/glob.svg)](https://rubygems.org/gems/glob)
7
6
 
@@ -102,6 +101,12 @@ glob.paths
102
101
 
103
102
  glob.to_h
104
103
  #=> {:formats=>{:".rb"=>"Ruby"}}
104
+
105
+ glob.match?("formats")
106
+ #=> false
107
+
108
+ glob.match?("formats.*")
109
+ #=> true
105
110
  ```
106
111
 
107
112
  You can set new keys by using `.set(path, value)`:
data/glob.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "./lib/glob/version"
3
+ require_relative "lib/glob/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "glob"
data/lib/glob/matcher.rb CHANGED
@@ -10,8 +10,9 @@ module Glob
10
10
 
11
11
  pattern = Regexp.escape(path.gsub(/^!/, ""))
12
12
  .gsub(/(\\{.*?\\})/) {|match| process_group(match) }
13
- .gsub(/\\\*/, "[^.]+")
14
- @regex = Regexp.new("^#{pattern}")
13
+ .gsub("\\*", "[^.]+")
14
+ anchor = path.end_with?("*") ? "" : "$"
15
+ @regex = Regexp.new("^#{pattern}#{anchor}")
15
16
  end
16
17
 
17
18
  def match?(other)
data/lib/glob/object.rb CHANGED
@@ -46,12 +46,19 @@ module Glob
46
46
  .sort
47
47
  end
48
48
 
49
+ def match?(wanted)
50
+ matcher = Matcher.new(wanted)
51
+ list = paths
52
+ list.include?(wanted) || list.any? {|path| matcher.match?(path) }
53
+ end
54
+ alias =~ match?
55
+
49
56
  private def map
50
57
  @map ||= Map.call(@target)
51
58
  end
52
59
 
53
60
  private def unescape(key)
54
- key.to_s.gsub(/\\\./, ".")
61
+ key.to_s.gsub("\\.", ".")
55
62
  end
56
63
 
57
64
  private def set_path_value(segments, target, value)
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.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
data/test/glob_test.rb CHANGED
@@ -3,6 +3,17 @@
3
3
  require "test_helper"
4
4
 
5
5
  class GlobTest < Minitest::Test
6
+ test "with partial matching" do
7
+ glob = Glob.new(
8
+ en: {editor: "editor", edit: "edit"},
9
+ pt: {editor: "editor", edit: "edit"}
10
+ )
11
+
12
+ glob << "*.edit"
13
+
14
+ assert_equal ["en.edit", "pt.edit"], glob.paths
15
+ end
16
+
6
17
  test "with rejecting filter" do
7
18
  glob = Glob.new(
8
19
  en: {
@@ -276,4 +287,15 @@ class GlobTest < Minitest::Test
276
287
  assert_equal expected, glob.to_h
277
288
  assert_equal ["a.a1.a2", "b.b1.b2.b3.b4"], glob.paths
278
289
  end
290
+
291
+ test "checks key" do
292
+ glob = Glob.new(a: 1, b: {b1: {b2: 2}})
293
+ glob << "*"
294
+
295
+ assert_match glob, "a"
296
+ refute_match glob, "a.*"
297
+ assert_match glob, "b.*"
298
+ assert_match glob, "b.b1.*"
299
+ assert_match glob, "b.b1.b2"
300
+ end
279
301
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-12-06 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: minitest
@@ -152,11 +151,10 @@ metadata:
152
151
  rubygems_mfa_required: 'true'
153
152
  homepage_uri: https://github.com/fnando/glob
154
153
  bug_tracker_uri: https://github.com/fnando/glob/issues
155
- source_code_uri: https://github.com/fnando/glob/tree/v0.4.0
156
- changelog_uri: https://github.com/fnando/glob/tree/v0.4.0/CHANGELOG.md
157
- documentation_uri: https://github.com/fnando/glob/tree/v0.4.0/README.md
158
- license_uri: https://github.com/fnando/glob/tree/v0.4.0/LICENSE.md
159
- post_install_message:
154
+ source_code_uri: https://github.com/fnando/glob/tree/v0.5.0
155
+ changelog_uri: https://github.com/fnando/glob/tree/v0.5.0/CHANGELOG.md
156
+ documentation_uri: https://github.com/fnando/glob/tree/v0.5.0/README.md
157
+ license_uri: https://github.com/fnando/glob/tree/v0.5.0/LICENSE.md
160
158
  rdoc_options: []
161
159
  require_paths:
162
160
  - lib
@@ -171,8 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
169
  - !ruby/object:Gem::Version
172
170
  version: '0'
173
171
  requirements: []
174
- rubygems_version: 3.3.26
175
- signing_key:
172
+ rubygems_version: 4.0.10
176
173
  specification_version: 4
177
174
  summary: Create a list of hash paths that match a given pattern. You can also generate
178
175
  a hash with only the matching paths.