hotdog 0.1.16 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3112f9756593f481b584743e04f759c2917670e
4
- data.tar.gz: 3d2abf90e0a720fb8830fbe86320847efea4dee7
3
+ metadata.gz: 79e4334fc2d2f63537cbaa32bc44c2e5d069b4f5
4
+ data.tar.gz: bc9fdf8a14f3ab1a8ab02caa22e9841bfbff5181
5
5
  SHA512:
6
- metadata.gz: 886e645627302c4cf74486bd0729d0958eb411ccb164d66d71b0c099894a626639a0db68d2f0eb45d5a5460a3d293b8b7e4b80bc0a85cda12bf84a8eb3413766
7
- data.tar.gz: 0a9628e5691a05e7d3f2ab910da7f8f15af0ab84f4ad6dea16270e9cd4c9bc3abf9130b41431a5078963037b6dd3a0cc979d4a119d29751c259cfc61e655f66b
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
 
@@ -18,7 +18,7 @@ module Hotdog
18
18
  application: self,
19
19
  confdir: find_confdir(File.expand_path(".")),
20
20
  debug: false,
21
- expiry: 180,
21
+ expiry: 300,
22
22
  fixed_string: false,
23
23
  force: false,
24
24
  format: "plain",
@@ -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 hosts_tags.id FROM hosts
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 hosts_tags.id FROM hosts
387
+ SELECT hosts.id FROM hosts
383
388
  WHERE LOWER(hosts.name) REGEXP LOWER(?);
384
389
  EOS
385
390
  else
@@ -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
- select_tag_values_from_hosts_tags_by_host_id_and_tag_name(@db, host_id, tag_name)
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
- [select_tag_values_from_hosts_tags_by_host_id_and_tag_name_glob(@db, host_id, tag_name)]
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
@@ -1,3 +1,3 @@
1
1
  module Hotdog
2
- VERSION = "0.1.16"
2
+ VERSION = "0.1.17"
3
3
  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.1.16
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-07 00:00:00.000000000 Z
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler