class DotMe::Dsl
Public Class Methods
run( filename )
click to toggle source
# File lib/dotme/dsl.rb, line 6 def self.run( filename ) self.new.instance_eval( ::File.read(filename), filename ) end
Public Instance Methods
_backup( what, where )
click to toggle source
# File lib/dotme/dsl.rb, line 10 def _backup( what, where ) FileUtils.rm_rf where unless !::File.directory? where Dir.mkdir where, 0700 what.each do |file| from = ::File.join Etc.getpwuid.dir, file unless file[0] != '.' file = file[1..-1] end if File.exists? from puts "Backupping #{from} to #{where} ..." FileUtils.mv from, ::File.join( where, file ) end end end
_git_clone( repo, where )
click to toggle source
# File lib/dotme/dsl.rb, line 32 def _git_clone( repo, where ) system "git clone #{repo} \"#{where}\"" end
_link( what, where )
click to toggle source
# File lib/dotme/dsl.rb, line 26 def _link( what, where ) puts "Symlinking #{what} to #{where} ..." what = File.absolute_path what File.symlink what, where end
method_missing( name, *args )
click to toggle source
# File lib/dotme/dsl.rb, line 36 def method_missing( name, *args ) name = "_#{name}" if respond_to? name args.each_with_index do |arg,i| args[i] = arg.is_a?(String) ? arg.gsub( '~', Etc.getpwuid.dir ) : arg.map { |v| v.gsub( '~', Etc.getpwuid.dir ) } end send name.to_sym, *args end end
sh( cmd )
click to toggle source
# File lib/dotme/dsl.rb, line 46 def sh( cmd ) system cmd end