Module: Chewbacca
- Defined in:
- lib/chewbacca.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/chewbacca.rb', line 2 def Chewbacca.included(klass) load 'manifest.rb' klass.class_eval do namespace :chewbacca do desc "push changed files according to manifest.rb" task :push do push end desc "pull all files according to manifest.rb" task :pull do pull end end end end |
Instance Method Details
#pull ⇒ Object
47 48 49 50 51 52 |
# File 'lib/chewbacca.rb', line 47 def pull MANIFEST.each do |local,remote| puts "harmmff! downloading #{remote} to #{local}" system "scp #{USER}@#{HOST}:#{remote} #{local}" end end |
#push ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/chewbacca.rb', line 18 def push if File.exist?('.cash') times = Marshal.load(File.open('.cash').read) else times = {} end MANIFEST.each do |local,remote| if File.exist?(local) print "#{local} : " if times[local] if times[local] < File.open(local).mtime.to_i print "gwroar! uploading to #{remote}\n" system "scp #{local} #{USER}@#{HOST}:#{remote}" times[local] = File.open(local).mtime.to_i else print "arghffff! no changes\n" end else times[local] = File.open(local).mtime.to_i print "gwroar! uploading to #{remote}\n" system "scp #{local} #{USER}@#{HOST}:#{remote}" end end end File.open('.cash','w') do |f| f.puts Marshal.dump(times) end end |