Skip to content
This repository
Browse code

Make use of silence_stderr in script/lighttpd, script/plugin, and Rai…

…ls::Info

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2903 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 5c1eb899dea9aad18220b6403d3dd83863591f28 1 parent 5feb312
Sam Stephenson authored
2  railties/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Make use of silence_stderr in script/lighttpd, script/plugin, and Rails::Info [Sam Stephenson]
  4
+
3 5
 * Enable HTTP installation of plugins when svn isn't avaialable. Closes #2661. [Chad Fowler]
4 6
 
5 7
 * Load Rails::Info after initialization [Sam Stephenson]
4  railties/lib/commands/lighttpd.rb
... ...
@@ -1,4 +1,6 @@
1  
-unless RUBY_PLATFORM !~ /mswin/ && `lighttpd -version 2>/dev/null`.size > 0
  1
+require 'active_support'
  2
+
  3
+unless RUBY_PLATFORM !~ /mswin/ && !silence_stderr { `lighttpd -version` }.blank?
2 4
   puts "lighttpd is not available on your system (or not in your path)"
3 5
   exit 1
4 6
 end
2  railties/lib/commands/plugin.rb
@@ -119,7 +119,7 @@ def best_install_method
119 119
 
120 120
   def externals
121 121
     return [] unless use_externals?
122  
-    ext = `svn propget svn:externals #{root}/vendor/plugins 2> /dev/null`
  122
+    ext = silence_stderr { `svn propget svn:externals #{root}/vendor/plugins` }
123 123
     ext.reject{ |line| line.strip == '' }.map do |line| 
124 124
       line.strip.split(/\s+/, 2) 
125 125
     end
6  railties/lib/rails_info.rb
@@ -29,8 +29,8 @@ def component_version(component)
29 29
         "#{component.classify}::Version::STRING".constantize
30 30
       end
31 31
     
32  
-      def edge_rails_revision
33  
-        svn_info[/^Revision: (\d+)/, 1] || 'unknown'
  32
+      def edge_rails_revision(info = svn_info)
  33
+        info[/^Revision: (\d+)/, 1]
34 34
       end
35 35
     
36 36
       def to_s
@@ -45,7 +45,7 @@ def to_s
45 45
     protected
46 46
       def svn_info
47 47
         Dir.chdir("#{RAILS_ROOT}/vendor/rails") do
48  
-          IO.popen('svn info') { |f| f.read }
  48
+          silence_stderr { `svn info` }
49 49
         end
50 50
       end
51 51
     end
41  railties/test/rails_info_test.rb
@@ -5,10 +5,22 @@
5 5
 require 'active_support'
6 6
 require 'rails_info'
7 7
 
8  
-class << Rails::Info
9  
-protected
10  
-  def svn_info
11  
-    <<-EOS
  8
+class InfoTest < Test::Unit::TestCase
  9
+  def setup
  10
+    Rails.send :remove_const, :Info
  11
+    silence_warnings { load 'rails_info.rb' }
  12
+  end
  13
+  
  14
+  def test_edge_rails_revision_not_set_when_svn_info_is_empty
  15
+    Rails::Info.property 'Test that this will not be defined' do
  16
+      Rails::Info.edge_rails_revision ''
  17
+    end
  18
+    assert !property_defined?('Test that this will not be defined')
  19
+  end
  20
+  
  21
+  def test_edge_rails_revision_extracted_from_svn_info
  22
+    Rails::Info.property 'Test Edge Rails revision' do
  23
+      Rails::Info.edge_rails_revision <<-EOS
12 24
 Path: .
13 25
 URL: http://www.rubyonrails.com/svn/rails/trunk
14 26
 Repository UUID: 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
@@ -20,13 +32,10 @@ def svn_info
20 32
 Last Changed Date: 2005-11-04 21:04:41 -0600 (Fri, 04 Nov 2005)
21 33
 Properties Last Updated: 2005-10-28 19:30:00 -0500 (Fri, 28 Oct 2005)
22 34
 
23  
-    EOS
24  
-  end
25  
-end
26  
-
27  
-class InfoTest < Test::Unit::TestCase
28  
-  def test_edge_rails_revision_extracted_from_svn_info
29  
-    assert_equal '2881', Rails::Info.edge_rails_revision
  35
+EOS
  36
+    end
  37
+  
  38
+    assert_property 'Test Edge Rails revision', '2881'
30 39
   end
31 40
   
32 41
   def test_property_with_block_swallows_exceptions_and_ignores_property
@@ -57,6 +66,16 @@ def test_component_version
57 66
   end
58 67
 
59 68
 protected
  69
+  def svn_info=(info)
  70
+    Rails::Info.module_eval do
  71
+      class << self
  72
+        def svn_info
  73
+          info
  74
+        end
  75
+      end
  76
+    end
  77
+  end
  78
+  
60 79
   def properties
61 80
     Rails::Info.properties
62 81
   end

0 notes on commit 5c1eb89

Please sign in to comment.
Something went wrong with that request. Please try again.