module Sumodev::Actions
Public Instance Methods
copy_dest_file(original, destination)
click to toggle source
# File lib/sumodev/actions.rb, line 2 def copy_dest_file original, destination from = File.expand_path(original, self.destination_root) to = File.expand_path(destination, self.destination_root) say_status :copy, relative_to_original_destination_root(to), true unless options[:pretend] FileUtils.cp from, to end end
git(commands = {})
click to toggle source
# File lib/sumodev/actions.rb, line 28 def git(commands = {}) if commands.respond_to?(:each) commands.each do |cmd, options| run "git #{cmd} #{options}" end else run "git #{commands}" end end
git_track(message, &block)
click to toggle source
# File lib/sumodev/actions.rb, line 38 def git_track(message, &block) block.call if block git :add => '.' git :commit => "-m \"#{message}\"" end
replace_in_file(file, replacements)
click to toggle source
# File lib/sumodev/actions.rb, line 13 def replace_in_file file, replacements return unless behavior == :invoke path = File.expand_path(file, self.destination_root) say_status :replace, relative_to_original_destination_root(path), true unless options[:pretend] content = File.binread(path) replacements.each do |match, replace| content.gsub!(match, replace.to_s) File.open(path, 'wb') {|f| f.write(content)} end end end