Permalink
Browse files

Cleanup some comments and make code a bit more clear

  • Loading branch information...
1 parent dd7cb75 commit 4aa8fcf7f06ddbf958120a6f1e9d81d9cc1e014f @kalbasit kalbasit committed Mar 22, 2013
Showing with 8 additions and 13 deletions.
  1. +1 −7 janus/ruby/janus/gems.rb
  2. +7 −6 janus/ruby/janus/plugins.rb
View
@@ -23,13 +23,7 @@ def find_gem(gem_name, *requirements)
#
# @param [String] The gem name
def install_gem(gem_name)
- require 'rubygems'
-
- # Install the gem only if it can't be found
- if find_gem(gem_name).length == 0
- # XXX: We should not run sudo if we do not need to!
- sudo "gem install #{gem_name}"
- end
+ sudo "gem install #{gem_name}" if find_gem(gem_name).length == 0
rescue RubyGemsNotFoundError
puts "Could not install the gem #{gem_name}, please do so manually."
puts "sudo gem install #{gem_name}"
@@ -6,8 +6,8 @@ module Janus
def self.included(base)
# Load all plugin installation tasks
- Dir["#{vim_path}/*/tasks/**.rake"].each do |f|
- base.send :import, f
+ Dir["#{vim_path}/*/tasks/**.rake"].each do |rake_file|
+ base.send :import, rake_file
end
end
@@ -39,7 +39,10 @@ def postinstall_vim_plugin(group, name, &block)
# @param [String] path
def download_and_save_file(url, path)
proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
- open_and_save_file(path, open(url, :proxy => proxy).read)
+
+ open_and_save_file(path) do
+ open(url, :proxy => proxy).read
+ end
end
# Open and save file
@@ -48,10 +51,8 @@ def download_and_save_file(url, path)
# @param [Value] What to write in the file
# @param [&block]
def open_and_save_file(path, value = nil, &block)
- # Make sure the directory up to the folder exists
mkdir_p File.dirname(path)
- # Open the file and use either the block or the value to write the
- # file
+
File.open path, 'w' do |f|
if block_given?
f.write(yield)

0 comments on commit 4aa8fcf

Please sign in to comment.