Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleanup some comments and make code a bit more clear
  • Loading branch information
kalbasit committed Mar 28, 2013
1 parent dd7cb75 commit 4aa8fcf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
8 changes: 1 addition & 7 deletions janus/ruby/janus/gems.rb
Expand Up @@ -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}"
Expand Down
13 changes: 7 additions & 6 deletions janus/ruby/janus/plugins.rb
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 4aa8fcf

Please sign in to comment.