hotdog 0.4.1 → 0.5.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/README.md +4 -0
- data/lib/hotdog/application.rb +21 -15
- data/lib/hotdog/commands/down.rb +10 -8
- data/lib/hotdog/commands/hosts.rb +0 -1
- data/lib/hotdog/commands/pssh.rb +27 -24
- data/lib/hotdog/commands/search.rb +640 -262
- data/lib/hotdog/commands/ssh.rb +30 -20
- data/lib/hotdog/commands/tags.rb +0 -1
- data/lib/hotdog/commands/up.rb +0 -1
- data/lib/hotdog/commands.rb +66 -22
- data/lib/hotdog/version.rb +1 -1
- data/spec/parser/parser_spec.rb +3 -3
- data/spec/parser/tag_expression_spec.rb +10 -8
- data/spec/parser/tag_glob_expression_spec.rb +10 -8
- data/spec/parser/tag_regexp_expression_spec.rb +10 -8
- metadata +3 -2
data/lib/hotdog/commands/ssh.rb
CHANGED
@@ -8,38 +8,45 @@ require "shellwords"
|
|
8
8
|
module Hotdog
|
9
9
|
module Commands
|
10
10
|
class Ssh < Search
|
11
|
-
def
|
12
|
-
|
11
|
+
def define_options(optparse)
|
12
|
+
@ssh_options = @options.merge({
|
13
13
|
index: nil,
|
14
14
|
options: [],
|
15
15
|
user: nil,
|
16
16
|
port: nil,
|
17
17
|
identity_file: nil,
|
18
18
|
forward_agent: false,
|
19
|
-
|
19
|
+
verbose: false,
|
20
|
+
})
|
20
21
|
|
21
22
|
optparse.on("-n", "--index INDEX", "Use this index of host if multiple servers are found", Integer) do |index|
|
22
|
-
|
23
|
+
@ssh_options[:index] = index
|
23
24
|
end
|
24
25
|
optparse.on("-o SSH_OPTION", "Passes this string to ssh command through shell. This option may be given multiple times") do |option|
|
25
|
-
|
26
|
+
@ssh_options[:options] += [option]
|
26
27
|
end
|
27
28
|
optparse.on("-i SSH_IDENTITY_FILE", "SSH identity file path") do |path|
|
28
|
-
|
29
|
+
@ssh_options[:identity_file] = path
|
29
30
|
end
|
30
31
|
optparse.on("-A", "Enable agent forwarding", TrueClass) do |b|
|
31
|
-
|
32
|
+
@ssh_options[:forward_agent] = b
|
32
33
|
end
|
33
34
|
optparse.on("-p PORT", "Port of the remote host", Integer) do |port|
|
34
|
-
|
35
|
+
@ssh_options[:port] = port
|
35
36
|
end
|
36
37
|
optparse.on("-u SSH_USER", "SSH login user name") do |user|
|
37
|
-
|
38
|
+
@ssh_options[:user] = user
|
39
|
+
end
|
40
|
+
optparse.on("-v", "--verbose", "Enable verbose ode") do |v|
|
41
|
+
@ssh_options[:verbose] = v
|
38
42
|
end
|
43
|
+
end
|
39
44
|
|
40
|
-
|
41
|
-
|
42
|
-
|
45
|
+
def parse_options(optparse, args=[])
|
46
|
+
end
|
47
|
+
|
48
|
+
def run(args=[])
|
49
|
+
expression = args.join(" ").strip
|
43
50
|
if expression.empty?
|
44
51
|
exit(1)
|
45
52
|
end
|
@@ -59,8 +66,8 @@ module Hotdog
|
|
59
66
|
STDERR.puts("no match found: #{search_args.join(" ")}")
|
60
67
|
exit(1)
|
61
68
|
else
|
62
|
-
if
|
63
|
-
host = result[
|
69
|
+
if @ssh_options[:index] && result.length > @ssh_options[:index]
|
70
|
+
host = result[@ssh_options[:index]]
|
64
71
|
else
|
65
72
|
result, fields = get_hosts_with_search_tags(result, node)
|
66
73
|
|
@@ -79,26 +86,29 @@ module Hotdog
|
|
79
86
|
|
80
87
|
# build ssh command
|
81
88
|
cmdline = ["ssh"]
|
82
|
-
|
89
|
+
@ssh_options[:options].each do |option|
|
83
90
|
cmdline << "-o" << option
|
84
91
|
end
|
85
|
-
if path =
|
92
|
+
if path = @ssh_options[:identity_file]
|
86
93
|
cmdline << "-i" << Shellwords.escape(path)
|
87
94
|
end
|
88
|
-
if port =
|
95
|
+
if port = @ssh_options[:port]
|
89
96
|
cmdline << "-p" << port.to_s
|
90
97
|
end
|
91
|
-
if
|
98
|
+
if @ssh_options[:forward_agent]
|
92
99
|
cmdline << "-A"
|
93
100
|
end
|
94
|
-
if
|
101
|
+
if @ssh_options[:verbose]
|
102
|
+
cmdline << "-v"
|
103
|
+
end
|
104
|
+
if user = @ssh_options[:user]
|
95
105
|
cmdline << (user + "@" + address)
|
96
106
|
else
|
97
107
|
cmdline << address
|
98
108
|
end
|
99
109
|
cmdline.concat(args)
|
100
110
|
|
101
|
-
exec
|
111
|
+
exec(*cmdline)
|
102
112
|
exit(127)
|
103
113
|
end
|
104
114
|
end
|
data/lib/hotdog/commands/tags.rb
CHANGED
data/lib/hotdog/commands/up.rb
CHANGED
data/lib/hotdog/commands.rb
CHANGED
@@ -29,14 +29,15 @@ module Hotdog
|
|
29
29
|
raise(NotImplementedError)
|
30
30
|
end
|
31
31
|
|
32
|
-
def execute(
|
32
|
+
def execute(q, args=[])
|
33
33
|
update_db
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
begin
|
35
|
+
logger.debug("execute: #{q} -- #{args.inspect}")
|
36
|
+
prepare(@db, q).execute(args)
|
37
|
+
rescue
|
38
|
+
logger.error("failed: #{q} -- #{args.inspect}")
|
39
|
+
raise
|
37
40
|
end
|
38
|
-
logger.debug(q)
|
39
|
-
prepare(@db, query).execute(args)
|
40
41
|
end
|
41
42
|
|
42
43
|
def fixed_string?()
|
@@ -51,6 +52,14 @@ module Hotdog
|
|
51
52
|
update_db(options)
|
52
53
|
end
|
53
54
|
|
55
|
+
def define_options(optparse)
|
56
|
+
# nop
|
57
|
+
end
|
58
|
+
|
59
|
+
def parse_options(optparse, args=[])
|
60
|
+
optparse.parse(args)
|
61
|
+
end
|
62
|
+
|
54
63
|
private
|
55
64
|
def prepare(db, query)
|
56
65
|
k = (db.hash & MASK_DATABASE) | (query.hash & MASK_QUERY)
|
@@ -61,10 +70,6 @@ module Hotdog
|
|
61
70
|
@options[:formatter].format(result, @options.merge(options))
|
62
71
|
end
|
63
72
|
|
64
|
-
def optparse()
|
65
|
-
@application.optparse
|
66
|
-
end
|
67
|
-
|
68
73
|
def glob?(s)
|
69
74
|
s.index('*') or s.index('?') or s.index('[') or s.index(']')
|
70
75
|
end
|
@@ -166,7 +171,7 @@ module Hotdog
|
|
166
171
|
FileUtils.mkdir_p(options[:confdir])
|
167
172
|
persistent = File.join(options[:confdir], PERSISTENT_DB)
|
168
173
|
|
169
|
-
if not options[:force] and File.exist?(persistent) and Time.new < File.mtime(persistent) + options[:expiry]
|
174
|
+
if (not options[:force] and File.exist?(persistent) and Time.new < File.mtime(persistent) + options[:expiry]) or options[:offline]
|
170
175
|
begin
|
171
176
|
persistent_db = SQLite3::Database.new(persistent)
|
172
177
|
persistent_db.execute("SELECT id, name FROM hosts LIMIT 1")
|
@@ -175,7 +180,11 @@ module Hotdog
|
|
175
180
|
@db = persistent_db
|
176
181
|
return
|
177
182
|
rescue SQLite3::SQLException
|
178
|
-
|
183
|
+
if options[:offline]
|
184
|
+
raise(RuntimeError.new("no database available on offline mode"))
|
185
|
+
else
|
186
|
+
persistent_db.close()
|
187
|
+
end
|
179
188
|
end
|
180
189
|
end
|
181
190
|
|
@@ -192,21 +201,38 @@ module Hotdog
|
|
192
201
|
memory_db.transaction do
|
193
202
|
known_tags = all_tags.keys.map { |tag| split_tag(tag) }.uniq
|
194
203
|
known_tags.each_slice(SQLITE_LIMIT_COMPOUND_SELECT / 2) do |known_tags|
|
195
|
-
|
204
|
+
q = "INSERT OR IGNORE INTO tags (name, value) VALUES %s" % known_tags.map { "(?, ?)" }.join(", ")
|
205
|
+
begin
|
206
|
+
prepare(memory_db, q).execute(known_tags)
|
207
|
+
rescue
|
208
|
+
logger.error("failed: #{q} -- #{known_tags.inspect}")
|
209
|
+
raise
|
210
|
+
end
|
196
211
|
end
|
197
212
|
|
198
213
|
known_hosts = all_tags.values.reduce(:+).uniq
|
199
214
|
known_hosts.each_slice(SQLITE_LIMIT_COMPOUND_SELECT) do |known_hosts|
|
200
|
-
|
215
|
+
q = "INSERT OR IGNORE INTO hosts (name) VALUES %s" % known_hosts.map { "(?)" }.join(", ")
|
216
|
+
begin
|
217
|
+
prepare(memory_db, q).execute(known_hosts)
|
218
|
+
rescue
|
219
|
+
logger.error("failed: #{q} -- #{known_hosts.inspect}")
|
220
|
+
raise
|
221
|
+
end
|
201
222
|
end
|
202
223
|
|
203
224
|
all_tags.each do |tag, hosts|
|
204
|
-
q = "INSERT OR REPLACE INTO hosts_tags (host_id, tag_id) " \
|
205
|
-
"SELECT host.id, tag.id FROM " \
|
206
|
-
"( SELECT id FROM hosts WHERE name IN (%s) ) AS host, " \
|
207
|
-
"( SELECT id FROM tags WHERE name = ? AND value = ? LIMIT 1 ) AS tag;"
|
208
225
|
hosts.each_slice(SQLITE_LIMIT_COMPOUND_SELECT - 2) do |hosts|
|
209
|
-
|
226
|
+
q = "INSERT OR REPLACE INTO hosts_tags (host_id, tag_id) " \
|
227
|
+
"SELECT host.id, tag.id FROM " \
|
228
|
+
"( SELECT id FROM hosts WHERE name IN (%s) ) AS host, " \
|
229
|
+
"( SELECT id FROM tags WHERE name = ? AND value = ? LIMIT 1 ) AS tag;" % hosts.map { "?" }.join(", ")
|
230
|
+
begin
|
231
|
+
prepare(memory_db, q).execute(hosts + split_tag(tag))
|
232
|
+
rescue
|
233
|
+
logger.error("failed: #{q} -- #{(hosts + split_tag(tag)).inspect}")
|
234
|
+
raise
|
235
|
+
end
|
210
236
|
end
|
211
237
|
end
|
212
238
|
end
|
@@ -269,17 +295,35 @@ module Hotdog
|
|
269
295
|
|
270
296
|
hosts = prepare(src, "SELECT id, name FROM hosts").execute().to_a
|
271
297
|
hosts.each_slice(SQLITE_LIMIT_COMPOUND_SELECT / 2) do |hosts|
|
272
|
-
|
298
|
+
q = "INSERT INTO hosts (id, name) VALUES %s" % hosts.map { "(?, ?)" }.join(", ")
|
299
|
+
begin
|
300
|
+
prepare(dst, q).execute(hosts)
|
301
|
+
rescue
|
302
|
+
logger.error("failed: #{q} -- #{hosts.inspect}")
|
303
|
+
raise
|
304
|
+
end
|
273
305
|
end
|
274
306
|
|
275
307
|
tags = prepare(src, "SELECT id, name, value FROM tags").execute().to_a
|
276
308
|
tags.each_slice(SQLITE_LIMIT_COMPOUND_SELECT / 3) do |tags|
|
277
|
-
|
309
|
+
q = "INSERT INTO tags (id, name, value) VALUES %s" % tags.map { "(?, ?, ?)" }.join(", ")
|
310
|
+
begin
|
311
|
+
prepare(dst, q).execute(tags)
|
312
|
+
rescue
|
313
|
+
logger.error("failed: #{q} -- #{tags.inspect}")
|
314
|
+
raise
|
315
|
+
end
|
278
316
|
end
|
279
317
|
|
280
318
|
hosts_tags = prepare(src, "SELECT host_id, tag_id FROM hosts_tags").to_a
|
281
319
|
hosts_tags.each_slice(SQLITE_LIMIT_COMPOUND_SELECT / 2) do |hosts_tags|
|
282
|
-
|
320
|
+
q = "INSERT INTO hosts_tags (host_id, tag_id) VALUES %s" % hosts_tags.map { "(?, ?)" }.join(", ")
|
321
|
+
begin
|
322
|
+
prepare(dst, q).execute(hosts_tags)
|
323
|
+
rescue
|
324
|
+
logger.error("failed: #{q} -- #{hosts_tags.inspect}")
|
325
|
+
raise
|
326
|
+
end
|
283
327
|
end
|
284
328
|
|
285
329
|
create_index_hosts(dst)
|
data/lib/hotdog/version.rb
CHANGED
data/spec/parser/parser_spec.rb
CHANGED
@@ -23,7 +23,7 @@ describe "parser" do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "parses ':/foo/'" do
|
26
|
-
expect(cmd.parse(":/foo/")).to eq({separator: ":", attribute_regexp: "
|
26
|
+
expect(cmd.parse(":/foo/")).to eq({separator: ":", attribute_regexp: "foo"})
|
27
27
|
end
|
28
28
|
|
29
29
|
it "parses 'foo'" do
|
@@ -63,11 +63,11 @@ describe "parser" do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "parses '/foo/'" do
|
66
|
-
expect(cmd.parse("/foo/")).to eq({identifier_regexp: "
|
66
|
+
expect(cmd.parse("/foo/")).to eq({identifier_regexp: "foo"})
|
67
67
|
end
|
68
68
|
|
69
69
|
it "parses '/foo/:/bar/'" do
|
70
|
-
expect(cmd.parse("/foo/:/bar/")).to eq({identifier_regexp: "
|
70
|
+
expect(cmd.parse("/foo/:/bar/")).to eq({identifier_regexp: "foo", separator: ":", attribute_regexp: "bar"})
|
71
71
|
end
|
72
72
|
|
73
73
|
it "parses '(foo)'" do
|
@@ -10,7 +10,7 @@ describe "tag expression" do
|
|
10
10
|
}
|
11
11
|
|
12
12
|
it "interprets tag with host" do
|
13
|
-
expr = Hotdog::Commands::Search::
|
13
|
+
expr = Hotdog::Commands::Search::StringHostNode.new("foo", ":")
|
14
14
|
q = [
|
15
15
|
"SELECT hosts.id AS host_id FROM hosts",
|
16
16
|
"WHERE hosts.name = ?;",
|
@@ -23,7 +23,7 @@ describe "tag expression" do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "interprets tag with identifier and attribute" do
|
26
|
-
expr = Hotdog::Commands::Search::
|
26
|
+
expr = Hotdog::Commands::Search::StringTagNode.new("foo", "bar", ":")
|
27
27
|
q = [
|
28
28
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
29
29
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
@@ -37,7 +37,7 @@ describe "tag expression" do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it "interprets tag with identifier with separator" do
|
40
|
-
expr = Hotdog::Commands::Search::
|
40
|
+
expr = Hotdog::Commands::Search::StringTagNameNode.new("foo", ":")
|
41
41
|
q = [
|
42
42
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
43
43
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
@@ -51,7 +51,7 @@ describe "tag expression" do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "interprets tag with identifier without separator" do
|
54
|
-
expr = Hotdog::Commands::Search::
|
54
|
+
expr = Hotdog::Commands::Search::StringNode.new("foo", nil)
|
55
55
|
q = [
|
56
56
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
57
57
|
"INNER JOIN hosts ON hosts_tags.host_id = hosts.id",
|
@@ -66,7 +66,7 @@ describe "tag expression" do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "interprets tag with attribute with separator" do
|
69
|
-
expr = Hotdog::Commands::Search::
|
69
|
+
expr = Hotdog::Commands::Search::StringTagValueNode.new("foo", ":")
|
70
70
|
q = [
|
71
71
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
72
72
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
@@ -80,7 +80,7 @@ describe "tag expression" do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it "interprets tag with attribute without separator" do
|
83
|
-
expr = Hotdog::Commands::Search::
|
83
|
+
expr = Hotdog::Commands::Search::StringTagValueNode.new("foo", nil)
|
84
84
|
q = [
|
85
85
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
86
86
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
@@ -94,8 +94,10 @@ describe "tag expression" do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it "empty tag" do
|
97
|
-
expr = Hotdog::Commands::Search::
|
98
|
-
expect
|
97
|
+
expr = Hotdog::Commands::Search::StringExpressionNode.new(nil, nil, nil)
|
98
|
+
expect {
|
99
|
+
expr.evaluate(cmd)
|
100
|
+
}.to raise_error(NotImplementedError)
|
99
101
|
expect(expr.dump).to eq({})
|
100
102
|
end
|
101
103
|
end
|
@@ -10,7 +10,7 @@ describe "tag glob expression" do
|
|
10
10
|
}
|
11
11
|
|
12
12
|
it "interprets tag glob with host" do
|
13
|
-
expr = Hotdog::Commands::Search::
|
13
|
+
expr = Hotdog::Commands::Search::GlobHostNode.new("foo*", ":")
|
14
14
|
q = [
|
15
15
|
"SELECT hosts.id AS host_id FROM hosts",
|
16
16
|
"WHERE LOWER(hosts.name) GLOB LOWER(?);",
|
@@ -23,7 +23,7 @@ describe "tag glob expression" do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "interprets tag glob with identifier and attribute" do
|
26
|
-
expr = Hotdog::Commands::Search::
|
26
|
+
expr = Hotdog::Commands::Search::GlobTagNode.new("foo*", "bar*", ":")
|
27
27
|
q = [
|
28
28
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
29
29
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
@@ -37,7 +37,7 @@ describe "tag glob expression" do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it "interprets tag glob with identifier with separator" do
|
40
|
-
expr = Hotdog::Commands::Search::
|
40
|
+
expr = Hotdog::Commands::Search::GlobTagNameNode.new("foo*", ":")
|
41
41
|
q = [
|
42
42
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
43
43
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
@@ -51,7 +51,7 @@ describe "tag glob expression" do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "interprets tag glob with identifier without separator" do
|
54
|
-
expr = Hotdog::Commands::Search::
|
54
|
+
expr = Hotdog::Commands::Search::GlobNode.new("foo*", nil)
|
55
55
|
q = [
|
56
56
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
57
57
|
"INNER JOIN hosts ON hosts_tags.host_id = hosts.id",
|
@@ -66,7 +66,7 @@ describe "tag glob expression" do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "interprets tag glob with attribute with separator" do
|
69
|
-
expr = Hotdog::Commands::Search::
|
69
|
+
expr = Hotdog::Commands::Search::GlobTagValueNode.new("foo*", ":")
|
70
70
|
q = [
|
71
71
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
72
72
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
@@ -80,7 +80,7 @@ describe "tag glob expression" do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it "interprets tag glob with attribute without separator" do
|
83
|
-
expr = Hotdog::Commands::Search::
|
83
|
+
expr = Hotdog::Commands::Search::GlobTagValueNode.new("foo*", nil)
|
84
84
|
q = [
|
85
85
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
86
86
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
@@ -94,8 +94,10 @@ describe "tag glob expression" do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it "empty tag glob" do
|
97
|
-
expr = Hotdog::Commands::Search::
|
98
|
-
expect
|
97
|
+
expr = Hotdog::Commands::Search::GlobExpressionNode.new(nil, nil, nil)
|
98
|
+
expect {
|
99
|
+
expr.evaluate(cmd)
|
100
|
+
}.to raise_error(NotImplementedError)
|
99
101
|
expect(expr.dump).to eq({})
|
100
102
|
end
|
101
103
|
end
|
@@ -10,7 +10,7 @@ describe "tag regexp expression" do
|
|
10
10
|
}
|
11
11
|
|
12
12
|
it "interprets tag regexp with host" do
|
13
|
-
expr = Hotdog::Commands::Search::
|
13
|
+
expr = Hotdog::Commands::Search::RegexpHostNode.new("foo", ":")
|
14
14
|
q = [
|
15
15
|
"SELECT hosts.id AS host_id FROM hosts",
|
16
16
|
"WHERE hosts.name REGEXP ?;",
|
@@ -23,7 +23,7 @@ describe "tag regexp expression" do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "interprets tag regexp with identifier and attribute" do
|
26
|
-
expr = Hotdog::Commands::Search::
|
26
|
+
expr = Hotdog::Commands::Search::RegexpTagNode.new("foo", "bar", ":")
|
27
27
|
q = [
|
28
28
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
29
29
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
@@ -37,7 +37,7 @@ describe "tag regexp expression" do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it "interprets tag regexp with identifier with separator" do
|
40
|
-
expr = Hotdog::Commands::Search::
|
40
|
+
expr = Hotdog::Commands::Search::RegexpTagNameNode.new("foo", ":")
|
41
41
|
q = [
|
42
42
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
43
43
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
@@ -51,7 +51,7 @@ describe "tag regexp expression" do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "interprets tag regexp with identifier without separator" do
|
54
|
-
expr = Hotdog::Commands::Search::
|
54
|
+
expr = Hotdog::Commands::Search::RegexpNode.new("foo", nil)
|
55
55
|
q = [
|
56
56
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
57
57
|
"INNER JOIN hosts ON hosts_tags.host_id = hosts.id",
|
@@ -66,7 +66,7 @@ describe "tag regexp expression" do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "interprets tag regexp with attribute with separator" do
|
69
|
-
expr = Hotdog::Commands::Search::
|
69
|
+
expr = Hotdog::Commands::Search::RegexpTagValueNode.new("foo", ":")
|
70
70
|
q = [
|
71
71
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
72
72
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
@@ -80,7 +80,7 @@ describe "tag regexp expression" do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it "interprets tag regexp with attribute without separator" do
|
83
|
-
expr = Hotdog::Commands::Search::
|
83
|
+
expr = Hotdog::Commands::Search::RegexpTagValueNode.new("foo", nil)
|
84
84
|
q = [
|
85
85
|
"SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
|
86
86
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
@@ -94,8 +94,10 @@ describe "tag regexp expression" do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it "empty tag regexp" do
|
97
|
-
expr = Hotdog::Commands::Search::
|
98
|
-
expect
|
97
|
+
expr = Hotdog::Commands::Search::RegexpExpressionNode.new(nil, nil, nil)
|
98
|
+
expect {
|
99
|
+
expr.evaluate(cmd)
|
100
|
+
}.to raise_error(NotImplementedError)
|
99
101
|
expect(expr.dump).to eq({})
|
100
102
|
end
|
101
103
|
end
|
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.
|
4
|
+
version: 0.5.0
|
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-09-
|
11
|
+
date: 2015-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -197,3 +197,4 @@ test_files:
|
|
197
197
|
- spec/parser/tag_glob_expression_spec.rb
|
198
198
|
- spec/parser/tag_regexp_expression_spec.rb
|
199
199
|
- spec/spec_helper.rb
|
200
|
+
has_rdoc:
|