Sha256: c3abd8dfaac4a33f6c14defdb37c49af0b1cad452065ec06801e49968fcce199

Contents?: true

Size: 1.17 KB

Versions: 61

Compression:

Stored size: 1.17 KB

Contents

class Jets::Util
  class << self
    # Make sure that the result is a text.
    def normalize_result(result)
      JSON.dump(result)
    end

    def cp_r(src, dest)
      # Fix for https://github.com/tongueroo/jets/issues/122
      #
      # Using FileUtils.cp_r doesnt work if there are special files like socket files in the src dir.
      # Instead of using this hack https://bugs.ruby-lang.org/issues/10104
      # Using rsync to perform the copy.
      src.chop! if src.ends_with?('/')
      dest.chop! if dest.ends_with?('/')
      check_rsync_installed!
      sh "rsync -a --links --no-specials --no-devices #{src}/ #{dest}/", quiet: true
    end

    @@rsync_installed = false
    def check_rsync_installed!
      return if @@rsync_installed # only check once
      if system "type rsync > /dev/null 2>&1"
        @@rsync_installed = true
      else
        raise Jets::Error.new("Rsync is required. Rsync does not seem to be installed.")
      end
    end

    def sh(command, quiet: false)
      puts "=> #{command}" unless quiet
      system(command)
      success = $?.success?
      raise Jets::Error.new("Command failed: #{command}") unless success
      success
    end
  end
end

Version data entries

61 entries across 61 versions & 3 rubygems

Version Path
jets_bb_fork-0.0.4 lib/jets/util.rb
jets-2.0.4 lib/jets/util.rb
jets-2.0.3 lib/jets/util.rb
jets-2.0.1 lib/jets/util.rb
jets-2.0.0 lib/jets/util.rb
jets-1.9.32 lib/jets/util.rb
jets-1.9.31 lib/jets/util.rb
jets-1.9.30 lib/jets/util.rb
jets-1.9.29 lib/jets/util.rb
jets-1.9.28 lib/jets/util.rb
jets-1.9.27 lib/jets/util.rb
jets-1.9.26 lib/jets/util.rb
jets-1.9.25 lib/jets/util.rb
jets-1.9.24 lib/jets/util.rb
jets-1.9.23 lib/jets/util.rb
jets-1.9.22 lib/jets/util.rb
jets-1.9.21 lib/jets/util.rb
jets-1.9.20 lib/jets/util.rb
jets-1.9.19 lib/jets/util.rb
jets-1.9.18 lib/jets/util.rb