Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Suggested changes to help Debian packaging #58

Closed
wants to merge 2 commits into from

3 participants

@terceiro

Hi,

These changes will help Debian packaging. Please consider applying them to the official tree so that they get included in the next release.

(I've just finished signing the CLA).

terceiro added some commits
@terceiro terceiro Obtain Ruby plugin test data from system ruby
This fixes the tests for the case where `ruby` is not the same
Ruby interpreter as the one you are running the tests against. For
example, the `ruby` in yout $PATH might be Ruby 1.8, but you are running
the tests under Ruby 1.9 (or vice-versa).
b2b8304
@terceiro terceiro Simplify loading logic in main program
If ohai was installed by Rubygems, it doesn't need to call `require
'rubygems'` because the bin stub created by Rubygems will do that
already.

Also, only add the local lib/ directory to the $LOAD_PATH if ohai is
actually being run from a source checkout.
00a2f12
@btm
Owner
btm commented

Anthony, I'm quite interested in helping here. Can you file a ticket at http://tickets.opscode.com against the Ohai project that details the reasons for the changes a little? I'm mobile right now and I will look over the diff later tonight.

@terceiro

I tried to write informative commit messages that explain the reasons for the changes, so as far as I can tell the commits are self informative.

OHAI ticket: http://tickets.opscode.com/browse/OHAI-332

@btm
Owner

Thanks! I knew I'd have to go back and reference other tickets so I wanted to be sure we got into the bug tracker there. Because I was mobile, I couldn't really look at the pull request but figured I could start responding right away. I'll keep following up on the ticket.

@lamont-granquist

2 years old

  • the RbConfig fixes already went into ohai
  • this patch implicitly drops support for ruby 1.8.7 (require 'rubygems' stuff) and we still support that so can't be merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 9, 2012
  1. @terceiro

    Obtain Ruby plugin test data from system ruby

    terceiro authored
    This fixes the tests for the case where `ruby` is not the same
    Ruby interpreter as the one you are running the tests against. For
    example, the `ruby` in yout $PATH might be Ruby 1.8, but you are running
    the tests under Ruby 1.9 (or vice-versa).
  2. @terceiro

    Simplify loading logic in main program

    terceiro authored
    If ohai was installed by Rubygems, it doesn't need to call `require
    'rubygems'` because the bin stub created by Rubygems will do that
    already.
    
    Also, only add the local lib/ directory to the $LOAD_PATH if ohai is
    actually being run from a source checkout.
This page is out of date. Refresh to see the latest.
Showing with 27 additions and 30 deletions.
  1. +3 −16 bin/ohai
  2. +24 −14 spec/ohai/plugins/ruby_spec.rb
View
19 bin/ohai
@@ -19,26 +19,13 @@
# limitations under the License.
#
-
-begin
- require 'rubygems'
-rescue LoadError
- # must be debian! ;)
- missing_rubygems = true
-end
-begin
+if File.exists?(File.expand_path('../../ohai.gemspec', __FILE__))
# if we're in a source code checkout, we want to run the code from that.
- # have to do this *after* rubygems is loaded.
$:.unshift File.expand_path('../../lib', __FILE__)
- require 'ohai/application'
-rescue LoadError
- if missing_rubygems
- STDERR.puts "rubygems previously failed to load - is it installed?"
- end
-
- raise
end
+require 'ohai/application'
+
if RUBY_PLATFORM =~ /mswin|mingw32|windows/
begin
require 'ruby-wmi'
View
38 spec/ohai/plugins/ruby_spec.rb
@@ -18,8 +18,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-
-ruby_bin = File.join(::Config::CONFIG['bindir'], ::Config::CONFIG['ruby_install_name'])
+require 'tempfile'
describe Ohai::System, "plugin ruby" do
@@ -36,23 +35,34 @@
@ruby_ohai_data = @ruby_ohai_data_pristine.dup
end
- {
+ code = <<-EOS
+ ruby_bin = File.join(::RbConfig::CONFIG['bindir'], ::RbConfig::CONFIG['ruby_install_name'])
+ data = {
:platform => RUBY_PLATFORM,
:version => RUBY_VERSION,
:release_date => RUBY_RELEASE_DATE,
- :target => ::Config::CONFIG['target'],
- :target_cpu => ::Config::CONFIG['target_cpu'],
- :target_vendor => ::Config::CONFIG['target_vendor'],
- :target_os => ::Config::CONFIG['target_os'],
- :host => ::Config::CONFIG['host'],
- :host_cpu => ::Config::CONFIG['host_cpu'],
- :host_os => ::Config::CONFIG['host_os'],
- :host_vendor => ::Config::CONFIG['host_vendor'],
- :gems_dir => %x{#{ruby_bin} #{::Config::CONFIG['bindir']}/gem env gemdir}.chomp!,
- :gem_bin => [ ::Gem.default_exec_format % 'gem', 'gem' ].map{|bin| "#{::Config::CONFIG['bindir']}/#{bin}"
+ :target => ::RbConfig::CONFIG['target'],
+ :target_cpu => ::RbConfig::CONFIG['target_cpu'],
+ :target_vendor => ::RbConfig::CONFIG['target_vendor'],
+ :target_os => ::RbConfig::CONFIG['target_os'],
+ :host => ::RbConfig::CONFIG['host'],
+ :host_cpu => ::RbConfig::CONFIG['host_cpu'],
+ :host_os => ::RbConfig::CONFIG['host_os'],
+ :host_vendor => ::RbConfig::CONFIG['host_vendor'],
+ :gems_dir => %x{\#{ruby_bin} \#{::RbConfig::CONFIG['bindir']}/gem env gemdir}.chomp!,
+ :gem_bin => [ ::Gem.default_exec_format % 'gem', 'gem' ].map{|bin| "\#{::RbConfig::CONFIG['bindir']}/\#{bin}"
}.find{|bin| ::File.exists? bin},
:ruby_bin => ruby_bin
- }.each do |attribute, value|
+ }
+ puts data.inspect
+ EOS
+ program = Tempfile.new('ruby')
+ program.write(code)
+ program.close
+ data = eval(`ruby #{program.path}`)
+ program.unlink
+
+ data.each do |attribute, value|
it "should have #{attribute} set" do
@ruby_ohai_data[attribute].should eql(value)
end
Something went wrong with that request. Please try again.