Class: FPM::Package::Docker

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

Defined Under Namespace

Classes: Node

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Docker

Returns a new instance of Docker.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fpm/package/docker.rb', line 8

def initialize( options = {} )
  super()
  if options[:logger]
    @logger = options[:logger]
  end
  if options[:client]
    @client = options[:client]
  end
  if @logger.nil?
    @logger = Cabin::Channel.get
  end
end

Instance Method Details

#input(name) ⇒ Object



21
22
23
# File 'lib/fpm/package/docker.rb', line 21

def input(name)
  split( name, '**' => staging_path)
end

#split(name, map) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fpm/package/docker.rb', line 25

def split( name, map )
  changes = changes(name)
  changes.remove_modified_leaves! do | kind, ml |
    if kind == DELETED
      @logger.warn("Found a deleted file. You can only create new files in a package",name: ml)
    else
      @logger.warn("Found a modified file. You can only create new files in a package",name: ml)
    end
  end
  fmap = {}
  changes.leaves.each do | change |
    map.each do | match, to |
      if File.fnmatch?(match, change)
        fmap[ change ] = File.join(to, change)
        break
      end
    end
  end
  directories = changes.smallest_superset
  directories.each do |chg|
    client.copy(name, chg, fmap ,chown: false)
  end
end