Skip to content

Commit

Permalink
refactored update method of gems.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
angelic committed Nov 13, 2008
1 parent de771a1 commit a0edb4c
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions lib/gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,16 @@ class Gems
def initialize app_name
@app_name = app_name
end

def update *gems
if gems.length
args = ''
gems.each {|x| args += " #{x}"}
result = `gem update #{args}`
if result
puts 'Gem update failed. Please enter your admin password for sudo gem update:'
`sudo gem update #{args}`
end
else
result = `gem update`
if result
puts 'Gem update failed. Please enter your admin password for sudo gem update:'
`sudo gem update`
end
args = gems.inject('') {|text, g| "#{text} #{g}"}
result = `gem update #{args}`
if result
puts 'Gem update failed. Please enter your admin password for sudo gem update:'
`sudo gem update #{args}`
end
end
end

def config *gems
@gems = gems
to_insert = gems.inject("") {|text, g| "#{text} config.gem '#{g}'\n"}
Expand Down

0 comments on commit a0edb4c

Please sign in to comment.