glob 0.2.2 → 0.3.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: 710091fe39bdc121bfbb38031b3c85c4fb2fd3f17793a33cd77650e0ccb0ff99
4
- data.tar.gz: 6494946d8f6f72bf148d07f3fffbeec90d2b0eb28099de6890f3055e7e01f80b
3
+ metadata.gz: 1364c317c2dde1a64f6f201956383cd023185d64349b101e8d167326701cc4fa
4
+ data.tar.gz: 76c07526698da02bb9792d29f3bafaa170fe03750f5bd335f7f80efb06114167
5
5
  SHA512:
6
- metadata.gz: 5ece615a763b898f36d186599b9704e07c46017fe6acd0acaaf4de5368a4af522185f2a7466474d8af20a8bcacd390ab5317082008b29ff7eee0a57337c123e6
7
- data.tar.gz: 89d411ddc1afd037ebb8a85d45db6dbf9ef881e7720158d9e4d4503eed98d21f9d43902c9ec501b49714da36d52a87a3e236b4fca3040932981fb71556d6e06b
6
+ metadata.gz: 4fcc6b11d949bb8e941794c39b6e83efc39c7fd94be7d51a2314d3b50cd7afe680448759cd28c6abe17f4f8566ba5ff31332c0806a014b1c1f4fa8a490117332
7
+ data.tar.gz: 5a15abeb7a6a9845fb00563f4b7ef5a53e0d432ca92f6fc239315ba38bd76fa84e1f68f9128c3aeec94834df1a2a94b50d32b3e929021af004fe1fbaab32d256
@@ -24,9 +24,9 @@ jobs:
24
24
  - Gemfile
25
25
 
26
26
  steps:
27
- - uses: actions/checkout@v2.4.0
27
+ - uses: actions/checkout@v3
28
28
 
29
- - uses: actions/cache@v2
29
+ - uses: actions/cache@v3
30
30
  with:
31
31
  path: vendor/bundle
32
32
  key: >
data/README.md CHANGED
@@ -28,6 +28,9 @@ There are two types of paths: `include` and `exclude`.
28
28
  - The `exclude` path is the one started by `!`, and will prevent that path from
29
29
  being added.
30
30
 
31
+ Rules may also have groups. Let's say you want to target `en.*` and `pt.*`; you
32
+ case set `{en,pt}.*` rather than having two separate rules.
33
+
31
34
  The latest rules have more precedence; that means that if you have the rule
32
35
  `*.messages.*`, then add a following rule as `!*.messages.bye`, all
33
36
  `*.messages.*` but `*.messages.bye` will be included.
data/lib/glob/matcher.rb CHANGED
@@ -8,7 +8,9 @@ module Glob
8
8
  @path = path
9
9
  @reject = path.start_with?("!")
10
10
 
11
- pattern = Regexp.escape(path.gsub(/^!/, "")).gsub(/\\\*/, "[^.]+")
11
+ pattern = Regexp.escape(path.gsub(/^!/, ""))
12
+ .gsub(/(\\{.*?\\})/) {|match| process_group(match) }
13
+ .gsub(/\\\*/, "[^.]+")
12
14
  @regex = Regexp.new("^#{pattern}")
13
15
  end
14
16
 
@@ -23,5 +25,11 @@ module Glob
23
25
  def reject?
24
26
  @reject
25
27
  end
28
+
29
+ def process_group(group)
30
+ group = group.gsub(/[{}\\]/, "").split(",").join("|")
31
+
32
+ "(#{group})"
33
+ end
26
34
  end
27
35
  end
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.2"
4
+ VERSION = "0.3.0"
5
5
  end
data/test/glob_test.rb CHANGED
@@ -189,4 +189,35 @@ class GlobTest < Minitest::Test
189
189
 
190
190
  assert_equal expected, actual
191
191
  end
192
+
193
+ test "using groups as root key" do
194
+ glob = Glob.new(
195
+ pt: {hello: "Olá!"},
196
+ en: {hello: "Hello!"},
197
+ es: {hello: "¡Hola!"}
198
+ )
199
+
200
+ glob << "{pt,en}.*"
201
+
202
+ assert_equal ["en.hello", "pt.hello"], glob.paths
203
+ end
204
+
205
+ test "using groups in mixed positions" do
206
+ glob = Glob.new(
207
+ pt: {messages: {hello: "Olá!", goodbye: "Tchau!"}},
208
+ en: {messages: {hello: "Hello!", goodbye: "Goodbye!"}},
209
+ es: {messages: {hello: "¡Hola!", goodbye: "¡Adios!"}}
210
+ )
211
+
212
+ glob << "{pt,en}.messages.{hello,goodbye}"
213
+
214
+ expected = [
215
+ "en.messages.goodbye",
216
+ "en.messages.hello",
217
+ "pt.messages.goodbye",
218
+ "pt.messages.hello"
219
+ ]
220
+
221
+ assert_equal expected, glob.paths
222
+ end
192
223
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-02 00:00:00.000000000 Z
11
+ date: 2022-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -152,10 +152,10 @@ metadata:
152
152
  rubygems_mfa_required: 'true'
153
153
  homepage_uri: https://github.com/fnando/glob
154
154
  bug_tracker_uri: https://github.com/fnando/glob/issues
155
- source_code_uri: https://github.com/fnando/glob/tree/v0.2.2
156
- changelog_uri: https://github.com/fnando/glob/tree/v0.2.2/CHANGELOG.md
157
- documentation_uri: https://github.com/fnando/glob/tree/v0.2.2/README.md
158
- license_uri: https://github.com/fnando/glob/tree/v0.2.2/LICENSE.md
155
+ source_code_uri: https://github.com/fnando/glob/tree/v0.3.0
156
+ changelog_uri: https://github.com/fnando/glob/tree/v0.3.0/CHANGELOG.md
157
+ documentation_uri: https://github.com/fnando/glob/tree/v0.3.0/README.md
158
+ license_uri: https://github.com/fnando/glob/tree/v0.3.0/LICENSE.md
159
159
  post_install_message:
160
160
  rdoc_options: []
161
161
  require_paths:
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
173
  requirements: []
174
- rubygems_version: 3.3.3
174
+ rubygems_version: 3.3.7
175
175
  signing_key:
176
176
  specification_version: 4
177
177
  summary: Create a list of hash paths that match a given pattern. You can also generate