diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 138b16a5..04f0deca 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -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 diff --git a/genghis.rb b/genghis.rb index 2f9f7330..8e4a8a52 100755 --- a/genghis.rb +++ b/genghis.rb @@ -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+/, " ") -

MongoDB driver C extension not found.

- Install this extension for better performance: gem install bson_ext -v #{installed} - MSG - alerts << {:level => 'warning', :msg => msg} - else - msg = <<-MSG.strip.gsub(/\s+/, " ") -

Restart required

- You have recently installed the bson_ext extension. - Run genghisapp --kill then restart genghisapp to use it. - MSG - alerts << {:level => 'info', :msg => msg} - end - end unless defined? ::JSON::Ext msg = <<-MSG.strip.gsub(/\s+/, " ") @@ -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+/, " ") +

MongoDB driver C extension not found.

+ Install this extension for better performance: gem install bson_ext -v #{installed} + MSG + alerts << {:level => 'warning', :msg => msg} + else + msg = <<-MSG.strip.gsub(/\s+/, " ") +

Restart required

+ You have recently installed the bson_ext extension. + Run genghisapp --kill then restart genghisapp to use it. + MSG + alerts << {:level => 'info', :msg => msg} end - rescue - # do nothing... end - if latest && (installed || running) < latest - msg = <<-MSG.strip.gsub(/\s+/, " ") -

A Genghis update is available

- You are running Genghis version #{Genghis::VERSION}. The current version is #{latest}. - Visit genghisapp.com for more information. - MSG - alerts << {:level => 'warning', :msg => msg} - elsif installed && running < installed - msg = <<-MSG.strip.gsub(/\s+/, " ") -

Restart required

- You have installed Genghis version #{installed} but are still running #{Genghis::VERSION}. - Run genghisapp --kill then restart genghisapp. - 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+/, " ") +

A Genghis update is available

+ You are running Genghis version #{Genghis::VERSION}. The current version is #{latest}. + Visit genghisapp.com for more information. + MSG + alerts << {:level => 'warning', :msg => msg} + elsif installed && running < installed + msg = <<-MSG.strip.gsub(/\s+/, " ") +

Restart required

+ You have installed Genghis version #{installed} but are still running #{Genghis::VERSION}. + Run genghisapp --kill then restart genghisapp. + MSG + alerts << {:level => 'info', :msg => msg} + end end + end alerts diff --git a/src/rb/genghis/helpers.rb b/src/rb/genghis/helpers.rb index 6da98896..3da8b96d 100644 --- a/src/rb/genghis/helpers.rb +++ b/src/rb/genghis/helpers.rb @@ -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+/, " ") -

MongoDB driver C extension not found.

- Install this extension for better performance: gem install bson_ext -v #{installed} - MSG - alerts << {:level => 'warning', :msg => msg} - else - msg = <<-MSG.strip.gsub(/\s+/, " ") -

Restart required

- You have recently installed the bson_ext extension. - Run genghisapp --kill then restart genghisapp to use it. - MSG - alerts << {:level => 'info', :msg => msg} - end - end unless defined? ::JSON::Ext msg = <<-MSG.strip.gsub(/\s+/, " ") @@ -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+/, " ") +

MongoDB driver C extension not found.

+ Install this extension for better performance: gem install bson_ext -v #{installed} + MSG + alerts << {:level => 'warning', :msg => msg} + else + msg = <<-MSG.strip.gsub(/\s+/, " ") +

Restart required

+ You have recently installed the bson_ext extension. + Run genghisapp --kill then restart genghisapp 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+/, " ") -

A Genghis update is available

- You are running Genghis version #{Genghis::VERSION}. The current version is #{latest}. - Visit genghisapp.com for more information. - MSG - alerts << {:level => 'warning', :msg => msg} - elsif installed && running < installed - msg = <<-MSG.strip.gsub(/\s+/, " ") -

Restart required

- You have installed Genghis version #{installed} but are still running #{Genghis::VERSION}. - Run genghisapp --kill then restart genghisapp. - MSG - alerts << {:level => 'info', :msg => msg} + if latest && (installed || running) < latest + msg = <<-MSG.strip.gsub(/\s+/, " ") +

A Genghis update is available

+ You are running Genghis version #{Genghis::VERSION}. The current version is #{latest}. + Visit genghisapp.com for more information. + MSG + alerts << {:level => 'warning', :msg => msg} + elsif installed && running < installed + msg = <<-MSG.strip.gsub(/\s+/, " ") +

Restart required

+ You have installed Genghis version #{installed} but are still running #{Genghis::VERSION}. + Run genghisapp --kill then restart genghisapp. + MSG + alerts << {:level => 'info', :msg => msg} + end end + end alerts