Class: GitCollection
- Inherits:
-
Object
- Object
- GitCollection
- Defined in:
- lib/gpack/core/GitCollection.rb
Instance Attribute Summary collapse
-
#refs ⇒ Object
Returns the value of attribute refs.
Instance Method Summary collapse
- #add_ref(ref) ⇒ Object
- #archive ⇒ Object
- #check ⇒ Object
- #clone ⇒ Object
-
#initialize ⇒ GitCollection
constructor
A new instance of GitCollection.
- #print ⇒ Object
- #ref_loop(refs, parallel_override = false) ⇒ Object
- #remove ⇒ Object
- #rinse ⇒ Object
- #set_writeable(tf) ⇒ Object
- #status ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize ⇒ GitCollection
Returns a new instance of GitCollection.
7 8 9 |
# File 'lib/gpack/core/GitCollection.rb', line 7 def initialize @refs = [] end |
Instance Attribute Details
#refs ⇒ Object
Returns the value of attribute refs.
5 6 7 |
# File 'lib/gpack/core/GitCollection.rb', line 5 def refs @refs end |
Instance Method Details
#add_ref(ref) ⇒ Object
10 11 12 |
# File 'lib/gpack/core/GitCollection.rb', line 10 def add_ref(ref) @refs << ref end |
#archive ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/gpack/core/GitCollection.rb', line 19 def archive() puts "\nCreating archives of local Repositories....." raise_warning = ref_loop(refs) { |ref| ref.archive } if raise_warning puts "\n"+("="*60+"\nWARNING DURING CLONING!\n\tSome repositories already existed and failed checks.\n\tReview this log or run 'gpack check' to see detailed information\n"+"="*60).color(Colors::RED) end end |
#check ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/gpack/core/GitCollection.rb', line 48 def check() puts "\nChecking Local Repositories....." raise_warning = ref_loop(refs,true) { |ref| ref.check } if raise_warning puts "\n"+("="*60+"\nWARNINGS FOUND DURING CHECK!\n\tReview this log to see detailed information\n" \ "\tThe following commands can be run to help debug:\n" \ "\t\tgpack status #Shows the current git status\n" \ "\t\tgpack rinse #Removes all local changes and untracked files,use with caution\n" \ +"="*60).color(Colors::RED) else puts "\n"+("All checks passed!").color(Colors::GREEN) end end |
#clone ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gpack/core/GitCollection.rb', line 28 def clone() puts "\nCloning Repositories....." raise_warning = ref_loop(refs) { |ref| ref.clone } if raise_warning puts "\n"+("="*60+"\nWARNING DURING CLONING!\n\tSome repositories already existed and failed checks.\n\tReview this log or run 'gpack check' to see detailed information\n"+"="*60).color(Colors::RED) end print() check() end |
#print ⇒ Object
13 14 15 16 17 18 |
# File 'lib/gpack/core/GitCollection.rb', line 13 def print() puts "="*40+"\n\tGit Reference Summary\n"+"="*40 @refs.each do |ref| ref.print() end end |
#ref_loop(refs, parallel_override = false) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/gpack/core/GitCollection.rb', line 114 def ref_loop(refs, parallel_override=false) if $SETTINGS["core"]["parallel"] && !parallel_override read, write = IO.pipe Parallel.map(@refs) do |ref| # Set up standard output as a StringIO object. old_stdout = $stdout foo = StringIO.new $stdout = foo raise_warning = yield(ref) write.puts raise_warning $stdout = old_stdout puts foo.string end write.close read_data = read.read #puts read_data if read_data.index("true") raise_warning = true end else raise_warning = false @refs.each do |ref| ret_warning = yield(ref) if ret_warning raise_warning = true end end end return raise_warning end |
#remove ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/gpack/core/GitCollection.rb', line 83 def remove() puts "This will force remove repositories and repopulate. Any local data will be lost!!!\nContinue (y/n)" if $SETTINGS["core"]["force"] == true do_remove = true else cont = $stdin.gets.chomp do_remove = cont == "y" end if do_remove puts "\nRemoving Local Repositories....." raise_warning = ref_loop(refs) { |ref| ref.remove() } `rm -f .gpackunlock` else puts "Abort Uninstall" end if raise_warning puts "\n"+("="*60+"\nWARNINGS FOUND DURING REMOVAL!\n\tReview this log to see detailed information\n"+"="*60).color(Colors::RED) end end |
#rinse ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/gpack/core/GitCollection.rb', line 39 def rinse() puts "\nRinsing Repositories....." raise_warning = ref_loop(refs) { |ref| ref.rinse } if raise_warning puts ("\n"+"="*60+"\nWARNING DURING Rinse!\n"+"="*60).color(Colors::RED) end end |
#set_writeable(tf) ⇒ Object
107 108 109 110 111 |
# File 'lib/gpack/core/GitCollection.rb', line 107 def set_writeable(tf) ref_loop(refs) { |ref| ref.set_writeable(tf) } end |
#status ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/gpack/core/GitCollection.rb', line 63 def status() puts "\nStatus of Local Repositories....." raise_warning = ref_loop(refs,true) { |ref| ref.status } if raise_warning puts "\n"+("="*60+"\nWARNINGS FOUND DURING CHECK!\n\tReview this log to see detailed information\n"+"="*60).color(Colors::RED) end end |
#update ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/gpack/core/GitCollection.rb', line 72 def update() print() puts "\nUpdating Repositories.....\n\n" puts "Please be patient, this can take some time if pulling large commits.....".color(Colors::GREEN) raise_warning = ref_loop(refs) { |ref| ref.update() } if raise_warning puts "\n"+("="*60+"\nWARNING DURING UPDATE!\n\tSome repositories failed checks and were not updated.\n\tReview this log or run 'gpack check' to see detailed information\n"+"="*60).color(Colors::RED) end end |