Module: WinterRakeUtils
- Extended by:
- FileUtils
- Defined in:
- lib/winter_rakeutils.rb
Class Method Summary collapse
- .ensure_dir(d) ⇒ Object
- .git_commit_push(msg = "auto") ⇒ Object
- .git_working_dir_clean? ⇒ Boolean
- .load_common_tasks ⇒ Object
- .load_gem_tasks ⇒ Object
- .load_git_tasks ⇒ Object
- .within_dir(dir, &block) ⇒ Object
Class Method Details
.ensure_dir(d) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/winter_rakeutils.rb', line 20 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
30 31 32 33 34 35 36 |
# File 'lib/winter_rakeutils.rb', line 30 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
11 12 13 14 15 16 17 18 |
# File 'lib/winter_rakeutils.rb', line 11 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 |
.load_common_tasks ⇒ Object
58 59 60 61 |
# File 'lib/winter_rakeutils.rb', line 58 def load_common_tasks spec = Gem::Specification.find_by_name 'winter_rakeutils' load "#{spec.gem_dir}/lib/winter_commontasks.rake" end |
.load_gem_tasks ⇒ Object
48 49 50 51 |
# File 'lib/winter_rakeutils.rb', line 48 def load_gem_tasks spec = Gem::Specification.find_by_name 'winter_rakeutils' load "#{spec.gem_dir}/lib/winter_gemtasks.rake" end |
.load_git_tasks ⇒ Object
53 54 55 56 |
# File 'lib/winter_rakeutils.rb', line 53 def load_git_tasks spec = Gem::Specification.find_by_name 'winter_rakeutils' load "#{spec.gem_dir}/lib/winter_gittasks.rake" end |
.within_dir(dir, &block) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/winter_rakeutils.rb', line 38 def within_dir dir, &block pwd = Dir.pwd Dir.chdir dir begin block.call ensure Dir.chdir pwd end end |