mq-ruby 0.1.28 → 0.1.29
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 +4 -4
- data/Cargo.toml +3 -3
- data/README.md +16 -0
- data/lib/mq/query.rb +33 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 35916b41ef1f575acbb4bb4e985538ed03b5974d803e5361c4fa9f1e1acf7f9f
|
|
4
|
+
data.tar.gz: f3df56c6c68b6ac2bcef0e63bd03e9eb9b006d78a7a3bc02f2feff0f129de0de
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2087a467b5f43cdc92c9bec713d9db7384fdf30bd1d5993e5a46bb77f5e1e7c4a6ce60842aaf662e14d860047d513896c5a87047ed9e46071191798d37dc44b9
|
|
7
|
+
data.tar.gz: 70896ae9198014ed316b3cbbd27e25ea4097ad6d74e2ee116af43ffa03617fa2dd6058e0dc0d014a37ba2b719c2e02032db1ff8718b6a52e8c8779c4de2af3d1
|
data/Cargo.toml
CHANGED
|
@@ -10,7 +10,7 @@ name = "mq-ruby"
|
|
|
10
10
|
publish = false
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
repository = "https://github.com/harehare/mq"
|
|
13
|
-
version = "0.1.
|
|
13
|
+
version = "0.1.29"
|
|
14
14
|
|
|
15
15
|
[lib]
|
|
16
16
|
crate-type = ["cdylib"]
|
|
@@ -18,6 +18,6 @@ name = "mq_ruby"
|
|
|
18
18
|
|
|
19
19
|
[dependencies]
|
|
20
20
|
magnus = {version = "0.8"}
|
|
21
|
-
mq-lang = "0.6.
|
|
22
|
-
mq-markdown = "0.6.
|
|
21
|
+
mq-lang = "0.6.5"
|
|
22
|
+
mq-markdown = "0.6.5"
|
|
23
23
|
|
data/README.md
CHANGED
|
@@ -254,6 +254,7 @@ MQ::Query.list.map { contains("important") }
|
|
|
254
254
|
.to_html # to_html() — HTML string
|
|
255
255
|
.to_string # to_string() — string coercion
|
|
256
256
|
.to_number # to_number() — numeric coercion
|
|
257
|
+
.to_boolean # to_boolean() — boolean coercion
|
|
257
258
|
.to_array # to_array()
|
|
258
259
|
.to_bytes # to_bytes()
|
|
259
260
|
.to_markdown_string # to_markdown_string()
|
|
@@ -267,11 +268,14 @@ MQ::Query.list.map { contains("important") }
|
|
|
267
268
|
.rtrim # rtrim()
|
|
268
269
|
.downcase # downcase()
|
|
269
270
|
.upcase # upcase()
|
|
271
|
+
.ascii_downcase # ascii_downcase()
|
|
272
|
+
.ascii_upcase # ascii_upcase()
|
|
270
273
|
.len # len()
|
|
271
274
|
.utf8bytelen # utf8bytelen()
|
|
272
275
|
.explode # explode() — string to codepoints
|
|
273
276
|
.implode # implode() — codepoints to string
|
|
274
277
|
.url_encode # url_encode()
|
|
278
|
+
.url_decode # url_decode()
|
|
275
279
|
.intern # intern()
|
|
276
280
|
|
|
277
281
|
.split(",") # split(",")
|
|
@@ -279,6 +283,7 @@ MQ::Query.list.map { contains("important") }
|
|
|
279
283
|
.replace("a", "b") # replace("a", "b") — literal replace
|
|
280
284
|
.test("\\d+") # test("\\d+") — regex test → bool
|
|
281
285
|
.capture("(\\w+)") # capture("(\\w+)") — regex capture
|
|
286
|
+
.scan("(\\w+)") # scan("(\\w+)") — all regex matches
|
|
282
287
|
.slice(0, 5) # slice(0, 5)
|
|
283
288
|
.index("sub") # index("sub") — position of substring
|
|
284
289
|
.rindex("sub") # rindex("sub") — last position
|
|
@@ -309,6 +314,8 @@ MQ::Query.list.map { contains("important") }
|
|
|
309
314
|
.range(3) # range(3)
|
|
310
315
|
.del("key") # del("key")
|
|
311
316
|
.insert(0, "val") # insert(0, "val")
|
|
317
|
+
.shuffle # shuffle() — random order
|
|
318
|
+
.sample(3) # sample(3) — n random elements, no replacement
|
|
312
319
|
```
|
|
313
320
|
|
|
314
321
|
#### Math Operations
|
|
@@ -350,8 +357,17 @@ MQ::Query.list.map { contains("important") }
|
|
|
350
357
|
.sha512 # sha512()
|
|
351
358
|
.from_hex # from_hex()
|
|
352
359
|
.to_hex # to_hex()
|
|
360
|
+
.uuid # uuid() — random (v4) UUID
|
|
361
|
+
.uuid_v4 # uuid_v4() — alias of uuid
|
|
362
|
+
.uuid_v7 # uuid_v7() — time-ordered (v7) UUID
|
|
363
|
+
.rand # rand() — pseudo-random number in [0, 1)
|
|
364
|
+
.rand_int(1, 10) # rand_int(1, 10) — pseudo-random integer in [min, max]
|
|
353
365
|
```
|
|
354
366
|
|
|
367
|
+
`MQ::Query.uuid`, `.uuid_v4`, `.uuid_v7`, `.rand`, and `.rand_int(min, max)` are
|
|
368
|
+
also available as class-level generators to start a query without a preceding
|
|
369
|
+
selector, e.g. `MQ::Query.uuid.to_query # => "uuid()"`.
|
|
370
|
+
|
|
355
371
|
#### Path Operations
|
|
356
372
|
|
|
357
373
|
```ruby
|
data/lib/mq/query.rb
CHANGED
|
@@ -66,6 +66,7 @@ module MQ
|
|
|
66
66
|
def to_html = pipe_with("to_html()")
|
|
67
67
|
def to_string = pipe_with("to_string()")
|
|
68
68
|
def to_number = pipe_with("to_number()")
|
|
69
|
+
def to_boolean = pipe_with("to_boolean()")
|
|
69
70
|
def to_array = pipe_with("to_array()")
|
|
70
71
|
def to_bytes = pipe_with("to_bytes()")
|
|
71
72
|
def to_markdown_string = pipe_with("to_markdown_string()")
|
|
@@ -135,14 +136,23 @@ module MQ
|
|
|
135
136
|
pipe_with("repeat(#{n})")
|
|
136
137
|
end
|
|
137
138
|
|
|
139
|
+
def shuffle = pipe_with("shuffle()")
|
|
140
|
+
|
|
141
|
+
def sample(n)
|
|
142
|
+
pipe_with("sample(#{n})")
|
|
143
|
+
end
|
|
144
|
+
|
|
138
145
|
def trim = pipe_with("trim()")
|
|
139
146
|
def ltrim = pipe_with("ltrim()")
|
|
140
147
|
def rtrim = pipe_with("rtrim()")
|
|
141
148
|
def downcase = pipe_with("downcase()")
|
|
142
149
|
def upcase = pipe_with("upcase()")
|
|
150
|
+
def ascii_downcase = pipe_with("ascii_downcase()")
|
|
151
|
+
def ascii_upcase = pipe_with("ascii_upcase()")
|
|
143
152
|
def explode = pipe_with("explode()")
|
|
144
153
|
def implode = pipe_with("implode()")
|
|
145
154
|
def url_encode = pipe_with("url_encode()")
|
|
155
|
+
def url_decode = pipe_with("url_decode()")
|
|
146
156
|
def intern = pipe_with("intern()")
|
|
147
157
|
|
|
148
158
|
def gsub(pattern, replacement)
|
|
@@ -161,6 +171,10 @@ module MQ
|
|
|
161
171
|
pipe_with("capture(#{pattern.inspect})")
|
|
162
172
|
end
|
|
163
173
|
|
|
174
|
+
def scan(pattern)
|
|
175
|
+
pipe_with("scan(#{pattern.inspect})")
|
|
176
|
+
end
|
|
177
|
+
|
|
164
178
|
def abs = pipe_with("abs()")
|
|
165
179
|
def ceil = pipe_with("ceil()")
|
|
166
180
|
def floor = pipe_with("floor()")
|
|
@@ -205,6 +219,15 @@ module MQ
|
|
|
205
219
|
def to_hex = pipe_with("to_hex()")
|
|
206
220
|
def to_hex_str = pipe_with("to_hex()")
|
|
207
221
|
|
|
222
|
+
def uuid = pipe_with("uuid()")
|
|
223
|
+
def uuid_v4 = pipe_with("uuid_v4()")
|
|
224
|
+
def uuid_v7 = pipe_with("uuid_v7()")
|
|
225
|
+
def rand = pipe_with("rand()")
|
|
226
|
+
|
|
227
|
+
def rand_int(min, max)
|
|
228
|
+
pipe_with("rand_int(#{min}, #{max})")
|
|
229
|
+
end
|
|
230
|
+
|
|
208
231
|
def basename = pipe_with("basename()")
|
|
209
232
|
def dirname = pipe_with("dirname()")
|
|
210
233
|
def extname = pipe_with("extname()")
|
|
@@ -453,6 +476,16 @@ module MQ
|
|
|
453
476
|
|
|
454
477
|
def to_text = new("to_text()")
|
|
455
478
|
def to_markdown = new("to_markdown()")
|
|
479
|
+
|
|
480
|
+
# --- Value generators (usable as query starting points) ---
|
|
481
|
+
def uuid = new("uuid()")
|
|
482
|
+
def uuid_v4 = new("uuid_v4()")
|
|
483
|
+
def uuid_v7 = new("uuid_v7()")
|
|
484
|
+
def rand = new("rand()")
|
|
485
|
+
|
|
486
|
+
def rand_int(min, max)
|
|
487
|
+
new("rand_int(#{min}, #{max})")
|
|
488
|
+
end
|
|
456
489
|
end
|
|
457
490
|
|
|
458
491
|
private
|