hotdog 0.1.18 → 0.2.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.
@@ -0,0 +1,63 @@
1
+ require "spec_helper"
2
+ require "hotdog/application"
3
+ require "hotdog/commands"
4
+ require "hotdog/commands/search"
5
+ require "parslet"
6
+
7
+ describe "tag regexp expression" do
8
+ let(:cmd) {
9
+ Hotdog::Commands::Search.new(Hotdog::Application.new)
10
+ }
11
+
12
+ it "interprets tag regexp with host" do
13
+ expr = Hotdog::Commands::Search::TagRegexpExpressionNode.new("host", "/foo/")
14
+ q = [
15
+ "SELECT hosts.id FROM hosts",
16
+ "WHERE hosts.name REGEXP ?;",
17
+ ]
18
+ allow(cmd).to receive(:execute).with(q.join(" "), ["foo"]) {
19
+ [[1], [2], [3]]
20
+ }
21
+ expect(expr.evaluate(cmd)).to eq([1, 2, 3])
22
+ end
23
+
24
+ it "interprets tag regexp with identifier and attribute" do
25
+ expr = Hotdog::Commands::Search::TagRegexpExpressionNode.new("/foo/", "/bar/")
26
+ q = [
27
+ "SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
28
+ "INNER JOIN tags ON hosts_tags.tag_id = tags.id",
29
+ "WHERE tags.name REGEXP ? AND tags.value REGEXP ?;",
30
+ ]
31
+ allow(cmd).to receive(:execute).with(q.join(" "), ["foo", "bar"]) {
32
+ [[1], [2], [3]]
33
+ }
34
+ expect(expr.evaluate(cmd)).to eq([1, 2, 3])
35
+ end
36
+
37
+ it "interprets tag regexp with identifier" do
38
+ expr = Hotdog::Commands::Search::TagRegexpExpressionNode.new("/foo/", nil)
39
+ q = [
40
+ "SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
41
+ "INNER JOIN hosts ON hosts_tags.host_id = hosts.id",
42
+ "INNER JOIN tags ON hosts_tags.tag_id = tags.id",
43
+ "WHERE hosts.name REGEXP ? OR tags.name REGEXP ? OR tags.value REGEXP ?;",
44
+ ]
45
+ allow(cmd).to receive(:execute).with(q.join(" "), ["foo", "foo", "foo"]) {
46
+ [[1], [2], [3]]
47
+ }
48
+ expect(expr.evaluate(cmd)).to eq([1, 2, 3])
49
+ end
50
+
51
+ it "interprets tag regexp with attribute" do
52
+ expr = Hotdog::Commands::Search::TagRegexpExpressionNode.new(nil, "/foo/")
53
+ q = [
54
+ "SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
55
+ "INNER JOIN tags ON hosts_tags.tag_id = tags.id",
56
+ "WHERE tags.value REGEXP ?;",
57
+ ]
58
+ allow(cmd).to receive(:execute).with(q.join(" "), ["foo"]) {
59
+ [[1], [2], [3]]
60
+ }
61
+ expect(expr.evaluate(cmd)).to eq([1, 2, 3])
62
+ end
63
+ end
@@ -0,0 +1 @@
1
+ require "rspec"
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.18
4
+ version: 0.2.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-08-28 00:00:00.000000000 Z
11
+ date: 2015-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.3.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.3.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: dogapi
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -103,6 +117,7 @@ extensions: []
103
117
  extra_rdoc_files: []
104
118
  files:
105
119
  - ".gitignore"
120
+ - ".travis.yml"
106
121
  - Gemfile
107
122
  - LICENSE.txt
108
123
  - README.md
@@ -129,6 +144,19 @@ files:
129
144
  - lib/hotdog/formatters/tsv.rb
130
145
  - lib/hotdog/formatters/yaml.rb
131
146
  - lib/hotdog/version.rb
147
+ - spec/core/application_spec.rb
148
+ - spec/formatter/csv_spec.rb
149
+ - spec/formatter/json_spec.rb
150
+ - spec/formatter/ltsv_spec.rb
151
+ - spec/formatter/plain_spec.rb
152
+ - spec/formatter/text_spec.rb
153
+ - spec/formatter/tsv_spec.rb
154
+ - spec/formatter/yaml_spec.rb
155
+ - spec/parser/parser_spec.rb
156
+ - spec/parser/tag_expression_spec.rb
157
+ - spec/parser/tag_glob_expression_spec.rb
158
+ - spec/parser/tag_regexp_expression_spec.rb
159
+ - spec/spec_helper.rb
132
160
  homepage: https://github.com/yyuu/hotdog
133
161
  licenses:
134
162
  - MIT
@@ -153,4 +181,17 @@ rubygems_version: 2.4.5
153
181
  signing_key:
154
182
  specification_version: 4
155
183
  summary: Yet another command-line tool for Datadog
156
- test_files: []
184
+ test_files:
185
+ - spec/core/application_spec.rb
186
+ - spec/formatter/csv_spec.rb
187
+ - spec/formatter/json_spec.rb
188
+ - spec/formatter/ltsv_spec.rb
189
+ - spec/formatter/plain_spec.rb
190
+ - spec/formatter/text_spec.rb
191
+ - spec/formatter/tsv_spec.rb
192
+ - spec/formatter/yaml_spec.rb
193
+ - spec/parser/parser_spec.rb
194
+ - spec/parser/tag_expression_spec.rb
195
+ - spec/parser/tag_glob_expression_spec.rb
196
+ - spec/parser/tag_regexp_expression_spec.rb
197
+ - spec/spec_helper.rb