Skip to content

Commit

Permalink
gathering rubygems information
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Feb 6, 2009
1 parent 0469db7 commit c199320
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/busted/gem.rb
Expand Up @@ -44,6 +44,16 @@ def ruby_info_file
target target
end end


def gem_info_file
template_file = File.join(BASEDIR, 'templates', 'gem_info.erb')
template = ERB.new(File.read(template_file))
target = File.join(Dir::tmpdir, 'gem_info.txt')
File.open(target, 'wb') { |f|
f.write template.result(binding)
}
target
end

private private
def copy_gem def copy_gem
dirname = File.join(Dir::tmpdir, File.basename(@gemspec.full_gem_path)) dirname = File.join(Dir::tmpdir, File.basename(@gemspec.full_gem_path))
Expand Down
20 changes: 20 additions & 0 deletions templates/gem_info.erb
@@ -0,0 +1,20 @@
# RubyGems Environment #

- RUBYGEMS VERSION: <%= ::Gem::RubyGemsVersion %>
- RUBY VERSION: <%= RUBY_VERSION %> (<%= RUBY_RELEASE_DATE %> patchlevel <%= defined?(RUBY_PATCHLEVEL) ? RUBY_PATCHLEVEL : 'none' %>) [<%= RUBY_PLATFORM %>]
- INSTALLATION DIRECTORY: <%= ::Gem.dir %>
- RUBYGEMS PREFIX: <%= ::Gem.prefix %>
- RUBY EXECUTABLE: <%= ::Gem.ruby %>
- EXECUTABLE DIRECTORY: <%= ::Gem.bindir %>
- RUBYGEMS PLATFORMS:
<% ::Gem.platforms.each do |platform| %> - <%= platform %>
<% end %>
- GEM PATHS:
<% ::Gem.path.each do |path| %> - <%= path %>
<% end %>
- GEM CONFIGURATION:
<% ::Gem.configuration.each do |name, value| %> - <%= name.inspect %> => <%= value.inspect %>
<% end %>
- REMOTE SOURCES:
<% ::Gem.sources.each do |s| %> - <%= s %>
<% end %>
2 changes: 1 addition & 1 deletion templates/ruby_info.erb
@@ -1,3 +1,3 @@
# Ruby Information # Ruby Information #
<% Config::CONFIG.sort_by { |x,y| x }.each do |k,v| %><%= k %>: <%= v %> <% Config::CONFIG.sort_by { |x,y| x }.each do |k,v| %><%= k %>: <%= v %>
<% end %> <% end %>
34 changes: 34 additions & 0 deletions test/busted/test_gem.rb
Expand Up @@ -30,6 +30,40 @@ def test_ruby_info
assert_match Dir::tmpdir, filename assert_match Dir::tmpdir, filename
assert File.exists?(filename) assert File.exists?(filename)
assert_match /txt$/, filename assert_match /txt$/, filename
contents = File.read(filename)
Config::CONFIG.each { |k,v|
assert_match k, contents
assert_match v, contents
}
end

def test_gem_information
broken = Busted::Gem.new(@spec)
filename = broken.gem_info_file
assert_match Dir::tmpdir, filename
assert File.exists?(filename)
assert_match /txt$/, filename
contents = File.read(filename)
assert_match ::Gem::RubyGemsVersion, contents
assert_match RUBY_VERSION, contents
assert_match RUBY_RELEASE_DATE, contents
assert_match RUBY_PLATFORM, contents
assert_match ::Gem.dir, contents
assert_match ::Gem.ruby, contents
assert_match ::Gem.bindir, contents
::Gem.platforms.each { |platform|
assert_match platform, contents
}
::Gem.path.each { |path|
assert_match path, contents
}
::Gem.configuration.each do |name,value|
assert_match name.inspect, contents
assert_match value.inspect, contents
end
::Gem.sources.each do |s|
assert_match s, contents
end
end end
end end
end end

0 comments on commit c199320

Please sign in to comment.