Class: FPM::Fry::Plugin::EditStaging::AddFile Private

Inherits:
Struct
  • Object
show all
Defined in:
lib/fpm/fry/plugin/edit_staging.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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ioObject

Returns the value of attribute io

Returns:

  • (Object)

    the current value of io



12
13
14
# File 'lib/fpm/fry/plugin/edit_staging.rb', line 12

def io
  @io
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



12
13
14
# File 'lib/fpm/fry/plugin/edit_staging.rb', line 12

def options
  @options
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



12
13
14
# File 'lib/fpm/fry/plugin/edit_staging.rb', line 12

def path
  @path
end

Instance Method Details

#call(_, package) ⇒ 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.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fpm/fry/plugin/edit_staging.rb', line 13

def call(_ , package)
  file = package.staging_path(path)
  package.logger.debug("Writing file directly to staging", target: file, content: io.inspect)
  FileUtils.mkdir_p(File.dirname(file))
  File.open(file,'w') do | f |
    IO.copy_stream(io, f)
    if options[:chmod]
      f.chmod(options[:chmod])
    end
  end
  io.close if io.respond_to? :close
end