glob 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-tests.yml +2 -2
- data/README.md +3 -0
- data/lib/glob/matcher.rb +9 -1
- data/lib/glob/version.rb +1 -1
- data/test/glob_test.rb +31 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1364c317c2dde1a64f6f201956383cd023185d64349b101e8d167326701cc4fa
|
4
|
+
data.tar.gz: 76c07526698da02bb9792d29f3bafaa170fe03750f5bd335f7f80efb06114167
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fcc6b11d949bb8e941794c39b6e83efc39c7fd94be7d51a2314d3b50cd7afe680448759cd28c6abe17f4f8566ba5ff31332c0806a014b1c1f4fa8a490117332
|
7
|
+
data.tar.gz: 5a15abeb7a6a9845fb00563f4b7ef5a53e0d432ca92f6fc239315ba38bd76fa84e1f68f9128c3aeec94834df1a2a94b50d32b3e929021af004fe1fbaab32d256
|
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(/^!/, ""))
|
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
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.
|
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-
|
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.
|
156
|
-
changelog_uri: https://github.com/fnando/glob/tree/v0.
|
157
|
-
documentation_uri: https://github.com/fnando/glob/tree/v0.
|
158
|
-
license_uri: https://github.com/fnando/glob/tree/v0.
|
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.
|
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
|