Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Suggested changes to help Debian packaging #58

Open
wants to merge 2 commits into from

2 participants

Antonio Terceiro Bryan McLellan
Antonio 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).

added some commits February 09, 2012
Antonio 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
Antonio 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
Bryan McLellan
Owner

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.

Antonio 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

Bryan McLellan
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Feb 09, 2012
Antonio 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
Antonio 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
This page is out of date. Refresh to see the latest.
19  bin/ohai
@@ -19,26 +19,13 @@
19 19
 # limitations under the License.
20 20
 #
21 21
 
22  
-
23  
-begin
24  
-  require 'rubygems'
25  
-rescue LoadError
26  
-  # must be debian! ;)
27  
-  missing_rubygems = true
28  
-end
29  
-begin
  22
+if File.exists?(File.expand_path('../../ohai.gemspec', __FILE__))
30 23
   # if we're in a source code checkout, we want to run the code from that.
31  
-  # have to do this *after* rubygems is loaded.
32 24
   $:.unshift File.expand_path('../../lib', __FILE__)
33  
-  require 'ohai/application'
34  
-rescue LoadError
35  
-  if missing_rubygems
36  
-    STDERR.puts "rubygems previously failed to load - is it installed?"
37  
-  end
38  
-
39  
-  raise
40 25
 end
41 26
 
  27
+require 'ohai/application'
  28
+
42 29
 if RUBY_PLATFORM =~ /mswin|mingw32|windows/
43 30
   begin
44 31
     require 'ruby-wmi'
38  spec/ohai/plugins/ruby_spec.rb
@@ -18,8 +18,7 @@
18 18
 
19 19
 
20 20
 require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
21  
-
22  
-ruby_bin = File.join(::Config::CONFIG['bindir'], ::Config::CONFIG['ruby_install_name'])
  21
+require 'tempfile'
23 22
 
24 23
 describe Ohai::System, "plugin ruby" do
25 24
 
@@ -36,23 +35,34 @@
36 35
     @ruby_ohai_data = @ruby_ohai_data_pristine.dup
37 36
   end
38 37
 
39  
-  {
  38
+  code = <<-EOS
  39
+  ruby_bin = File.join(::RbConfig::CONFIG['bindir'], ::RbConfig::CONFIG['ruby_install_name'])
  40
+  data = {
40 41
     :platform => RUBY_PLATFORM,
41 42
     :version => RUBY_VERSION,
42 43
     :release_date => RUBY_RELEASE_DATE,
43  
-    :target => ::Config::CONFIG['target'],
44  
-    :target_cpu => ::Config::CONFIG['target_cpu'],
45  
-    :target_vendor => ::Config::CONFIG['target_vendor'],
46  
-    :target_os => ::Config::CONFIG['target_os'],
47  
-    :host => ::Config::CONFIG['host'],
48  
-    :host_cpu => ::Config::CONFIG['host_cpu'],
49  
-    :host_os => ::Config::CONFIG['host_os'],
50  
-    :host_vendor => ::Config::CONFIG['host_vendor'],
51  
-    :gems_dir => %x{#{ruby_bin} #{::Config::CONFIG['bindir']}/gem env gemdir}.chomp!,
52  
-    :gem_bin => [ ::Gem.default_exec_format % 'gem', 'gem' ].map{|bin| "#{::Config::CONFIG['bindir']}/#{bin}"
  44
+    :target => ::RbConfig::CONFIG['target'],
  45
+    :target_cpu => ::RbConfig::CONFIG['target_cpu'],
  46
+    :target_vendor => ::RbConfig::CONFIG['target_vendor'],
  47
+    :target_os => ::RbConfig::CONFIG['target_os'],
  48
+    :host => ::RbConfig::CONFIG['host'],
  49
+    :host_cpu => ::RbConfig::CONFIG['host_cpu'],
  50
+    :host_os => ::RbConfig::CONFIG['host_os'],
  51
+    :host_vendor => ::RbConfig::CONFIG['host_vendor'],
  52
+    :gems_dir => %x{\#{ruby_bin} \#{::RbConfig::CONFIG['bindir']}/gem env gemdir}.chomp!,
  53
+    :gem_bin => [ ::Gem.default_exec_format % 'gem', 'gem' ].map{|bin| "\#{::RbConfig::CONFIG['bindir']}/\#{bin}"
53 54
       }.find{|bin| ::File.exists? bin},
54 55
     :ruby_bin => ruby_bin
55  
-  }.each do |attribute, value|
  56
+  }
  57
+  puts data.inspect
  58
+  EOS
  59
+  program = Tempfile.new('ruby')
  60
+  program.write(code)
  61
+  program.close
  62
+  data = eval(`ruby #{program.path}`)
  63
+  program.unlink
  64
+
  65
+  data.each do |attribute, value|
56 66
     it "should have #{attribute} set" do
57 67
       @ruby_ohai_data[attribute].should eql(value)
58 68
     end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.