Skip to content

Commit

Permalink
Made the installer not print the install process
Browse files Browse the repository at this point in the history
  • Loading branch information
brand-it committed Sep 25, 2018
1 parent d635790 commit 6e6de72
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
34 changes: 24 additions & 10 deletions gem_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,37 @@

module GemInstaller
def install(lib)
return false if `gem list #{lib}`.include?(lib)
Logger.info("running 'install #{lib} --no-ri --no-rdoc'")
Gem::GemRunner.new.run(['install', lib, '--no-ri', '--no-rdoc'])
Logger.info("failed to 'install #{lib} --no-ri --no-rdoc'")
false
suppress_output do
return false if `gem list #{lib}`.include?(lib)
Logger.info("running 'install #{lib} --no-ri --no-rdoc'")
Gem::GemRunner.new.run(['install', lib, '--no-ri', '--no-rdoc'])
Logger.info("failed to 'install #{lib} --no-ri --no-rdoc'")
false
end
rescue Gem::SystemExitException
Logger.info("Successfully Installed #{lib}")
true
end

def reinstall(lib)
return install(lib) unless `gem list #{lib}`.include?(lib)
Logger.info("Uninstalling #{lib}")
Gem::GemRunner.new.run(['uninstall', lib, '-a'])
Logger.info("Failed to uninstall #{lib}")
install(lib)
suppress_output do
return install(lib) unless `gem list #{lib}`.include?(lib)
Logger.info("Uninstalling #{lib}")
Gem::GemRunner.new.run(['uninstall', lib, '-a'])
Logger.info("Failed to uninstall #{lib}")
install(lib)
end
rescue StandardError => exception
Logger.error("Failure #{exception.message}")
end

def suppress_output
original_stdout, original_stderr = $stdout.clone, $stderr.clone
$stderr.reopen File.new('/dev/null', 'w')
$stdout.reopen File.new('/dev/null', 'w')
yield
ensure
$stdout.reopen original_stdout
$stderr.reopen original_stderr
end
end
2 changes: 1 addition & 1 deletion info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ end</string>
<key>queuemode</key>
<integer>1</integer>
<key>runningsubtext</key>
<string>Loading Classes...</string>
<string>Downloading Faker Gem....</string>
<key>script</key>
<string>query = ARGV[0].to_s.downcase
require 'json'
Expand Down

0 comments on commit 6e6de72

Please sign in to comment.