Module: WinterRakeUtils

Defined in:
lib/winter_rakeutils.rb

Instance Method Summary collapse

Instance Method Details

#ensure_dir(d) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/winter_rakeutils.rb', line 13

def ensure_dir d
  unless File.exists? d
    mkdir_p d
    unless File.exists? d
      sleep 0.01
      ensure_dir d
    end
  end
end

#git_commit_push(msg = "auto") ⇒ Object



23
24
25
26
27
28
29
# File 'lib/winter_rakeutils.rb', line 23

def git_commit_push msg = "auto"
  sh "git add -A"
  unless git_working_dir_clean?
    sh "git commit -m #{msg}"
    sh "git push"
  end
end

#git_working_dir_clean?Boolean



4
5
6
7
8
9
10
11
# File 'lib/winter_rakeutils.rb', line 4

def git_working_dir_clean?
  `git status`.lines.each do |line|
    if line.index "Changes to be committed"
      return false
    end
  end
  return true
end

#within_dir(dir, &block) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/winter_rakeutils.rb', line 31

def within_dir dir, &block
  pwd = Dir.pwd
  Dir.chdir dir
  begin
    block.call
  ensure
    Dir.chdir pwd
  end
end