summaryrefslogtreecommitdiff
path: root/lib/bundler/env.rb
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2013-01-20 19:25:49 -0800
committerAndre Arko <andre@arko.net>2013-01-20 19:25:49 -0800
commitebd9315339dc6ff0b101c70137f2cd622f880b08 (patch)
tree2f841fae1f972bb335b5cbffd85c82e774243084 /lib/bundler/env.rb
parent5934c537d4f57561354b7bb271f077dced368992 (diff)
downloadbundler-ebd9315339dc6ff0b101c70137f2cd622f880b08.tar.gz
bundle env command (inspired by @Peeja)
closes #2270
Diffstat (limited to 'lib/bundler/env.rb')
-rw-r--r--lib/bundler/env.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb
new file mode 100644
index 0000000000..4229076151
--- /dev/null
+++ b/lib/bundler/env.rb
@@ -0,0 +1,56 @@
+module Bundler
+ class Env
+
+ def write(io)
+ io.write(report)
+ end
+
+ def report
+ out = "Bundler #{Bundler::VERSION}\n"
+
+ out << "Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
+ out << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
+ out << ") [#{RUBY_PLATFORM}]\n"
+
+ out << "Rubygems #{Gem::VERSION}\n"
+
+ out << "rvm #{ENV['rvm_version']}\n" if ENV['rvm_version']
+
+ out << "GEM_HOME #{ENV['GEM_HOME']}\n"
+
+ out << "GEM_PATH #{ENV['GEM_PATH']}\n" unless ENV['GEM_PATH'] == ENV['GEM_HOME']
+
+ %w(rubygems-bundler open_gem).each do |name|
+ specs = Gem::Specification.find_all{|s| s.name == name }
+ out << "#{name} (#{specs.map(&:version).join(',')})\n" unless specs.empty?
+ end
+
+ out << "\nBundler settings\n" unless Bundler.settings.all.empty?
+ Bundler.settings.all.each do |setting|
+ out << " #{setting}\n"
+ Bundler.settings.pretty_values_for(setting).each do |line|
+ out << " " << line << "\n"
+ end
+ end
+
+ out << "\n\n" << "Gemfile\n"
+ out << read_file("Gemfile") << "\n"
+
+ out << "\n\n" << "Gemfile.lock\n"
+ out << read_file("Gemfile.lock") << "\n"
+
+ out
+ end
+
+ private
+
+ def read_file(filename)
+ File.read(filename).strip
+ rescue Errno::ENOENT
+ "<No #{filename} found>"
+ rescue => e
+ "#{e.class}: #{e.message}"
+ end
+
+ end
+end \ No newline at end of file