Class: Overapp::TmpDir
Class Method Summary collapse
- .base_dir ⇒ Object
- .local_repo_map ⇒ Object
- .to_local_repo_path(url) ⇒ Object
- .with(ops = {}) ⇒ Object
- .with_repo_path(url) ⇒ Object
- .with_repo_path_localuse(url) ⇒ Object
Class Method Details
.base_dir ⇒ Object
4 5 6 |
# File 'lib/overapp/util/tmp_dir.rb', line 4 def base_dir File.(File.dirname(__FILE__) + "/../../../tmp") end |
.local_repo_map ⇒ Object
23 24 25 26 27 28 |
# File 'lib/overapp/util/tmp_dir.rb', line 23 def local_repo_map res = {} res["https://github.com/mharris717/ember_auth_rails_overlay.git"] = "ember_auth_rails_overlay" res["https://github.com/mharris717/widget_overlay_rails.git"] = "rails_widget" res end |
.to_local_repo_path(url) ⇒ Object
30 31 32 33 34 |
# File 'lib/overapp/util/tmp_dir.rb', line 30 def to_local_repo_path(url) base = local_repo_map[url] raise "no base #{url}" unless base "/code/orig/ember_npm_projects/overlays/#{base}" end |
.with(ops = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/overapp/util/tmp_dir.rb', line 7 def with(ops={}) dir = "#{base_dir}/#{rand(1000000000000000000)}" `mkdir #{dir}` if block_given? Dir.chdir(dir) do yield dir end else dir end ensure if block_given? ec "rm -rf #{dir}", :silent => true end end |
.with_repo_path(url) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/overapp/util/tmp_dir.rb', line 36 def with_repo_path(url) url = Overapp.to_proper_dir(url) with do |dir| `git clone #{url} . 2>&1` yield dir end end |
.with_repo_path_localuse(url) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/overapp/util/tmp_dir.rb', line 44 def with_repo_path_localuse(url) File.create "/code/orig/overapp/repo.txt",url dir = to_local_repo_path(url) Dir.chdir(dir) do yield dir end end |