Sha256: 2dfa31ca2b9e73ac87cfcefb66e74fcc29d91df2bb150a09f7d816a5a684ad69
Contents?: true
Size: 1.17 KB
Versions: 4
Compression:
Stored size: 1.17 KB
Contents
module Resource class RemoteFile < Base block_attr :owner, :group, :mode, :source # Install a static local file into a remote server. def initialize target, &block set_base_defaults @pattern = 'cookbooks/*/files/default/' @target = target self.instance_eval(&block) end def content (Dir[@pattern + '*'] + Dir[@pattern + '*.*']).each do |file| return ::File.read(file) if file.include? @source end 'Resource was not found' end def run Execution.block 'Creating a remote file', @target, @owner do |b| if ::File.exist? @target sums_equal = MD5.hexdigest(::File.read(@target)) == MD5.hexdigest(content) else sums_equal = false @always_run = true end if sums_equal Output.warn 'Skipping', 'checksum comparison matches' else Output.warn 'Generating file with ruby', @target ::File.open(@target, 'w+') { |file| file.write content } b.always_run @always_run b.run "chown #{@owner}:#{@group} #{@target}" b.run "chmod #{unix_mode} #{@target}" end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
atesta-0.0.4 | lib/resource/remote_file.rb |
atesta-0.0.3 | lib/resource/remote_file.rb |
atesta-0.0.2 | lib/resource/remote_file.rb |
atesta-0.0.1 | lib/resource/remote_file.rb |