hotdog 0.1.16 → 0.1.17
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/README.md +9 -0
- data/lib/hotdog/application.rb +1 -1
- data/lib/hotdog/commands/search.rb +9 -4
- data/lib/hotdog/commands.rb +10 -2
- data/lib/hotdog/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79e4334fc2d2f63537cbaa32bc44c2e5d069b4f5
|
4
|
+
data.tar.gz: bc9fdf8a14f3ab1a8ab02caa22e9841bfbff5181
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4e0aacb47ea09c873bbc7f39ee0b003d004716b619a5983eeb7c994a6c57ad4fd3f1286e2b9d1db89819cbf967745289d4e15a7d78109cf880f128173212227
|
7
|
+
data.tar.gz: e3f328b83968a36e98bedf91ced0e68e2f89a2edec886c1a6f2377a7e44d42d7158fdc76201ef53a27ddcd8a8176ae8be7a4db0e8771c7b47c75183e7092ec9b
|
data/README.md
CHANGED
@@ -100,25 +100,34 @@ Acceptable expressions in pseudo BNF.
|
|
100
100
|
```
|
101
101
|
expression: binary_expression
|
102
102
|
| term
|
103
|
+
;
|
103
104
|
|
104
105
|
binary_expression: term "&&" term
|
105
106
|
| term "||" term
|
106
107
|
| term "and" term
|
107
108
|
| term "or" term
|
109
|
+
;
|
108
110
|
|
109
111
|
unary_expression: '!' expression
|
110
112
|
| '~' expression
|
111
113
|
| "not" expression
|
114
|
+
;
|
112
115
|
|
113
116
|
term: unary_expression
|
114
117
|
| atom
|
118
|
+
;
|
115
119
|
|
116
120
|
atom: '(' expression ')'
|
117
121
|
| IDENTIFIER separator ATTRIBUTE
|
122
|
+
| IDENTIFIER separator
|
123
|
+
| separator ATTRIBUTE
|
118
124
|
| IDENTIFIER
|
125
|
+
| ATTRIBUTE
|
126
|
+
;
|
119
127
|
|
120
128
|
separator: ':'
|
121
129
|
| '='
|
130
|
+
;
|
122
131
|
```
|
123
132
|
|
124
133
|
|
data/lib/hotdog/application.rb
CHANGED
@@ -104,13 +104,18 @@ module Hotdog
|
|
104
104
|
rule(:atom) {
|
105
105
|
( spacing.maybe >> str('(') >> expression >> str(')') >> spacing.maybe \
|
106
106
|
| spacing.maybe >> identifier_regexp.as(:identifier_regexp) >> separator >> attribute_regexp.as(:attribute_regexp) >> spacing.maybe \
|
107
|
+
| spacing.maybe >> identifier_regexp.as(:identifier_regexp) >> separator >> spacing.maybe \
|
107
108
|
| spacing.maybe >> identifier_regexp.as(:identifier_regexp) >> spacing.maybe \
|
108
109
|
| spacing.maybe >> identifier_glob.as(:identifier_glob) >> separator >> attribute_glob.as(:attribute_glob) >> spacing.maybe \
|
109
110
|
| spacing.maybe >> identifier_glob.as(:identifier_glob) >> separator >> attribute.as(:attribute) >> spacing.maybe \
|
111
|
+
| spacing.maybe >> identifier_glob.as(:identifier_glob) >> separator >> spacing.maybe \
|
110
112
|
| spacing.maybe >> identifier_glob.as(:identifier_glob) >> spacing.maybe \
|
111
113
|
| spacing.maybe >> identifier.as(:identifier) >> separator >> attribute_glob.as(:attribute_glob) >> spacing.maybe \
|
112
114
|
| spacing.maybe >> identifier.as(:identifier) >> separator >> attribute.as(:attribute) >> spacing.maybe \
|
115
|
+
| spacing.maybe >> identifier.as(:identifier) >> separator >> spacing.maybe \
|
113
116
|
| spacing.maybe >> identifier.as(:identifier) >> spacing.maybe \
|
117
|
+
| spacing.maybe >> separator >> attribute_glob.as(:attribute_glob) >> spacing.maybe \
|
118
|
+
| spacing.maybe >> separator >> attribute.as(:attribute_glob) >> spacing.maybe \
|
114
119
|
| spacing.maybe >> attribute_regexp.as(:attribute_regexp) >> spacing.maybe \
|
115
120
|
| spacing.maybe >> attribute_glob.as(:attribute_glob) >> spacing.maybe \
|
116
121
|
| spacing.maybe >> attribute.as(:attribute) >> spacing.maybe \
|
@@ -265,10 +270,10 @@ module Hotdog
|
|
265
270
|
attr_reader :identifier
|
266
271
|
attr_reader :attribute
|
267
272
|
def identifier?
|
268
|
-
!identifier.nil?
|
273
|
+
!(identifier.nil? or identifier.to_s.empty?)
|
269
274
|
end
|
270
275
|
def attribute?
|
271
|
-
!attribute.nil?
|
276
|
+
!(attribute.nil? or attribute.to_s.empty?)
|
272
277
|
end
|
273
278
|
def evaluate(environment)
|
274
279
|
if identifier?
|
@@ -276,7 +281,7 @@ module Hotdog
|
|
276
281
|
case identifier
|
277
282
|
when /\Ahost\z/i
|
278
283
|
values = environment.execute(<<-EOS, attribute).map { |row| row.first }
|
279
|
-
SELECT
|
284
|
+
SELECT hosts.id FROM hosts
|
280
285
|
WHERE LOWER(hosts.name) = LOWER(?);
|
281
286
|
EOS
|
282
287
|
else
|
@@ -379,7 +384,7 @@ module Hotdog
|
|
379
384
|
case identifier
|
380
385
|
when /\Ahost\z/i
|
381
386
|
values = environment.execute(<<-EOS, attribute).map { |row| row.first }
|
382
|
-
SELECT
|
387
|
+
SELECT hosts.id FROM hosts
|
383
388
|
WHERE LOWER(hosts.name) REGEXP LOWER(?);
|
384
389
|
EOS
|
385
390
|
else
|
data/lib/hotdog/commands.rb
CHANGED
@@ -87,7 +87,11 @@ module Hotdog
|
|
87
87
|
fields << tag_name unless fields.index(tag_name)
|
88
88
|
end
|
89
89
|
[host_name] + fields.map { |tag_name|
|
90
|
-
|
90
|
+
if glob?(tag_name)
|
91
|
+
select_tag_values_from_hosts_tags_by_host_id_and_tag_name_glob(@db, host_id, tag_name)
|
92
|
+
else
|
93
|
+
select_tag_values_from_hosts_tags_by_host_id_and_tag_name(@db, host_id, tag_name)
|
94
|
+
end
|
91
95
|
}
|
92
96
|
}
|
93
97
|
fields = ["host"] + fields
|
@@ -100,7 +104,11 @@ module Hotdog
|
|
100
104
|
result = execute("SELECT name FROM hosts WHERE id IN (%s)" % hosts.map { "?" }.join(", "), hosts)
|
101
105
|
else
|
102
106
|
result = hosts.map { |host_id|
|
103
|
-
|
107
|
+
if glob?(tag_name)
|
108
|
+
[select_tag_values_from_hosts_tags_by_host_id_and_tag_name_glob(@db, host_id, tag_name)]
|
109
|
+
else
|
110
|
+
[select_tag_values_from_hosts_tags_by_host_id_and_tag_name(@db, host_id, tag_name)]
|
111
|
+
end
|
104
112
|
}
|
105
113
|
end
|
106
114
|
else
|
data/lib/hotdog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotdog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yamashita Yuu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|