chef-zero 1.2.1 → 1.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -26,12 +26,11 @@ module ChefZero
|
|
26
26
|
left.matches_doc?(doc)
|
27
27
|
when ':'
|
28
28
|
if left.respond_to?(:literal_string) && left.literal_string
|
29
|
-
|
30
|
-
right.matches_values?([value])
|
29
|
+
values = doc[left.literal_string]
|
31
30
|
else
|
32
31
|
values = doc.matching_values { |key| left.matches_values?([key]) }
|
33
|
-
right.matches_values?(values)
|
34
32
|
end
|
33
|
+
right.matches_values?(values)
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
@@ -14,8 +14,7 @@ module ChefZero
|
|
14
14
|
attr_reader :regexp
|
15
15
|
|
16
16
|
def matches_doc?(doc)
|
17
|
-
|
18
|
-
return value ? matches_values?([value]) : false
|
17
|
+
matches_values?(doc[DEFAULT_FIELD])
|
19
18
|
end
|
20
19
|
def matches_values?(values)
|
21
20
|
values.any? { |value| !@regexp.match(value).nil? }
|
@@ -9,31 +9,22 @@ module ChefZero
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def [](key)
|
12
|
-
|
13
|
-
values[0]
|
12
|
+
matching_values { |match_key| match_key == key }
|
14
13
|
end
|
15
14
|
|
16
15
|
def matching_values(&block)
|
17
|
-
result =
|
16
|
+
result = []
|
18
17
|
key_values(nil, @json) do |key, value|
|
19
18
|
if block.call(key)
|
20
|
-
|
21
|
-
result[key] << value.to_s
|
22
|
-
else
|
23
|
-
result[key] = value.to_s.clone
|
24
|
-
end
|
19
|
+
result << value.to_s
|
25
20
|
end
|
26
21
|
end
|
27
22
|
# Handle manufactured value(s)
|
28
23
|
if block.call('X_CHEF_id_CHEF_X')
|
29
|
-
|
30
|
-
result['X_CHEF_id_CHEF_X'] << @id.to_s
|
31
|
-
else
|
32
|
-
result['X_CHEF_id_CHEF_X'] = @id.to_s.clone
|
33
|
-
end
|
24
|
+
result << @id.to_s
|
34
25
|
end
|
35
26
|
|
36
|
-
result.
|
27
|
+
result.uniq
|
37
28
|
end
|
38
29
|
|
39
30
|
private
|
data/lib/chef_zero/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.3'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: puma
|
@@ -104,7 +104,6 @@ files:
|
|
104
104
|
- Rakefile
|
105
105
|
- lib/chef_zero/cookbook_data.rb
|
106
106
|
- lib/chef_zero/data_normalizer.rb
|
107
|
-
- lib/chef_zero/data_store/chef_fs_store.rb
|
108
107
|
- lib/chef_zero/data_store/data_already_exists_error.rb
|
109
108
|
- lib/chef_zero/data_store/data_error.rb
|
110
109
|
- lib/chef_zero/data_store/data_not_found_error.rb
|
@@ -1,96 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: John Keiser (<jkeiser@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef_fs/file_system'
|
20
|
-
require 'chef_fs/file_system/not_found_error'
|
21
|
-
require 'chef_zero/data_store/data_already_exists_error'
|
22
|
-
require 'chef_zero/data_store/data_not_found_error'
|
23
|
-
|
24
|
-
module ChefZero
|
25
|
-
module DataStore
|
26
|
-
class ChefFSStore
|
27
|
-
def initialize(chef_fs)
|
28
|
-
@chef_fs = chef_fs
|
29
|
-
end
|
30
|
-
|
31
|
-
def create_dir(path, name, *options)
|
32
|
-
parent = get_dir(path, options.include?(:create_dir))
|
33
|
-
parent.create_child(name, nil)
|
34
|
-
end
|
35
|
-
|
36
|
-
def create(path, name, data, *options)
|
37
|
-
if !data.is_a?(String)
|
38
|
-
raise "set only works with strings"
|
39
|
-
end
|
40
|
-
|
41
|
-
parent = get_dir(path, options.include?(:create_dir))
|
42
|
-
parent.create_child(name, data)
|
43
|
-
end
|
44
|
-
|
45
|
-
def get(path)
|
46
|
-
begin
|
47
|
-
ChefFS::FileSystem.resolve_path(path.join('/')).read
|
48
|
-
rescue ChefFS::FileSystem::NotFoundError => e
|
49
|
-
raise DataNotFoundError.new(path, e)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def set(path, data, *options)
|
54
|
-
if !data.is_a?(String)
|
55
|
-
raise "set only works with strings: #{path} = #{data.inspect}"
|
56
|
-
end
|
57
|
-
|
58
|
-
parent = get_dir(path[0..-2], options.include?(:create_dir))
|
59
|
-
parent.create_child(path[-1], data)
|
60
|
-
end
|
61
|
-
|
62
|
-
def delete(path)
|
63
|
-
begin
|
64
|
-
ChefFS::FileSystem.resolve_path(path.join('/')).delete
|
65
|
-
rescue ChefFS::FileSystem::NotFoundError => e
|
66
|
-
raise DataNotFoundError.new(path, e)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def list(path)
|
71
|
-
begin
|
72
|
-
ChefFS::FileSystem.resolve_path(path.join('/')).children.map { |c| c.name }.sort
|
73
|
-
rescue ChefFS::FileSystem::NotFoundError => e
|
74
|
-
raise DataNotFoundError.new(path, e)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def exists?(path)
|
79
|
-
ChefFS::FileSystem.resolve_path(path.join('/')).exists?
|
80
|
-
end
|
81
|
-
|
82
|
-
private
|
83
|
-
|
84
|
-
def get_dir(path, create=false)
|
85
|
-
result = Chef::FileSystem.resolve_path('/' + path.join('/'))
|
86
|
-
if result.exists?
|
87
|
-
result
|
88
|
-
elsif create
|
89
|
-
get_dir(path[0..-2], create).create_child(result.name, nil)
|
90
|
-
else
|
91
|
-
raise DataNotFoundError.new(path)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|