class Egads::Group
Public Class Methods
exit_on_failure?()
click to toggle source
Always exit on failure
# File lib/egads/group.rb, line 8 def self.exit_on_failure? true end
Protected Instance Methods
run_hooks_for(cmd, hook)
click to toggle source
Run command hooks from config file E.g. run_hooks_for
(:build, :after)
# File lib/egads/group.rb, line 37 def run_hooks_for(cmd, hook) say_status :hooks, "Running #{cmd} #{hook} hooks" Config.hooks_for(cmd, hook).each do |command| run_with_code(command, stream: true) end end
run_with_code(command, options={})
click to toggle source
# File lib/egads/group.rb, line 13 def run_with_code(command, options={}) say_status :run, "#{command}", options.fetch(:verbose, true) capture = [] duration = Benchmark.realtime do Open3.popen2e(command) do |_, out, thread| out.each do |line| puts line if options[:stream] capture << line end unless thread.value == 0 raise CommandError.new("`#{command}` failed with exit status #{thread.value.exitstatus.inspect}") end end end say_status :done, "Finished in %.1f seconds" % duration, options.fetch(:verbose, true) capture.join end
symlink(src, dest)
click to toggle source
# File lib/egads/group.rb, line 53 def symlink(src, dest) raise ArgumentError.new("#{src} is not a file") unless File.file?(src) say_status :symlink, "from #{src} to #{dest}" FileUtils.ln_sf(src, dest) end
symlink_directory(src, dest)
click to toggle source
Symlinks a directory (not atomically) NB that `ln -f` doesn't work with directories.
# File lib/egads/group.rb, line 46 def symlink_directory(src, dest) raise ArgumentError.new("#{src} is not a directory") unless File.directory?(src) say_status :symlink, "from #{src} to #{dest}" FileUtils.rm_rf(dest) File.symlink(src, dest) end