Sha256: ee454ed1e4c7cefca8b09262ad2b9112579520d278d4237dc99076ff2151ec20

Contents?: true

Size: 837 Bytes

Versions: 12

Compression:

Stored size: 837 Bytes

Contents

module Picky

  module Backends

    module Helpers

      # Common file helpers.
      #
      module File

        # The backup directory of this file.
        # Equal to the file's dirname plus /backup
        #
        def backup_directory path
          ::File.join ::File.dirname(path), 'backup'
        end

        # Prepares the backup directory for the file.
        #
        def prepare_backup target
          FileUtils.mkdir target unless Dir.exists?(target)
        end

        # The backup filename.
        #
        def backup_file_path_of path
          dir, name = ::File.split path
          ::File.join dir, 'backup', name
        end

        # Extracts the size of the file in Bytes.
        #
        def size_of path
          `ls -l #{path} | awk '{print $5}'`.to_i
        end

      end

    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
picky-3.2.0 lib/picky/backends/helpers/file.rb
picky-3.1.13 lib/picky/backends/helpers/file.rb
picky-3.1.12 lib/picky/backends/helpers/file.rb
picky-3.1.11 lib/picky/backends/helpers/file.rb
picky-3.1.10 lib/picky/backends/helpers/file.rb
picky-3.1.9 lib/picky/backends/helpers/file.rb
picky-3.1.8 lib/picky/backends/helpers/file.rb
picky-3.1.7 lib/picky/backends/helpers/file.rb
picky-3.1.6 lib/picky/backends/helpers/file.rb
picky-3.1.5 lib/picky/backends/helpers/file.rb
picky-3.1.4 lib/picky/backends/helpers/file.rb
picky-3.1.3 lib/picky/backends/helpers/file.rb