Class: FPM::Package::Docker::Node Private

Inherits:
Struct
  • Object
show all
Defined in:
lib/fpm/package/docker.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Node.



105
106
107
# File 'lib/fpm/package/docker.rb', line 105

def initialize
  super(Hash.new{|hsh,key| hsh[key] = Node.new },nil)
end

Class Method Details

.read(enum) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



200
201
202
203
204
205
206
207
208
209
210
# File 'lib/fpm/package/docker.rb', line 200

def self.read(enum)
  fs = Node.new
  enum.each do |ch|
    n = fs
    ch['Path'].split('/').each do |part|
      n = n[part]
    end
    n.kind = ch['Kind']
  end
  return fs
end

Instance Method Details

#[](name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



109
110
111
# File 'lib/fpm/package/docker.rb', line 109

def [](name)
  children[name]
end

#contains_leaves?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


129
130
131
# File 'lib/fpm/package/docker.rb', line 129

def contains_leaves?
  children.any?{|_,c| c.leaf? }
end

#delete(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



191
192
193
194
195
196
197
198
# File 'lib/fpm/package/docker.rb', line 191

def delete(path)
  _, key, rest = path.split('/',3)
  if rest.nil?
    children.delete(key)
  else
    children[key].delete("/#{rest}")
  end
end

#leaf?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


113
114
115
# File 'lib/fpm/package/docker.rb', line 113

def leaf?
  children.none?
end

#leaves(prefix = '/', &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/fpm/package/docker.rb', line 117

def leaves(prefix = '/', &block)
  return to_enum(:leaves, prefix) unless block
  if leaf?
    yield prefix, false
  else
    children.each do |name, cld|
      cld.leaves( File.join(prefix,name), &block )
    end
  end
  return self
end

#modified_leaves(prefix = '/', &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/fpm/package/docker.rb', line 133

def modified_leaves(prefix = '/', &block)
  return to_enum(:modified_leaves, prefix) unless block
  if leaf?
    if kind != CREATED
      yield kind, prefix
    end
  else
    children.each do |name, cld|
      cld.modified_leaves( File.join(prefix,name), &block)
    end
  end
end

#reject!(prefix = '/', &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



179
180
181
182
183
184
185
186
187
188
189
# File 'lib/fpm/package/docker.rb', line 179

def reject!(prefix = '/', &block)
  children.reject! do |name, cld|
    p = File.join(prefix,name)
    if yield p
      true
    else
      cld.reject!(p,&block)
      false
    end
  end
end

#remove_modified_leaves!(changes_to_remove, prefix = '/', &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/fpm/package/docker.rb', line 146

def remove_modified_leaves!(changes_to_remove, prefix = '/', &block)
  to_remove = {}
  children.each do |name, cld|
    removed_children = cld.remove_modified_leaves!(changes_to_remove, File.join(prefix,name), &block)
    if cld.leaf? && changes_to_remove.include?(cld.kind)
      to_remove[name] = [cld.kind, removed_children]
    end
  end
  if to_remove.any?
    to_remove.each do |name, (kind, removed_children)|
      children.delete(name)
      if !removed_children
        yield kind, File.join(prefix,name)
      end
    end
    return true
  end
  return false
end

#smallest_superset(prefix = '/', &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/fpm/package/docker.rb', line 166

def smallest_superset(prefix = '/', &block)
  return to_enum(:smallest_superset, prefix) unless block
  if leaf?
    return
  elsif contains_leaves?
    yield prefix
  else
    children.each do |name, cld|
      cld.smallest_superset( File.join(prefix,name), &block)
    end
  end
end