Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
Suppress gem checks for older rubygems versions.
Browse files Browse the repository at this point in the history
Fixes #81
  • Loading branch information
bobthecow committed Mar 25, 2013
1 parent 3ca6f70 commit 665a2c2
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 95 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
## v2.2.3

* [Fix #90][i90] — Fix error loading server list after adding a malformed server DSN (PHP backend).
* [Fix #81][i81] — Suppress dependency version warnings if for (really) old versions of rubygems.
* Fix various compile errors and edge cases.
* Bump Bootstrap and Mousetrap library versions.

[i90]: https://github.com/bobthecow/genghis/issues/90
[i81]: https://github.com/bobthecow/genghis/issues/81


## v2.2.2
Expand Down
100 changes: 53 additions & 47 deletions genghis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -692,27 +692,6 @@ def thunk_mongo_id(id)

def server_status_alerts
alerts = []
unless defined? ::BSON::BSON_C
require 'rubygems'

Gem.refresh

installed = Gem::Specification.find_all { |s| s.name == 'mongo' }.map { |s| s.version }.sort.last
if Gem::Specification.find_all { |s| s.name == 'bson_ext' && s.version == installed }.empty?
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>MongoDB driver C extension not found.</h4>
Install this extension for better performance: <code>gem install bson_ext -v #{installed}</code>
MSG
alerts << {:level => 'warning', :msg => msg}
else
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>Restart required</h4>
You have recently installed the <tt>bson_ext</tt> extension.
Run <code>genghisapp&nbsp;--kill</code> then restart <code>genghisapp</code> to use it.
MSG
alerts << {:level => 'info', :msg => msg}
end
end

unless defined? ::JSON::Ext
msg = <<-MSG.strip.gsub(/\s+/, " ")
Expand All @@ -722,39 +701,66 @@ def server_status_alerts
alerts << {:level => 'warning', :msg => msg}
end

unless ENV['GENGHIS_NO_UPDATE_CHECK']
require 'open-uri'
require 'rubygems'
# It would be awesome if we didn't have to resort to this :)
if Gem::Specification.respond_to? :find_all

Gem.refresh
unless defined? ::BSON::BSON_C
require 'rubygems'

latest = nil
installed = Gem::Specification.find_all { |s| s.name == 'genghisapp' }.map { |s| s.version }.sort.last
running = Gem::Version.new(Genghis::VERSION.gsub(/[\+_-]/, '.'))
Gem.refresh

begin
open('https://raw.github.com/bobthecow/genghis/master/VERSION') do |f|
latest = Gem::Version.new(f.read.gsub(/[\+_-]/, '.'))
installed = Gem::Specification.find_all { |s| s.name == 'mongo' }.map { |s| s.version }.sort.last
if Gem::Specification.find_all { |s| s.name == 'bson_ext' && s.version == installed }.empty?
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>MongoDB driver C extension not found.</h4>
Install this extension for better performance: <code>gem install bson_ext -v #{installed}</code>
MSG
alerts << {:level => 'warning', :msg => msg}
else
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>Restart required</h4>
You have recently installed the <tt>bson_ext</tt> extension.
Run <code>genghisapp&nbsp;--kill</code> then restart <code>genghisapp</code> to use it.
MSG
alerts << {:level => 'info', :msg => msg}
end
rescue
# do nothing...
end

if latest && (installed || running) < latest
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>A Genghis update is available</h4>
You are running Genghis version <tt>#{Genghis::VERSION}</tt>. The current version is <tt>#{latest}</tt>.
Visit <a href="http://genghisapp.com">genghisapp.com</a> for more information.
MSG
alerts << {:level => 'warning', :msg => msg}
elsif installed && running < installed
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>Restart required</h4>
You have installed Genghis version <tt>#{installed}</tt> but are still running <tt>#{Genghis::VERSION}</tt>.
Run <code>genghisapp&nbsp;--kill</code> then restart <code>genghisapp</code>.
MSG
alerts << {:level => 'info', :msg => msg}
unless ENV['GENGHIS_NO_UPDATE_CHECK']
require 'open-uri'
require 'rubygems'

Gem.refresh

latest = nil
installed = Gem::Specification.find_all { |s| s.name == 'genghisapp' }.map { |s| s.version }.sort.last
running = Gem::Version.new(Genghis::VERSION.gsub(/[\+_-]/, '.'))

begin
open('https://raw.github.com/bobthecow/genghis/master/VERSION') do |f|
latest = Gem::Version.new(f.read.gsub(/[\+_-]/, '.'))
end
rescue
# do nothing...
end

if latest && (installed || running) < latest
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>A Genghis update is available</h4>
You are running Genghis version <tt>#{Genghis::VERSION}</tt>. The current version is <tt>#{latest}</tt>.
Visit <a href="http://genghisapp.com">genghisapp.com</a> for more information.
MSG
alerts << {:level => 'warning', :msg => msg}
elsif installed && running < installed
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>Restart required</h4>
You have installed Genghis version <tt>#{installed}</tt> but are still running <tt>#{Genghis::VERSION}</tt>.
Run <code>genghisapp&nbsp;--kill</code> then restart <code>genghisapp</code>.
MSG
alerts << {:level => 'info', :msg => msg}
end
end

end

alerts
Expand Down
102 changes: 54 additions & 48 deletions src/rb/genghis/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,6 @@ def thunk_mongo_id(id)

def server_status_alerts
alerts = []
unless defined? ::BSON::BSON_C
require 'rubygems'

Gem.refresh

installed = Gem::Specification.find_all { |s| s.name == 'mongo' }.map { |s| s.version }.sort.last
if Gem::Specification.find_all { |s| s.name == 'bson_ext' && s.version == installed }.empty?
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>MongoDB driver C extension not found.</h4>
Install this extension for better performance: <code>gem install bson_ext -v #{installed}</code>
MSG
alerts << {:level => 'warning', :msg => msg}
else
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>Restart required</h4>
You have recently installed the <tt>bson_ext</tt> extension.
Run <code>genghisapp&nbsp;--kill</code> then restart <code>genghisapp</code> to use it.
MSG
alerts << {:level => 'info', :msg => msg}
end
end

unless defined? ::JSON::Ext
msg = <<-MSG.strip.gsub(/\s+/, " ")
Expand All @@ -70,39 +49,66 @@ def server_status_alerts
alerts << {:level => 'warning', :msg => msg}
end

unless ENV['GENGHIS_NO_UPDATE_CHECK']
require 'open-uri'
require 'rubygems'
# It would be awesome if we didn't have to resort to this :)
if Gem::Specification.respond_to? :find_all

unless defined? ::BSON::BSON_C
require 'rubygems'

Gem.refresh

installed = Gem::Specification.find_all { |s| s.name == 'mongo' }.map { |s| s.version }.sort.last
if Gem::Specification.find_all { |s| s.name == 'bson_ext' && s.version == installed }.empty?
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>MongoDB driver C extension not found.</h4>
Install this extension for better performance: <code>gem install bson_ext -v #{installed}</code>
MSG
alerts << {:level => 'warning', :msg => msg}
else
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>Restart required</h4>
You have recently installed the <tt>bson_ext</tt> extension.
Run <code>genghisapp&nbsp;--kill</code> then restart <code>genghisapp</code> to use it.
MSG
alerts << {:level => 'info', :msg => msg}
end
end

unless ENV['GENGHIS_NO_UPDATE_CHECK']
require 'open-uri'
require 'rubygems'

Gem.refresh
Gem.refresh

latest = nil
installed = Gem::Specification.find_all { |s| s.name == 'genghisapp' }.map { |s| s.version }.sort.last
running = Gem::Version.new(Genghis::VERSION.gsub(/[\+_-]/, '.'))
latest = nil
installed = Gem::Specification.find_all { |s| s.name == 'genghisapp' }.map { |s| s.version }.sort.last
running = Gem::Version.new(Genghis::VERSION.gsub(/[\+_-]/, '.'))

begin
open('https://raw.github.com/bobthecow/genghis/master/VERSION') do |f|
latest = Gem::Version.new(f.read.gsub(/[\+_-]/, '.'))
begin
open('https://raw.github.com/bobthecow/genghis/master/VERSION') do |f|
latest = Gem::Version.new(f.read.gsub(/[\+_-]/, '.'))
end
rescue
# do nothing...
end
rescue
# do nothing...
end

if latest && (installed || running) < latest
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>A Genghis update is available</h4>
You are running Genghis version <tt>#{Genghis::VERSION}</tt>. The current version is <tt>#{latest}</tt>.
Visit <a href="http://genghisapp.com">genghisapp.com</a> for more information.
MSG
alerts << {:level => 'warning', :msg => msg}
elsif installed && running < installed
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>Restart required</h4>
You have installed Genghis version <tt>#{installed}</tt> but are still running <tt>#{Genghis::VERSION}</tt>.
Run <code>genghisapp&nbsp;--kill</code> then restart <code>genghisapp</code>.
MSG
alerts << {:level => 'info', :msg => msg}
if latest && (installed || running) < latest
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>A Genghis update is available</h4>
You are running Genghis version <tt>#{Genghis::VERSION}</tt>. The current version is <tt>#{latest}</tt>.
Visit <a href="http://genghisapp.com">genghisapp.com</a> for more information.
MSG
alerts << {:level => 'warning', :msg => msg}
elsif installed && running < installed
msg = <<-MSG.strip.gsub(/\s+/, " ")
<h4>Restart required</h4>
You have installed Genghis version <tt>#{installed}</tt> but are still running <tt>#{Genghis::VERSION}</tt>.
Run <code>genghisapp&nbsp;--kill</code> then restart <code>genghisapp</code>.
MSG
alerts << {:level => 'info', :msg => msg}
end
end

end

alerts
Expand Down

0 comments on commit 665a2c2

Please sign in to comment.