command_search 0.3.0 → 0.4.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 +4 -4
- data/lib/command_search/aliaser.rb +8 -14
- data/lib/command_search/mongoer.rb +2 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c362907118b743a2b22ec4828a138bc9dd825d7f9359bac7679818b0ccc1fa3
|
4
|
+
data.tar.gz: 82346ff2cce58d1b119fe96f35e92a8bc4527442038af10b8ad7f88b1d1ef902
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f34e7224f15fdb9d54439a8ec6f3e0e155509e01a178f04d251baccb0421bedd31c0e5fe85701d60f7fba6ea2d6875b484e7f7546f43336c9ee2617d31c8331
|
7
|
+
data.tar.gz: e3069421cb073394cb54bda87d9329673674f4dd8392213e1b06afbdeed6862d3f7aa656266168651190869ac85267fa92e0a34d50a0d4493875ddff8d2a9a21
|
@@ -8,13 +8,16 @@ module CommandSearch
|
|
8
8
|
Regexp.new(head_border + Regexp.escape(str) + tail_border, 'i')
|
9
9
|
end
|
10
10
|
|
11
|
-
def quotes?(
|
11
|
+
def quotes?(str, offset)
|
12
|
+
head = str[0...offset[0]]
|
13
|
+
tail = str[offset[1]..-1]
|
12
14
|
return true if head.count("'").odd? && tail.count("'").odd?
|
13
15
|
return true if head.count('"').odd? && tail.count('"').odd?
|
14
16
|
false
|
15
17
|
end
|
16
18
|
|
17
19
|
def alias_item(query, alias_key, alias_value)
|
20
|
+
return query unless alias_value.is_a?(String) || alias_value.is_a?(Proc)
|
18
21
|
if alias_key.is_a?(Regexp)
|
19
22
|
pattern = alias_key
|
20
23
|
elsif alias_key.is_a?(String)
|
@@ -22,23 +25,14 @@ module CommandSearch
|
|
22
25
|
else
|
23
26
|
return query
|
24
27
|
end
|
25
|
-
|
26
|
-
|
27
|
-
offset = Regexp.last_match.offset(0)
|
28
|
-
head = query[0...offset.first]
|
29
|
-
tail = alias_item(query[offset.last..-1], alias_key, alias_value)
|
30
|
-
if quotes?(head, tail)
|
31
|
-
replacement = current_match
|
32
|
-
else
|
28
|
+
query.gsub(pattern) do |match|
|
29
|
+
next match if quotes?(query, Regexp.last_match.offset(0))
|
33
30
|
if alias_value.is_a?(String)
|
34
|
-
|
31
|
+
alias_value
|
35
32
|
elsif alias_value.is_a?(Proc)
|
36
|
-
|
37
|
-
else
|
38
|
-
return query
|
33
|
+
alias_value.call(match).to_s
|
39
34
|
end
|
40
35
|
end
|
41
|
-
head + replacement + tail
|
42
36
|
end
|
43
37
|
|
44
38
|
def alias(query, aliases)
|
@@ -31,13 +31,11 @@ module CommandSearch
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def is_bool_str?(str)
|
34
|
-
|
35
|
-
false
|
34
|
+
str[/\Atrue\Z|\Afalse\Z/i]
|
36
35
|
end
|
37
36
|
|
38
37
|
def make_boolean(str)
|
39
|
-
|
40
|
-
false
|
38
|
+
str[/\Atrue\Z/i]
|
41
39
|
end
|
42
40
|
|
43
41
|
def build_command(ast_node, command_types)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: command_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zumbalogy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
60
|
rubyforge_project:
|
61
|
-
rubygems_version: 2.7.
|
61
|
+
rubygems_version: 2.7.8
|
62
62
|
signing_key:
|
63
63
|
specification_version: 4
|
64
64
|
summary: Let users query collections with ease.
|