Class: Jets::Util
- Inherits:
-
Object
- Object
- Jets::Util
- Defined in:
- lib/jets/util.rb
Constant Summary collapse
- @@rsync_installed =
false
Class Method Summary collapse
- .check_rsync_installed! ⇒ Object
- .cp_r(src, dest) ⇒ Object
-
.normalize_result(result) ⇒ Object
Make sure that the result is a text.
- .sh(command, quiet: false) ⇒ Object
Class Method Details
.check_rsync_installed! ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/jets/util.rb', line 21 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 |
.cp_r(src, dest) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/jets/util.rb', line 8 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 |
.normalize_result(result) ⇒ Object
Make sure that the result is a text.
4 5 6 |
# File 'lib/jets/util.rb', line 4 def normalize_result(result) JSON.dump(result) end |