hotdog 0.12.0 → 0.13.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 +27 -8
 - data/lib/hotdog/application.rb +7 -1
 - data/lib/hotdog/commands.rb +0 -2
 - data/lib/hotdog/commands/search.rb +16 -1239
 - data/lib/hotdog/commands/ssh.rb +7 -0
 - data/lib/hotdog/expression.rb +165 -0
 - data/lib/hotdog/expression/semantics.rb +1098 -0
 - data/lib/hotdog/expression/syntax.rb +176 -0
 - data/lib/hotdog/version.rb +1 -1
 - data/spec/parser/glob_expression_spec.rb +18 -18
 - data/spec/parser/parser_spec.rb +113 -77
 - data/spec/parser/regexp_expression_spec.rb +18 -18
 - data/spec/parser/string_expression_spec.rb +18 -18
 - metadata +5 -2
 
| 
         @@ -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:: 
     | 
| 
      
 13 
     | 
    
         
            +
                expr = Hotdog::Expression::RegexpHostNode.new("foo", ":")
         
     | 
| 
       14 
14 
     | 
    
         
             
                q = [
         
     | 
| 
       15 
15 
     | 
    
         
             
                  "SELECT hosts.id AS host_id FROM hosts",
         
     | 
| 
       16 
16 
     | 
    
         
             
                    "WHERE hosts.name REGEXP ?;",
         
     | 
| 
         @@ -19,11 +19,11 @@ describe "tag regexp expression" do 
     | 
|
| 
       19 
19 
     | 
    
         
             
                  [[1], [2], [3]]
         
     | 
| 
       20 
20 
     | 
    
         
             
                }
         
     | 
| 
       21 
21 
     | 
    
         
             
                expect(expr.evaluate(cmd)).to eq([1, 2, 3])
         
     | 
| 
       22 
     | 
    
         
            -
                expect(expr.dump).to eq({ 
     | 
| 
      
 22 
     | 
    
         
            +
                expect(expr.dump).to eq({tag_name_regexp: "host", separator: ":", tag_value_regexp: "foo"})
         
     | 
| 
       23 
23 
     | 
    
         
             
              end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
              it "interprets tag regexp with  
     | 
| 
       26 
     | 
    
         
            -
                expr = Hotdog:: 
     | 
| 
      
 25 
     | 
    
         
            +
              it "interprets tag regexp with tag_name and tag_value" do
         
     | 
| 
      
 26 
     | 
    
         
            +
                expr = Hotdog::Expression::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",
         
     | 
| 
         @@ -33,11 +33,11 @@ describe "tag regexp expression" do 
     | 
|
| 
       33 
33 
     | 
    
         
             
                  [[1], [2], [3]]
         
     | 
| 
       34 
34 
     | 
    
         
             
                }
         
     | 
| 
       35 
35 
     | 
    
         
             
                expect(expr.evaluate(cmd)).to eq([1, 2, 3])
         
     | 
| 
       36 
     | 
    
         
            -
                expect(expr.dump).to eq({ 
     | 
| 
      
 36 
     | 
    
         
            +
                expect(expr.dump).to eq({tag_name_regexp: "foo", separator: ":", tag_value_regexp: "bar"})
         
     | 
| 
       37 
37 
     | 
    
         
             
              end
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
              it "interprets tag regexp with  
     | 
| 
       40 
     | 
    
         
            -
                expr = Hotdog:: 
     | 
| 
      
 39 
     | 
    
         
            +
              it "interprets tag regexp with tag_name with separator" do
         
     | 
| 
      
 40 
     | 
    
         
            +
                expr = Hotdog::Expression::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",
         
     | 
| 
         @@ -47,11 +47,11 @@ describe "tag regexp expression" do 
     | 
|
| 
       47 
47 
     | 
    
         
             
                  [[1], [2], [3]]
         
     | 
| 
       48 
48 
     | 
    
         
             
                }
         
     | 
| 
       49 
49 
     | 
    
         
             
                expect(expr.evaluate(cmd)).to eq([1, 2, 3])
         
     | 
| 
       50 
     | 
    
         
            -
                expect(expr.dump).to eq({ 
     | 
| 
      
 50 
     | 
    
         
            +
                expect(expr.dump).to eq({tag_name_regexp: "foo", separator: ":"})
         
     | 
| 
       51 
51 
     | 
    
         
             
              end
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
              it "interprets tag regexp with  
     | 
| 
       54 
     | 
    
         
            -
                expr = Hotdog:: 
     | 
| 
      
 53 
     | 
    
         
            +
              it "interprets tag regexp with tag_name without separator" do
         
     | 
| 
      
 54 
     | 
    
         
            +
                expr = Hotdog::Expression::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",
         
     | 
| 
         @@ -62,11 +62,11 @@ describe "tag regexp expression" do 
     | 
|
| 
       62 
62 
     | 
    
         
             
                  [[1], [2], [3]]
         
     | 
| 
       63 
63 
     | 
    
         
             
                }
         
     | 
| 
       64 
64 
     | 
    
         
             
                expect(expr.evaluate(cmd)).to eq([1, 2, 3])
         
     | 
| 
       65 
     | 
    
         
            -
                expect(expr.dump).to eq({ 
     | 
| 
      
 65 
     | 
    
         
            +
                expect(expr.dump).to eq({tag_name_regexp: "foo"})
         
     | 
| 
       66 
66 
     | 
    
         
             
              end
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
       68 
     | 
    
         
            -
              it "interprets tag regexp with  
     | 
| 
       69 
     | 
    
         
            -
                expr = Hotdog:: 
     | 
| 
      
 68 
     | 
    
         
            +
              it "interprets tag regexp with tag_value with separator" do
         
     | 
| 
      
 69 
     | 
    
         
            +
                expr = Hotdog::Expression::RegexpTagValueNode.new("foo", ":")
         
     | 
| 
       70 
70 
     | 
    
         
             
                q = [
         
     | 
| 
       71 
71 
     | 
    
         
             
                  "SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
         
     | 
| 
       72 
72 
     | 
    
         
             
                    "INNER JOIN hosts ON hosts_tags.host_id = hosts.id",
         
     | 
| 
         @@ -77,11 +77,11 @@ describe "tag regexp expression" do 
     | 
|
| 
       77 
77 
     | 
    
         
             
                  [[1], [2], [3]]
         
     | 
| 
       78 
78 
     | 
    
         
             
                }
         
     | 
| 
       79 
79 
     | 
    
         
             
                expect(expr.evaluate(cmd)).to eq([1, 2, 3])
         
     | 
| 
       80 
     | 
    
         
            -
                expect(expr.dump).to eq({separator: ":",  
     | 
| 
      
 80 
     | 
    
         
            +
                expect(expr.dump).to eq({separator: ":", tag_value_regexp: "foo"})
         
     | 
| 
       81 
81 
     | 
    
         
             
              end
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
              it "interprets tag regexp with  
     | 
| 
       84 
     | 
    
         
            -
                expr = Hotdog:: 
     | 
| 
      
 83 
     | 
    
         
            +
              it "interprets tag regexp with tag_value without separator" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                expr = Hotdog::Expression::RegexpTagValueNode.new("foo", nil)
         
     | 
| 
       85 
85 
     | 
    
         
             
                q = [
         
     | 
| 
       86 
86 
     | 
    
         
             
                  "SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
         
     | 
| 
       87 
87 
     | 
    
         
             
                    "INNER JOIN hosts ON hosts_tags.host_id = hosts.id",
         
     | 
| 
         @@ -92,11 +92,11 @@ describe "tag regexp expression" do 
     | 
|
| 
       92 
92 
     | 
    
         
             
                  [[1], [2], [3]]
         
     | 
| 
       93 
93 
     | 
    
         
             
                }
         
     | 
| 
       94 
94 
     | 
    
         
             
                expect(expr.evaluate(cmd)).to eq([1, 2, 3])
         
     | 
| 
       95 
     | 
    
         
            -
                expect(expr.dump).to eq({ 
     | 
| 
      
 95 
     | 
    
         
            +
                expect(expr.dump).to eq({tag_value_regexp: "foo"})
         
     | 
| 
       96 
96 
     | 
    
         
             
              end
         
     | 
| 
       97 
97 
     | 
    
         | 
| 
       98 
98 
     | 
    
         
             
              it "empty tag regexp" do
         
     | 
| 
       99 
     | 
    
         
            -
                expr = Hotdog:: 
     | 
| 
      
 99 
     | 
    
         
            +
                expr = Hotdog::Expression::RegexpExpressionNode.new(nil, nil, nil)
         
     | 
| 
       100 
100 
     | 
    
         
             
                expect {
         
     | 
| 
       101 
101 
     | 
    
         
             
                  expr.evaluate(cmd)
         
     | 
| 
       102 
102 
     | 
    
         
             
                }.to raise_error(NotImplementedError)
         
     | 
| 
         @@ -10,7 +10,7 @@ describe "tag expression" do 
     | 
|
| 
       10 
10 
     | 
    
         
             
              }
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
              it "interprets tag with host" do
         
     | 
| 
       13 
     | 
    
         
            -
                expr = Hotdog:: 
     | 
| 
      
 13 
     | 
    
         
            +
                expr = Hotdog::Expression::StringHostNode.new("foo", ":")
         
     | 
| 
       14 
14 
     | 
    
         
             
                q = [
         
     | 
| 
       15 
15 
     | 
    
         
             
                  "SELECT hosts.id AS host_id FROM hosts",
         
     | 
| 
       16 
16 
     | 
    
         
             
                    "WHERE hosts.name = ?;",
         
     | 
| 
         @@ -19,11 +19,11 @@ describe "tag expression" do 
     | 
|
| 
       19 
19 
     | 
    
         
             
                  [[1], [2], [3]]
         
     | 
| 
       20 
20 
     | 
    
         
             
                }
         
     | 
| 
       21 
21 
     | 
    
         
             
                expect(expr.evaluate(cmd)).to eq([1, 2, 3])
         
     | 
| 
       22 
     | 
    
         
            -
                expect(expr.dump).to eq({ 
     | 
| 
      
 22 
     | 
    
         
            +
                expect(expr.dump).to eq({tag_name: "host", separator: ":", tag_value: "foo"})
         
     | 
| 
       23 
23 
     | 
    
         
             
              end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
              it "interprets tag with  
     | 
| 
       26 
     | 
    
         
            -
                expr = Hotdog:: 
     | 
| 
      
 25 
     | 
    
         
            +
              it "interprets tag with tag_name and tag_value" do
         
     | 
| 
      
 26 
     | 
    
         
            +
                expr = Hotdog::Expression::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",
         
     | 
| 
         @@ -33,11 +33,11 @@ describe "tag expression" do 
     | 
|
| 
       33 
33 
     | 
    
         
             
                  [[1], [2], [3]]
         
     | 
| 
       34 
34 
     | 
    
         
             
                }
         
     | 
| 
       35 
35 
     | 
    
         
             
                expect(expr.evaluate(cmd)).to eq([1, 2, 3])
         
     | 
| 
       36 
     | 
    
         
            -
                expect(expr.dump).to eq({ 
     | 
| 
      
 36 
     | 
    
         
            +
                expect(expr.dump).to eq({tag_name: "foo", separator: ":", tag_value: "bar"})
         
     | 
| 
       37 
37 
     | 
    
         
             
              end
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
              it "interprets tag with  
     | 
| 
       40 
     | 
    
         
            -
                expr = Hotdog:: 
     | 
| 
      
 39 
     | 
    
         
            +
              it "interprets tag with tag_name with separator" do
         
     | 
| 
      
 40 
     | 
    
         
            +
                expr = Hotdog::Expression::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",
         
     | 
| 
         @@ -47,11 +47,11 @@ describe "tag expression" do 
     | 
|
| 
       47 
47 
     | 
    
         
             
                  [[1], [2], [3]]
         
     | 
| 
       48 
48 
     | 
    
         
             
                }
         
     | 
| 
       49 
49 
     | 
    
         
             
                expect(expr.evaluate(cmd)).to eq([1, 2, 3])
         
     | 
| 
       50 
     | 
    
         
            -
                expect(expr.dump).to eq({ 
     | 
| 
      
 50 
     | 
    
         
            +
                expect(expr.dump).to eq({tag_name: "foo", separator: ":"})
         
     | 
| 
       51 
51 
     | 
    
         
             
              end
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
              it "interprets tag with  
     | 
| 
       54 
     | 
    
         
            -
                expr = Hotdog:: 
     | 
| 
      
 53 
     | 
    
         
            +
              it "interprets tag with tag_name without separator" do
         
     | 
| 
      
 54 
     | 
    
         
            +
                expr = Hotdog::Expression::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",
         
     | 
| 
         @@ -62,11 +62,11 @@ describe "tag expression" do 
     | 
|
| 
       62 
62 
     | 
    
         
             
                  [[1], [2], [3]]
         
     | 
| 
       63 
63 
     | 
    
         
             
                }
         
     | 
| 
       64 
64 
     | 
    
         
             
                expect(expr.evaluate(cmd)).to eq([1, 2, 3])
         
     | 
| 
       65 
     | 
    
         
            -
                expect(expr.dump).to eq({ 
     | 
| 
      
 65 
     | 
    
         
            +
                expect(expr.dump).to eq({tag_name: "foo"})
         
     | 
| 
       66 
66 
     | 
    
         
             
              end
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
       68 
     | 
    
         
            -
              it "interprets tag with  
     | 
| 
       69 
     | 
    
         
            -
                expr = Hotdog:: 
     | 
| 
      
 68 
     | 
    
         
            +
              it "interprets tag with tag_value with separator" do
         
     | 
| 
      
 69 
     | 
    
         
            +
                expr = Hotdog::Expression::StringTagValueNode.new("foo", ":")
         
     | 
| 
       70 
70 
     | 
    
         
             
                q = [
         
     | 
| 
       71 
71 
     | 
    
         
             
                  "SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
         
     | 
| 
       72 
72 
     | 
    
         
             
                    "INNER JOIN hosts ON hosts_tags.host_id = hosts.id",
         
     | 
| 
         @@ -77,11 +77,11 @@ describe "tag expression" do 
     | 
|
| 
       77 
77 
     | 
    
         
             
                  [[1], [2], [3]]
         
     | 
| 
       78 
78 
     | 
    
         
             
                }
         
     | 
| 
       79 
79 
     | 
    
         
             
                expect(expr.evaluate(cmd)).to eq([1, 2, 3])
         
     | 
| 
       80 
     | 
    
         
            -
                expect(expr.dump).to eq({separator: ":",  
     | 
| 
      
 80 
     | 
    
         
            +
                expect(expr.dump).to eq({separator: ":", tag_value: "foo"})
         
     | 
| 
       81 
81 
     | 
    
         
             
              end
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
              it "interprets tag with  
     | 
| 
       84 
     | 
    
         
            -
                expr = Hotdog:: 
     | 
| 
      
 83 
     | 
    
         
            +
              it "interprets tag with tag_value without separator" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                expr = Hotdog::Expression::StringTagValueNode.new("foo", nil)
         
     | 
| 
       85 
85 
     | 
    
         
             
                q = [
         
     | 
| 
       86 
86 
     | 
    
         
             
                  "SELECT DISTINCT hosts_tags.host_id FROM hosts_tags",
         
     | 
| 
       87 
87 
     | 
    
         
             
                    "INNER JOIN hosts ON hosts_tags.host_id = hosts.id",
         
     | 
| 
         @@ -92,11 +92,11 @@ describe "tag expression" do 
     | 
|
| 
       92 
92 
     | 
    
         
             
                  [[1], [2], [3]]
         
     | 
| 
       93 
93 
     | 
    
         
             
                }
         
     | 
| 
       94 
94 
     | 
    
         
             
                expect(expr.evaluate(cmd)).to eq([1, 2, 3])
         
     | 
| 
       95 
     | 
    
         
            -
                expect(expr.dump).to eq({ 
     | 
| 
      
 95 
     | 
    
         
            +
                expect(expr.dump).to eq({tag_value: "foo"})
         
     | 
| 
       96 
96 
     | 
    
         
             
              end
         
     | 
| 
       97 
97 
     | 
    
         | 
| 
       98 
98 
     | 
    
         
             
              it "empty tag" do
         
     | 
| 
       99 
     | 
    
         
            -
                expr = Hotdog:: 
     | 
| 
      
 99 
     | 
    
         
            +
                expr = Hotdog::Expression::StringExpressionNode.new(nil, nil, nil)
         
     | 
| 
       100 
100 
     | 
    
         
             
                expect {
         
     | 
| 
       101 
101 
     | 
    
         
             
                  expr.evaluate(cmd)
         
     | 
| 
       102 
102 
     | 
    
         
             
                }.to raise_error(NotImplementedError)
         
     | 
    
        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.13.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: 2016-09- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-09-26 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -182,6 +182,9 @@ files: 
     | 
|
| 
       182 
182 
     | 
    
         
             
            - lib/hotdog/commands/tags.rb
         
     | 
| 
       183 
183 
     | 
    
         
             
            - lib/hotdog/commands/up.rb
         
     | 
| 
       184 
184 
     | 
    
         
             
            - lib/hotdog/commands/version.rb
         
     | 
| 
      
 185 
     | 
    
         
            +
            - lib/hotdog/expression.rb
         
     | 
| 
      
 186 
     | 
    
         
            +
            - lib/hotdog/expression/semantics.rb
         
     | 
| 
      
 187 
     | 
    
         
            +
            - lib/hotdog/expression/syntax.rb
         
     | 
| 
       185 
188 
     | 
    
         
             
            - lib/hotdog/formatters.rb
         
     | 
| 
       186 
189 
     | 
    
         
             
            - lib/hotdog/formatters/csv.rb
         
     | 
| 
       187 
190 
     | 
    
         
             
            - lib/hotdog/formatters/json.rb
         
     |